Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

http_api_reference.md 81KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876
  1. ---
  2. sidebar_position: 1
  3. slug: /http_api_reference
  4. ---
  5. # HTTP API
  6. A complete reference for RAGFlow's RESTful API. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](https://ragflow.io/docs/dev/acquire_ragflow_api_key).
  7. ---
  8. ## DATASET MANAGEMENT
  9. ---
  10. ### Create dataset
  11. **POST** `/api/v1/datasets`
  12. Creates a dataset.
  13. #### Request
  14. - Method: POST
  15. - URL: `/api/v1/datasets`
  16. - Headers:
  17. - `'content-Type: application/json'`
  18. - `'Authorization: Bearer <YOUR_API_KEY>'`
  19. - Body:
  20. - `"name"`: `string`
  21. - `"avatar"`: `string`
  22. - `"description"`: `string`
  23. - `"language"`: `string`
  24. - `"embedding_model"`: `string`
  25. - `"permission"`: `string`
  26. - `"chunk_method"`: `string`
  27. - `"parser_config"`: `object`
  28. ##### Request example
  29. ```bash
  30. curl --request POST \
  31. --url http://{address}/api/v1/datasets \
  32. --header 'Content-Type: application/json' \
  33. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  34. --data '{
  35. "name": "test_1"
  36. }'
  37. ```
  38. ##### Request parameters
  39. - `"name"`: (*Body parameter*), `string`, *Required*
  40. The unique name of the dataset to create. It must adhere to the following requirements:
  41. - Permitted characters include:
  42. - English letters (a-z, A-Z)
  43. - Digits (0-9)
  44. - "_" (underscore)
  45. - Must begin with an English letter or underscore.
  46. - Maximum 65,535 characters.
  47. - Case-insensitive.
  48. - `"avatar"`: (*Body parameter*), `string`
  49. Base64 encoding of the avatar.
  50. - `"description"`: (*Body parameter*), `string`
  51. A brief description of the dataset to create.
  52. - `"language"`: (*Body parameter*), `string`
  53. The language setting of the dataset to create. Available options:
  54. - `"English"` (default)
  55. - `"Chinese"`
  56. - `"embedding_model"`: (*Body parameter*), `string`
  57. The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
  58. - `"permission"`: (*Body parameter*), `string`
  59. Specifies who can access the dataset to create. Available options:
  60. - `"me"`: (Default) Only you can manage the dataset.
  61. - `"team"`: All team members can manage the dataset.
  62. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  63. The chunking method of the dataset to create. Available options:
  64. - `"naive"`: General (default)
  65. - `"manual"`: Manual
  66. - `"qa"`: Q&A
  67. - `"table"`: Table
  68. - `"paper"`: Paper
  69. - `"book"`: Book
  70. - `"laws"`: Laws
  71. - `"presentation"`: Presentation
  72. - `"picture"`: Picture
  73. - `"one"`: One
  74. - `"knowledge_graph"`: Knowledge Graph
  75. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  76. - `"email"`: Email
  77. - `"parser_config"`: (*Body parameter*), `object`
  78. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  79. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  80. - `"chunk_token_count"`: Defaults to `128`.
  81. - `"layout_recognize"`: Defaults to `true`.
  82. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  83. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  84. - `"task_page_size"`: Defaults to `12`. For PDF only.
  85. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  86. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  87. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  88. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  89. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  90. - `"chunk_token_count"`: Defaults to `128`.
  91. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  92. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  93. #### Response
  94. Success:
  95. ```json
  96. {
  97. "code": 0,
  98. "data": {
  99. "avatar": null,
  100. "chunk_count": 0,
  101. "chunk_method": "naive",
  102. "create_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  103. "create_time": 1729761247434,
  104. "created_by": "69736c5e723611efb51b0242ac120007",
  105. "description": null,
  106. "document_count": 0,
  107. "embedding_model": "BAAI/bge-large-zh-v1.5",
  108. "id": "527fa74891e811ef9c650242ac120006",
  109. "language": "English",
  110. "name": "test_1",
  111. "parser_config": {
  112. "chunk_token_num": 128,
  113. "delimiter": "\\n!?;。;!?",
  114. "html4excel": false,
  115. "layout_recognize": true,
  116. "raptor": {
  117. "user_raptor": false
  118. }
  119. },
  120. "permission": "me",
  121. "similarity_threshold": 0.2,
  122. "status": "1",
  123. "tenant_id": "69736c5e723611efb51b0242ac120007",
  124. "token_num": 0,
  125. "update_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  126. "update_time": 1729761247434,
  127. "vector_similarity_weight": 0.3
  128. }
  129. }
  130. ```
  131. Failure:
  132. ```json
  133. {
  134. "code": 102,
  135. "message": "Duplicated knowledgebase name in creating dataset."
  136. }
  137. ```
  138. ---
  139. ### Delete datasets
  140. **DELETE** `/api/v1/datasets`
  141. Deletes datasets by ID.
  142. #### Request
  143. - Method: DELETE
  144. - URL: `/api/v1/datasets`
  145. - Headers:
  146. - `'content-Type: application/json'`
  147. - `'Authorization: Bearer <YOUR_API_KEY>'`
  148. - Body:
  149. - `"ids"`: `list[string]`
  150. ##### Request example
  151. ```bash
  152. curl --request DELETE \
  153. --url http://{address}/api/v1/datasets \
  154. --header 'Content-Type: application/json' \
  155. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  156. --data '{
  157. "ids": ["test_1", "test_2"]
  158. }'
  159. ```
  160. ##### Request parameters
  161. - `"ids"`: (*Body parameter*), `list[string]`
  162. The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
  163. #### Response
  164. Success:
  165. ```json
  166. {
  167. "code": 0
  168. }
  169. ```
  170. Failure:
  171. ```json
  172. {
  173. "code": 102,
  174. "message": "You don't own the dataset."
  175. }
  176. ```
  177. ---
  178. ### Update dataset
  179. **PUT** `/api/v1/datasets/{dataset_id}`
  180. Updates configurations for a specified dataset.
  181. #### Request
  182. - Method: PUT
  183. - URL: `/api/v1/datasets/{dataset_id}`
  184. - Headers:
  185. - `'content-Type: application/json'`
  186. - `'Authorization: Bearer <YOUR_API_KEY>'`
  187. - Body:
  188. - `"name"`: `string`
  189. - `"embedding_model"`: `string`
  190. - `"chunk_method"`: `enum<string>`
  191. ##### Request example
  192. ```bash
  193. curl --request PUT \
  194. --url http://{address}/api/v1/datasets/{dataset_id} \
  195. --header 'Content-Type: application/json' \
  196. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  197. --data '
  198. {
  199. "name": "updated_dataset"
  200. }'
  201. ```
  202. ##### Request parameters
  203. - `dataset_id`: (*Path parameter*)
  204. The ID of the dataset to update.
  205. - `"name"`: (*Body parameter*), `string`
  206. The revised name of the dataset.
  207. - `"embedding_model"`: (*Body parameter*), `string`
  208. The updated embedding model name.
  209. - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
  210. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  211. The chunking method for the dataset. Available options:
  212. - `"naive"`: General
  213. - `"manual`: Manual
  214. - `"qa"`: Q&A
  215. - `"table"`: Table
  216. - `"paper"`: Paper
  217. - `"book"`: Book
  218. - `"laws"`: Laws
  219. - `"presentation"`: Presentation
  220. - `"picture"`: Picture
  221. - `"one"`:One
  222. - `"email"`: Email
  223. - `"knowledge_graph"`: Knowledge Graph
  224. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  225. #### Response
  226. Success:
  227. ```json
  228. {
  229. "code": 0
  230. }
  231. ```
  232. Failure:
  233. ```json
  234. {
  235. "code": 102,
  236. "message": "Can't change tenant_id."
  237. }
  238. ```
  239. ---
  240. ### List datasets
  241. **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  242. Lists datasets.
  243. #### Request
  244. - Method: GET
  245. - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  246. - Headers:
  247. - `'Authorization: Bearer <YOUR_API_KEY>'`
  248. ##### Request example
  249. ```bash
  250. curl --request GET \
  251. --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  252. --header 'Authorization: Bearer <YOUR_API_KEY>'
  253. ```
  254. ##### Request parameters
  255. - `page`: (*Filter parameter*)
  256. Specifies the page on which the datasets will be displayed. Defaults to `1`.
  257. - `page_size`: (*Filter parameter*)
  258. The number of datasets on each page. Defaults to `30`.
  259. - `orderby`: (*Filter parameter*)
  260. The field by which datasets should be sorted. Available options:
  261. - `create_time` (default)
  262. - `update_time`
  263. - `desc`: (*Filter parameter*)
  264. Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
  265. - `name`: (*Filter parameter*)
  266. The name of the dataset to retrieve.
  267. - `id`: (*Filter parameter*)
  268. The ID of the dataset to retrieve.
  269. #### Response
  270. Success:
  271. ```json
  272. {
  273. "code": 0,
  274. "data": [
  275. {
  276. "avatar": "",
  277. "chunk_count": 59,
  278. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  279. "create_time": 1726276357324,
  280. "created_by": "69736c5e723611efb51b0242ac120007",
  281. "description": null,
  282. "document_count": 1,
  283. "embedding_model": "BAAI/bge-large-zh-v1.5",
  284. "id": "6e211ee0723611efa10a0242ac120007",
  285. "language": "English",
  286. "name": "mysql",
  287. "chunk_method": "knowledge_graph",
  288. "parser_config": {
  289. "chunk_token_num": 8192,
  290. "delimiter": "\\n!?;。;!?",
  291. "entity_types": [
  292. "organization",
  293. "person",
  294. "location",
  295. "event",
  296. "time"
  297. ]
  298. },
  299. "permission": "me",
  300. "similarity_threshold": 0.2,
  301. "status": "1",
  302. "tenant_id": "69736c5e723611efb51b0242ac120007",
  303. "token_num": 12744,
  304. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  305. "update_time": 1728533243536,
  306. "vector_similarity_weight": 0.3
  307. }
  308. ]
  309. }
  310. ```
  311. Failure:
  312. ```json
  313. {
  314. "code": 102,
  315. "message": "The dataset doesn't exist"
  316. }
  317. ```
  318. ---
  319. ## FILE MANAGEMENT WITHIN DATASET
  320. ---
  321. ### Upload documents
  322. **POST** `/api/v1/datasets/{dataset_id}/documents`
  323. Uploads documents to a specified dataset.
  324. #### Request
  325. - Method: POST
  326. - URL: `/api/v1/datasets/{dataset_id}/documents`
  327. - Headers:
  328. - `'Content-Type: multipart/form-data'`
  329. - `'Authorization: Bearer <YOUR_API_KEY>'`
  330. - Form:
  331. - `'file=@{FILE_PATH}'`
  332. ##### Request example
  333. ```bash
  334. curl --request POST \
  335. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  336. --header 'Content-Type: multipart/form-data' \
  337. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  338. --form 'file=@./test1.txt' \
  339. --form 'file=@./test2.pdf'
  340. ```
  341. ##### Request parameters
  342. - `dataset_id`: (*Path parameter*)
  343. The ID of the dataset to which the documents will be uploaded.
  344. - `'file'`: (*Body parameter*)
  345. A document to upload.
  346. #### Response
  347. Success:
  348. ```json
  349. {
  350. "code": 0,
  351. "data": [
  352. {
  353. "chunk_method": "naive",
  354. "created_by": "69736c5e723611efb51b0242ac120007",
  355. "dataset_id": "527fa74891e811ef9c650242ac120006",
  356. "id": "b330ec2e91ec11efbc510242ac120004",
  357. "location": "1.txt",
  358. "name": "1.txt",
  359. "parser_config": {
  360. "chunk_token_num": 128,
  361. "delimiter": "\\n!?;。;!?",
  362. "html4excel": false,
  363. "layout_recognize": true,
  364. "raptor": {
  365. "user_raptor": false
  366. }
  367. },
  368. "run": "UNSTART",
  369. "size": 17966,
  370. "thumbnail": "",
  371. "type": "doc"
  372. }
  373. ]
  374. }
  375. ```
  376. Failure:
  377. ```json
  378. {
  379. "code": 101,
  380. "message": "No file part!"
  381. }
  382. ```
  383. ---
  384. ### Update document
  385. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  386. Updates configurations for a specified document.
  387. #### Request
  388. - Method: PUT
  389. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  390. - Headers:
  391. - `'content-Type: application/json'`
  392. - `'Authorization: Bearer <YOUR_API_KEY>'`
  393. - Body:
  394. - `"name"`:`string`
  395. - `"chunk_method"`:`string`
  396. - `"parser_config"`:`object`
  397. ##### Request example
  398. ```bash
  399. curl --request PUT \
  400. --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
  401. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  402. --header 'Content-Type: application/json' \
  403. --data '
  404. {
  405. "name": "manual.txt",
  406. "chunk_method": "manual",
  407. "parser_config": {"chunk_token_count": 128}
  408. }'
  409. ```
  410. ##### Request parameters
  411. - `dataset_id`: (*Path parameter*)
  412. The ID of the associated dataset.
  413. - `document_id`: (*Path parameter*)
  414. The ID of the document to update.
  415. - `"name"`: (*Body parameter*), `string`
  416. - `"chunk_method"`: (*Body parameter*), `string`
  417. The parsing method to apply to the document:
  418. - `"naive"`: General
  419. - `"manual`: Manual
  420. - `"qa"`: Q&A
  421. - `"table"`: Table
  422. - `"paper"`: Paper
  423. - `"book"`: Book
  424. - `"laws"`: Laws
  425. - `"presentation"`: Presentation
  426. - `"picture"`: Picture
  427. - `"one"`: One
  428. - `"knowledge_graph"`: Knowledge Graph
  429. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  430. - `"email"`: Email
  431. - `"parser_config"`: (*Body parameter*), `object`
  432. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  433. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  434. - `"chunk_token_count"`: Defaults to `128`.
  435. - `"layout_recognize"`: Defaults to `true`.
  436. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  437. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  438. - `"task_page_size"`: Defaults to `12`. For PDF only.
  439. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  440. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  441. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  442. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  443. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  444. - `"chunk_token_count"`: Defaults to `128`.
  445. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  446. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  447. #### Response
  448. Success:
  449. ```json
  450. {
  451. "code": 0
  452. }
  453. ```
  454. Failure:
  455. ```json
  456. {
  457. "code": 102,
  458. "message": "The dataset does not have the document."
  459. }
  460. ```
  461. ---
  462. ### Download document
  463. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  464. Downloads a document from a specified dataset.
  465. #### Request
  466. - Method: GET
  467. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  468. - Headers:
  469. - `'Authorization: Bearer <YOUR_API_KEY>'`
  470. - Output:
  471. - `'{PATH_TO_THE_FILE}'`
  472. ##### Request example
  473. ```bash
  474. curl --request GET \
  475. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
  476. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  477. --output ./ragflow.txt
  478. ```
  479. ##### Request parameters
  480. - `dataset_id`: (*Path parameter*)
  481. The associated dataset ID.
  482. - `documents_id`: (*Path parameter*)
  483. The ID of the document to download.
  484. #### Response
  485. Success:
  486. ```json
  487. This is a test to verify the file download feature.
  488. ```
  489. Failure:
  490. ```json
  491. {
  492. "code": 102,
  493. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  494. }
  495. ```
  496. ---
  497. ### List documents
  498. **GET** `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  499. Lists documents in a specified dataset.
  500. #### Request
  501. - Method: GET
  502. - URL: `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  503. - Headers:
  504. - `'content-Type: application/json'`
  505. - `'Authorization: Bearer <YOUR_API_KEY>'`
  506. ##### Request example
  507. ```bash
  508. curl --request GET \
  509. --url http://{address}/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name} \
  510. --header 'Authorization: Bearer <YOUR_API_KEY>'
  511. ```
  512. ##### Request parameters
  513. - `dataset_id`: (*Path parameter*)
  514. The associated dataset ID.
  515. - `keywords`: (*Filter parameter*), `string`
  516. The keywords used to match document titles.
  517. - `page`: (*Filter parameter*), `integer`
  518. Specifies the page on which the documents will be displayed. Defaults to `1`.
  519. - `page_size`: (*Filter parameter*), `integer`
  520. The maximum number of documents on each page. Defaults to `30`.
  521. - `orderby`: (*Filter parameter*), `string`
  522. The field by which documents should be sorted. Available options:
  523. - `create_time` (default)
  524. - `update_time`
  525. - `desc`: (*Filter parameter*), `boolean`
  526. Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
  527. - `id`: (*Filter parameter*), `string`
  528. The ID of the document to retrieve.
  529. #### Response
  530. Success:
  531. ```json
  532. {
  533. "code": 0,
  534. "data": {
  535. "docs": [
  536. {
  537. "chunk_count": 0,
  538. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  539. "create_time": 1728897061948,
  540. "created_by": "69736c5e723611efb51b0242ac120007",
  541. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  542. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  543. "location": "Test_2.txt",
  544. "name": "Test_2.txt",
  545. "parser_config": {
  546. "chunk_token_count": 128,
  547. "delimiter": "\n!?。;!?",
  548. "layout_recognize": true,
  549. "task_page_size": 12
  550. },
  551. "chunk_method": "naive",
  552. "process_begin_at": null,
  553. "process_duation": 0.0,
  554. "progress": 0.0,
  555. "progress_msg": "",
  556. "run": "0",
  557. "size": 7,
  558. "source_type": "local",
  559. "status": "1",
  560. "thumbnail": null,
  561. "token_count": 0,
  562. "type": "doc",
  563. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  564. "update_time": 1728897061948
  565. }
  566. ],
  567. "total": 1
  568. }
  569. }
  570. ```
  571. Failure:
  572. ```json
  573. {
  574. "code": 102,
  575. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  576. }
  577. ```
  578. ---
  579. ### Delete documents
  580. **DELETE** `/api/v1/datasets/{dataset_id}/documents`
  581. Deletes documents by ID.
  582. #### Request
  583. - Method: DELETE
  584. - URL: `/api/v1/datasets/{dataset_id}/documents`
  585. - Headers:
  586. - `'Content-Type: application/json'`
  587. - `'Authorization: Bearer <YOUR_API_KEY>'`
  588. - Body:
  589. - `"ids"`: `list[string]`
  590. ##### Request example
  591. ```bash
  592. curl --request DELETE \
  593. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  594. --header 'Content-Type: application/json' \
  595. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  596. --data '
  597. {
  598. "ids": ["id_1","id_2"]
  599. }'
  600. ```
  601. ##### Request parameters
  602. - `dataset_id`: (*Path parameter*)
  603. The associated dataset ID.
  604. - `"ids"`: (*Body parameter*), `list[string]`
  605. The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
  606. #### Response
  607. Success:
  608. ```json
  609. {
  610. "code": 0
  611. }.
  612. ```
  613. Failure:
  614. ```json
  615. {
  616. "code": 102,
  617. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  618. }
  619. ```
  620. ---
  621. ### Parse documents
  622. **POST** `/api/v1/datasets/{dataset_id}/chunks`
  623. Parses documents in a specified dataset.
  624. #### Request
  625. - Method: POST
  626. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  627. - Headers:
  628. - `'content-Type: application/json'`
  629. - `'Authorization: Bearer <YOUR_API_KEY>'`
  630. - Body:
  631. - `"document_ids"`: `list[string]`
  632. ##### Request example
  633. ```bash
  634. curl --request POST \
  635. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  636. --header 'Content-Type: application/json' \
  637. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  638. --data '
  639. {
  640. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  641. }'
  642. ```
  643. ##### Request parameters
  644. - `dataset_id`: (*Path parameter*)
  645. The dataset ID.
  646. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  647. The IDs of the documents to parse.
  648. #### Response
  649. Success:
  650. ```json
  651. {
  652. "code": 0
  653. }
  654. ```
  655. Failure:
  656. ```json
  657. {
  658. "code": 102,
  659. "message": "`document_ids` is required"
  660. }
  661. ```
  662. ---
  663. ### Stop parsing documents
  664. **DELETE** `/api/v1/datasets/{dataset_id}/chunks`
  665. Stops parsing specified documents.
  666. #### Request
  667. - Method: DELETE
  668. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  669. - Headers:
  670. - `'content-Type: application/json'`
  671. - `'Authorization: Bearer <YOUR_API_KEY>'`
  672. - Body:
  673. - `"document_ids"`: `list[string]`
  674. ##### Request example
  675. ```bash
  676. curl --request DELETE \
  677. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  678. --header 'Content-Type: application/json' \
  679. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  680. --data '
  681. {
  682. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  683. }'
  684. ```
  685. ##### Request parameters
  686. - `dataset_id`: (*Path parameter*)
  687. The associated dataset ID.
  688. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  689. The IDs of the documents for which the parsing should be stopped.
  690. #### Response
  691. Success:
  692. ```json
  693. {
  694. "code": 0
  695. }
  696. ```
  697. Failure:
  698. ```json
  699. {
  700. "code": 102,
  701. "message": "`document_ids` is required"
  702. }
  703. ```
  704. ---
  705. ## CHUNK MANAGEMENT WITHIN DATASET
  706. ---
  707. ### Add chunk
  708. **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  709. Adds a chunk to a specified document in a specified dataset.
  710. #### Request
  711. - Method: POST
  712. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  713. - Headers:
  714. - `'content-Type: application/json'`
  715. - `'Authorization: Bearer <YOUR_API_KEY>'`
  716. - Body:
  717. - `"content"`: `string`
  718. - `"important_keywords"`: `list[string]`
  719. ##### Request example
  720. ```bash
  721. curl --request POST \
  722. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  723. --header 'Content-Type: application/json' \
  724. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  725. --data '
  726. {
  727. "content": "<CHUNK_CONTENT_HERE>"
  728. }'
  729. ```
  730. ##### Request parameters
  731. - `dataset_id`: (*Path parameter*)
  732. The associated dataset ID.
  733. - `document_ids`: (*Path parameter*)
  734. The associated document ID.
  735. - `"content"`: (*Body parameter*), `string`, *Required*
  736. The text content of the chunk.
  737. - `"important_keywords`(*Body parameter*), `list[string]`
  738. The key terms or phrases to tag with the chunk.
  739. - `"questions"`(*Body parameter*), `list[string]`
  740. If there is a given question, the embedded chunks will be based on them
  741. #### Response
  742. Success:
  743. ```json
  744. {
  745. "code": 0,
  746. "data": {
  747. "chunk": {
  748. "content": "who are you",
  749. "create_time": "2024-12-30 16:59:55",
  750. "create_timestamp": 1735549195.969164,
  751. "dataset_id": "72f36e1ebdf411efb7250242ac120006",
  752. "document_id": "61d68474be0111ef98dd0242ac120006",
  753. "id": "12ccdc56e59837e5",
  754. "important_keywords": [],
  755. "questions": []
  756. }
  757. }
  758. }
  759. ```
  760. Failure:
  761. ```json
  762. {
  763. "code": 102,
  764. "message": "`content` is required"
  765. }
  766. ```
  767. ---
  768. ### List chunks
  769. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}`
  770. Lists chunks in a specified document.
  771. #### Request
  772. - Method: GET
  773. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id}`
  774. - Headers:
  775. - `'Authorization: Bearer <YOUR_API_KEY>'`
  776. ##### Request example
  777. ```bash
  778. curl --request GET \
  779. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id} \
  780. --header 'Authorization: Bearer <YOUR_API_KEY>'
  781. ```
  782. ##### Request parameters
  783. - `dataset_id`: (*Path parameter*)
  784. The associated dataset ID.
  785. - `document_ids`: (*Path parameter*)
  786. The associated document ID.
  787. - `keywords`(*Filter parameter*), `string`
  788. The keywords used to match chunk content.
  789. - `page`(*Filter parameter*), `integer`
  790. Specifies the page on which the chunks will be displayed. Defaults to `1`.
  791. - `page_size`(*Filter parameter*), `integer`
  792. The maximum number of chunks on each page. Defaults to `1024`.
  793. - `id`(*Filter parameter*), `string`
  794. The ID of the chunk to retrieve.
  795. #### Response
  796. Success:
  797. ```json
  798. {
  799. "code": 0,
  800. "data": {
  801. "chunks": [
  802. {
  803. "available_int": 1,
  804. "content": "This is a test content.",
  805. "docnm_kwd": "1.txt",
  806. "document_id": "b330ec2e91ec11efbc510242ac120004",
  807. "id": "b48c170e90f70af998485c1065490726",
  808. "image_id": "",
  809. "important_keywords": "",
  810. "positions": [
  811. ""
  812. ]
  813. }
  814. ],
  815. "doc": {
  816. "chunk_count": 1,
  817. "chunk_method": "naive",
  818. "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
  819. "create_time": 1729763127646,
  820. "created_by": "69736c5e723611efb51b0242ac120007",
  821. "dataset_id": "527fa74891e811ef9c650242ac120006",
  822. "id": "b330ec2e91ec11efbc510242ac120004",
  823. "location": "1.txt",
  824. "name": "1.txt",
  825. "parser_config": {
  826. "chunk_token_num": 128,
  827. "delimiter": "\\n!?;。;!?",
  828. "html4excel": false,
  829. "layout_recognize": true,
  830. "raptor": {
  831. "user_raptor": false
  832. }
  833. },
  834. "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
  835. "process_duation": 0.54213,
  836. "progress": 0.0,
  837. "progress_msg": "Task dispatched...",
  838. "run": "2",
  839. "size": 17966,
  840. "source_type": "local",
  841. "status": "1",
  842. "thumbnail": "",
  843. "token_count": 8,
  844. "type": "doc",
  845. "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
  846. "update_time": 1729767795721
  847. },
  848. "total": 1
  849. }
  850. }
  851. ```
  852. Failure:
  853. ```json
  854. {
  855. "code": 102,
  856. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  857. }
  858. ```
  859. ---
  860. ### Delete chunks
  861. **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  862. Deletes chunks by ID.
  863. #### Request
  864. - Method: DELETE
  865. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  866. - Headers:
  867. - `'content-Type: application/json'`
  868. - `'Authorization: Bearer <YOUR_API_KEY>'`
  869. - Body:
  870. - `"chunk_ids"`: `list[string]`
  871. ##### Request example
  872. ```bash
  873. curl --request DELETE \
  874. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  875. --header 'Content-Type: application/json' \
  876. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  877. --data '
  878. {
  879. "chunk_ids": ["test_1", "test_2"]
  880. }'
  881. ```
  882. ##### Request parameters
  883. - `dataset_id`: (*Path parameter*)
  884. The associated dataset ID.
  885. - `document_ids`: (*Path parameter*)
  886. The associated document ID.
  887. - `"chunk_ids"`: (*Body parameter*), `list[string]`
  888. The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
  889. #### Response
  890. Success:
  891. ```json
  892. {
  893. "code": 0
  894. }
  895. ```
  896. Failure:
  897. ```json
  898. {
  899. "code": 102,
  900. "message": "`chunk_ids` is required"
  901. }
  902. ```
  903. ---
  904. ### Update chunk
  905. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  906. Updates content or configurations for a specified chunk.
  907. #### Request
  908. - Method: PUT
  909. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  910. - Headers:
  911. - `'content-Type: application/json'`
  912. - `'Authorization: Bearer <YOUR_API_KEY>'`
  913. - Body:
  914. - `"content"`: `string`
  915. - `"important_keywords"`: `list[string]`
  916. - `"available"`: `boolean`
  917. ##### Request example
  918. ```bash
  919. curl --request PUT \
  920. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
  921. --header 'Content-Type: application/json' \
  922. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  923. --data '
  924. {
  925. "content": "ragflow123",
  926. "important_keywords": []
  927. }'
  928. ```
  929. ##### Request parameters
  930. - `dataset_id`: (*Path parameter*)
  931. The associated dataset ID.
  932. - `document_ids`: (*Path parameter*)
  933. The associated document ID.
  934. - `chunk_id`: (*Path parameter*)
  935. The ID of the chunk to update.
  936. - `"content"`: (*Body parameter*), `string`
  937. The text content of the chunk.
  938. - `"important_keywords"`: (*Body parameter*), `list[string]`
  939. A list of key terms or phrases to tag with the chunk.
  940. - `"available"`: (*Body parameter*) `boolean`
  941. The chunk's availability status in the dataset. Value options:
  942. - `true`: Available (default)
  943. - `false`: Unavailable
  944. #### Response
  945. Success:
  946. ```json
  947. {
  948. "code": 0
  949. }
  950. ```
  951. Failure:
  952. ```json
  953. {
  954. "code": 102,
  955. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  956. }
  957. ```
  958. ---
  959. ### Retrieve chunks
  960. **POST** `/api/v1/retrieval`
  961. Retrieves chunks from specified datasets.
  962. #### Request
  963. - Method: POST
  964. - URL: `/api/v1/retrieval`
  965. - Headers:
  966. - `'content-Type: application/json'`
  967. - `'Authorization: Bearer <YOUR_API_KEY>'`
  968. - Body:
  969. - `"question"`: `string`
  970. - `"dataset_ids"`: `list[string]`
  971. - `"document_ids"`: `list[string]`
  972. - `"page"`: `integer`
  973. - `"page_size"`: `integer`
  974. - `"similarity_threshold"`: `float`
  975. - `"vector_similarity_weight"`: `float`
  976. - `"top_k"`: `integer`
  977. - `"rerank_id"`: `string`
  978. - `"keyword"`: `boolean`
  979. - `"highlight"`: `boolean`
  980. ##### Request example
  981. ```bash
  982. curl --request POST \
  983. --url http://{address}/api/v1/retrieval \
  984. --header 'Content-Type: application/json' \
  985. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  986. --data '
  987. {
  988. "question": "What is advantage of ragflow?",
  989. "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
  990. "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
  991. }'
  992. ```
  993. ##### Request parameter
  994. - `"question"`: (*Body parameter*), `string`, *Required*
  995. The user query or query keywords.
  996. - `"dataset_ids"`: (*Body parameter*) `list[string]`
  997. The IDs of the datasets to search. If you do not set this argument, ensure that you set `"document_ids"`.
  998. - `"document_ids"`: (*Body parameter*), `list[string]`
  999. The IDs of the documents to search. Ensure that all selected documents use the same embedding model. Otherwise, an error will occur. If you do not set this argument, ensure that you set `"dataset_ids"`.
  1000. - `"page"`: (*Body parameter*), `integer`
  1001. Specifies the page on which the chunks will be displayed. Defaults to `1`.
  1002. - `"page_size"`: (*Body parameter*)
  1003. The maximum number of chunks on each page. Defaults to `30`.
  1004. - `"similarity_threshold"`: (*Body parameter*)
  1005. The minimum similarity score. Defaults to `0.2`.
  1006. - `"vector_similarity_weight"`: (*Body parameter*), `float`
  1007. The weight of vector cosine similarity. Defaults to `0.3`. If x represents the weight of vector cosine similarity, then (1 - x) is the term similarity weight.
  1008. - `"top_k"`: (*Body parameter*), `integer`
  1009. The number of chunks engaged in vector cosine computation. Defaults to `1024`.
  1010. - `"rerank_id"`: (*Body parameter*), `integer`
  1011. The ID of the rerank model.
  1012. - `"keyword"`: (*Body parameter*), `boolean`
  1013. Indicates whether to enable keyword-based matching:
  1014. - `true`: Enable keyword-based matching.
  1015. - `false`: Disable keyword-based matching (default).
  1016. - `"highlight"`: (*Body parameter*), `boolean`
  1017. Specifies whether to enable highlighting of matched terms in the results:
  1018. - `true`: Enable highlighting of matched terms.
  1019. - `false`: Disable highlighting of matched terms (default).
  1020. #### Response
  1021. Success:
  1022. ```json
  1023. {
  1024. "code": 0,
  1025. "data": {
  1026. "chunks": [
  1027. {
  1028. "content": "ragflow content",
  1029. "content_ltks": "ragflow content",
  1030. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  1031. "document_keyword": "1.txt",
  1032. "highlight": "<em>ragflow</em> content",
  1033. "id": "d78435d142bd5cf6704da62c778795c5",
  1034. "image_id": "",
  1035. "important_keywords": [
  1036. ""
  1037. ],
  1038. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1039. "positions": [
  1040. ""
  1041. ],
  1042. "similarity": 0.9669436601210759,
  1043. "term_similarity": 1.0,
  1044. "vector_similarity": 0.8898122004035864
  1045. }
  1046. ],
  1047. "doc_aggs": [
  1048. {
  1049. "count": 1,
  1050. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1051. "doc_name": "1.txt"
  1052. }
  1053. ],
  1054. "total": 1
  1055. }
  1056. }
  1057. ```
  1058. Failure:
  1059. ```json
  1060. {
  1061. "code": 102,
  1062. "message": "`datasets` is required."
  1063. }
  1064. ```
  1065. ---
  1066. ## CHAT ASSISTANT MANAGEMENT
  1067. ---
  1068. ### Create chat assistant
  1069. **POST** `/api/v1/chats`
  1070. Creates a chat assistant.
  1071. #### Request
  1072. - Method: POST
  1073. - URL: `/api/v1/chats`
  1074. - Headers:
  1075. - `'content-Type: application/json'`
  1076. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1077. - Body:
  1078. - `"name"`: `string`
  1079. - `"avatar"`: `string`
  1080. - `"dataset_ids"`: `list[string]`
  1081. - `"llm"`: `object`
  1082. - `"prompt"`: `object`
  1083. ##### Request example
  1084. ```shell
  1085. curl --request POST \
  1086. --url http://{address}/api/v1/chats \
  1087. --header 'Content-Type: application/json' \
  1088. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1089. --data '{
  1090. "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
  1091. "name":"new_chat_1"
  1092. }'
  1093. ```
  1094. ##### Request parameters
  1095. - `"name"`: (*Body parameter*), `string`, *Required*
  1096. The name of the chat assistant.
  1097. - `"avatar"`: (*Body parameter*), `string`
  1098. Base64 encoding of the avatar.
  1099. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1100. The IDs of the associated datasets.
  1101. - `"llm"`: (*Body parameter*), `object`
  1102. The LLM settings for the chat assistant to create. If it is not explicitly set, a JSON object with the following values will be generated as the default. An `llm` JSON object contains the following attributes:
  1103. - `"model_name"`, `string`
  1104. The chat model name. If not set, the user's default chat model will be used.
  1105. - `"temperature"`: `float`
  1106. Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to `0.1`.
  1107. - `"top_p"`: `float`
  1108. Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to `0.3`
  1109. - `"presence_penalty"`: `float`
  1110. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1111. - `"frequency penalty"`: `float`
  1112. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1113. - `"max_token"`: `integer`
  1114. The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
  1115. - `"prompt"`: (*Body parameter*), `object`
  1116. Instructions for the LLM to follow. If it is not explicitly set, a JSON object with the following values will be generated as the default. A `prompt` JSON object contains the following attributes:
  1117. - `"similarity_threshold"`: `float` RAGFlow employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted reranking score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is `0.2`.
  1118. - `"keywords_similarity_weight"`: `float` This argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is `0.7`.
  1119. - `"top_n"`: `int` This argument specifies the number of top chunks with similarity scores above the `similarity_threshold` that are fed to the LLM. The LLM will *only* access these 'top N' chunks. The default value is `8`.
  1120. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1121. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1122. - All the variables in 'System' should be curly bracketed.
  1123. - The default value is `[{"key": "knowledge", "optional": true}]`.
  1124. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1125. - `top_k`: `int` Refers to the process of reordering or selecting the top-k items from a list or set based on a specific ranking criterion. Default to 1024.
  1126. - `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
  1127. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1128. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1129. - `"prompt"`: `string` The prompt content.
  1130. #### Response
  1131. Success:
  1132. ```json
  1133. {
  1134. "code": 0,
  1135. "data": {
  1136. "avatar": "",
  1137. "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1138. "create_time": 1729768709023,
  1139. "dataset_ids": [
  1140. "527fa74891e811ef9c650242ac120006"
  1141. ],
  1142. "description": "A helpful Assistant",
  1143. "do_refer": "1",
  1144. "id": "b1f2f15691f911ef81180242ac120003",
  1145. "language": "English",
  1146. "llm": {
  1147. "frequency_penalty": 0.7,
  1148. "max_tokens": 512,
  1149. "model_name": "qwen-plus@Tongyi-Qianwen",
  1150. "presence_penalty": 0.4,
  1151. "temperature": 0.1,
  1152. "top_p": 0.3
  1153. },
  1154. "name": "12234",
  1155. "prompt": {
  1156. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1157. "keywords_similarity_weight": 0.3,
  1158. "opener": "Hi! I'm your assistant, what can I do for you?",
  1159. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n ",
  1160. "rerank_model": "",
  1161. "similarity_threshold": 0.2,
  1162. "top_n": 6,
  1163. "variables": [
  1164. {
  1165. "key": "knowledge",
  1166. "optional": false
  1167. }
  1168. ]
  1169. },
  1170. "prompt_type": "simple",
  1171. "status": "1",
  1172. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1173. "top_k": 1024,
  1174. "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1175. "update_time": 1729768709023
  1176. }
  1177. }
  1178. ```
  1179. Failure:
  1180. ```json
  1181. {
  1182. "code": 102,
  1183. "message": "Duplicated chat name in creating dataset."
  1184. }
  1185. ```
  1186. ---
  1187. ### Update chat assistant
  1188. **PUT** `/api/v1/chats/{chat_id}`
  1189. Updates configurations for a specified chat assistant.
  1190. #### Request
  1191. - Method: PUT
  1192. - URL: `/api/v1/chats/{chat_id}`
  1193. - Headers:
  1194. - `'content-Type: application/json'`
  1195. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1196. - Body:
  1197. - `"name"`: `string`
  1198. - `"avatar"`: `string`
  1199. - `"dataset_ids"`: `list[string]`
  1200. - `"llm"`: `object`
  1201. - `"prompt"`: `object`
  1202. ##### Request example
  1203. ```bash
  1204. curl --request PUT \
  1205. --url http://{address}/api/v1/chats/{chat_id} \
  1206. --header 'Content-Type: application/json' \
  1207. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1208. --data '
  1209. {
  1210. "name":"Test"
  1211. }'
  1212. ```
  1213. #### Parameters
  1214. - `chat_id`: (*Path parameter*)
  1215. The ID of the chat assistant to update.
  1216. - `"name"`: (*Body parameter*), `string`, *Required*
  1217. The revised name of the chat assistant.
  1218. - `"avatar"`: (*Body parameter*), `string`
  1219. Base64 encoding of the avatar.
  1220. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1221. The IDs of the associated datasets.
  1222. - `"llm"`: (*Body parameter*), `object`
  1223. The LLM settings for the chat assistant to create. If it is not explicitly set, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
  1224. - `"model_name"`, `string`
  1225. The chat model name. If not set, the user's default chat model will be used.
  1226. - `"temperature"`: `float`
  1227. Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to `0.1`.
  1228. - `"top_p"`: `float`
  1229. Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to `0.3`
  1230. - `"presence_penalty"`: `float`
  1231. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1232. - `"frequency penalty"`: `float`
  1233. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1234. - `"max_token"`: `integer`
  1235. The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
  1236. - `"prompt"`: (*Body parameter*), `object`
  1237. Instructions for the LLM to follow. A `prompt` object contains the following attributes:
  1238. - `"similarity_threshold"`: `float` RAGFlow employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted rerank score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is `0.2`.
  1239. - `"keywords_similarity_weight"`: `float` This argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is `0.7`.
  1240. - `"top_n"`: `int` This argument specifies the number of top chunks with similarity scores above the `similarity_threshold` that are fed to the LLM. The LLM will *only* access these 'top N' chunks. The default value is `8`.
  1241. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1242. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1243. - All the variables in 'System' should be curly bracketed.
  1244. - The default value is `[{"key": "knowledge", "optional": true}]`
  1245. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1246. - `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
  1247. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1248. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1249. - `"prompt"`: `string` The prompt content.
  1250. #### Response
  1251. Success:
  1252. ```json
  1253. {
  1254. "code": 0
  1255. }
  1256. ```
  1257. Failure:
  1258. ```json
  1259. {
  1260. "code": 102,
  1261. "message": "Duplicated chat name in updating dataset."
  1262. }
  1263. ```
  1264. ---
  1265. ### Delete chat assistants
  1266. **DELETE** `/api/v1/chats`
  1267. Deletes chat assistants by ID.
  1268. #### Request
  1269. - Method: DELETE
  1270. - URL: `/api/v1/chats`
  1271. - Headers:
  1272. - `'content-Type: application/json'`
  1273. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1274. - Body:
  1275. - `"ids"`: `list[string]`
  1276. ##### Request example
  1277. ```bash
  1278. curl --request DELETE \
  1279. --url http://{address}/api/v1/chats \
  1280. --header 'Content-Type: application/json' \
  1281. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1282. --data '
  1283. {
  1284. "ids": ["test_1", "test_2"]
  1285. }'
  1286. ```
  1287. ##### Request parameters
  1288. - `"ids"`: (*Body parameter*), `list[string]`
  1289. The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
  1290. #### Response
  1291. Success:
  1292. ```json
  1293. {
  1294. "code": 0
  1295. }
  1296. ```
  1297. Failure:
  1298. ```json
  1299. {
  1300. "code": 102,
  1301. "message": "ids are required"
  1302. }
  1303. ```
  1304. ---
  1305. ### List chat assistants
  1306. **GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
  1307. Lists chat assistants.
  1308. #### Request
  1309. - Method: GET
  1310. - URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1311. - Headers:
  1312. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1313. ##### Request example
  1314. ```bash
  1315. curl --request GET \
  1316. --url http://{address}/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1317. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1318. ```
  1319. ##### Request parameters
  1320. - `page`: (*Filter parameter*), `integer`
  1321. Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
  1322. - `page_size`: (*Filter parameter*), `integer`
  1323. The number of chat assistants on each page. Defaults to `30`.
  1324. - `orderby`: (*Filter parameter*), `string`
  1325. The attribute by which the results are sorted. Available options:
  1326. - `create_time` (default)
  1327. - `update_time`
  1328. - `desc`: (*Filter parameter*), `boolean`
  1329. Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `true`.
  1330. - `id`: (*Filter parameter*), `string`
  1331. The ID of the chat assistant to retrieve.
  1332. - `name`: (*Filter parameter*), `string`
  1333. The name of the chat assistant to retrieve.
  1334. #### Response
  1335. Success:
  1336. ```json
  1337. {
  1338. "code": 0,
  1339. "data": [
  1340. {
  1341. "avatar": "",
  1342. "create_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1343. "create_time": 1729232406637,
  1344. "description": "A helpful Assistant",
  1345. "do_refer": "1",
  1346. "id": "04d0d8e28d1911efa3630242ac120006",
  1347. "dataset_ids": ["527fa74891e811ef9c650242ac120006"],
  1348. "language": "English",
  1349. "llm": {
  1350. "frequency_penalty": 0.7,
  1351. "max_tokens": 512,
  1352. "model_name": "qwen-plus@Tongyi-Qianwen",
  1353. "presence_penalty": 0.4,
  1354. "temperature": 0.1,
  1355. "top_p": 0.3
  1356. },
  1357. "name": "13243",
  1358. "prompt": {
  1359. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1360. "keywords_similarity_weight": 0.3,
  1361. "opener": "Hi! I'm your assistant, what can I do for you?",
  1362. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n",
  1363. "rerank_model": "",
  1364. "similarity_threshold": 0.2,
  1365. "top_n": 6,
  1366. "variables": [
  1367. {
  1368. "key": "knowledge",
  1369. "optional": false
  1370. }
  1371. ]
  1372. },
  1373. "prompt_type": "simple",
  1374. "status": "1",
  1375. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1376. "top_k": 1024,
  1377. "update_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1378. "update_time": 1729232406638
  1379. }
  1380. ]
  1381. }
  1382. ```
  1383. Failure:
  1384. ```json
  1385. {
  1386. "code": 102,
  1387. "message": "The chat doesn't exist"
  1388. }
  1389. ```
  1390. ---
  1391. ## SESSION MANAGEMENT
  1392. ---
  1393. ### Create session with chat assistant
  1394. **POST** `/api/v1/chats/{chat_id}/sessions`
  1395. Creates a session with a chat assistant.
  1396. #### Request
  1397. - Method: POST
  1398. - URL: `/api/v1/chats/{chat_id}/sessions`
  1399. - Headers:
  1400. - `'content-Type: application/json'`
  1401. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1402. - Body:
  1403. - `"name"`: `string`
  1404. - `"user_id"`: `string` (optional)
  1405. ##### Request example
  1406. ```bash
  1407. curl --request POST \
  1408. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1409. --header 'Content-Type: application/json' \
  1410. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1411. --data '
  1412. {
  1413. "name": "new session"
  1414. }'
  1415. ```
  1416. ##### Request parameters
  1417. - `chat_id`: (*Path parameter*)
  1418. The ID of the associated chat assistant.
  1419. - `"name"`: (*Body parameter*), `string`
  1420. The name of the chat session to create.
  1421. - `"user_id"`: (*Body parameter*), `string`
  1422. Optional user-defined ID.
  1423. #### Response
  1424. Success:
  1425. ```json
  1426. {
  1427. "code": 0,
  1428. "data": {
  1429. "chat_id": "2ca4b22e878011ef88fe0242ac120005",
  1430. "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1431. "create_time": 1728636374571,
  1432. "id": "4606b4ec87ad11efbc4f0242ac120006",
  1433. "messages": [
  1434. {
  1435. "content": "Hi! I am your assistant,can I help you?",
  1436. "role": "assistant"
  1437. }
  1438. ],
  1439. "name": "new session",
  1440. "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1441. "update_time": 1728636374571
  1442. }
  1443. }
  1444. ```
  1445. Failure:
  1446. ```json
  1447. {
  1448. "code": 102,
  1449. "message": "Name cannot be empty."
  1450. }
  1451. ```
  1452. ---
  1453. ### Update chat assistant's session
  1454. **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1455. Updates a session of a specified chat assistant.
  1456. #### Request
  1457. - Method: PUT
  1458. - URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1459. - Headers:
  1460. - `'content-Type: application/json'`
  1461. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1462. - Body:
  1463. - `"name`: `string`
  1464. - `"user_id`: `string` (optional)
  1465. ##### Request example
  1466. ```bash
  1467. curl --request PUT \
  1468. --url http://{address}/api/v1/chats/{chat_id}/sessions/{session_id} \
  1469. --header 'Content-Type: application/json' \
  1470. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1471. --data '
  1472. {
  1473. "name": "<REVISED_SESSION_NAME_HERE>"
  1474. }'
  1475. ```
  1476. ##### Request Parameter
  1477. - `chat_id`: (*Path parameter*)
  1478. The ID of the associated chat assistant.
  1479. - `session_id`: (*Path parameter*)
  1480. The ID of the session to update.
  1481. - `"name"`: (*Body Parameter*), `string`
  1482. The revised name of the session.
  1483. - `"user_id"`: (*Body parameter*), `string`
  1484. Optional user-defined ID.
  1485. #### Response
  1486. Success:
  1487. ```json
  1488. {
  1489. "code": 0
  1490. }
  1491. ```
  1492. Failure:
  1493. ```json
  1494. {
  1495. "code": 102,
  1496. "message": "Name cannot be empty."
  1497. }
  1498. ```
  1499. ---
  1500. ### List chat assistant's sessions
  1501. **GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
  1502. Lists sessions associated with a specified chat assistant.
  1503. #### Request
  1504. - Method: GET
  1505. - URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}&user_id={user_id}`
  1506. - Headers:
  1507. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1508. ##### Request example
  1509. ```bash
  1510. curl --request GET \
  1511. --url http://{address}/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id} \
  1512. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1513. ```
  1514. ##### Request Parameters
  1515. - `chat_id`: (*Path parameter*)
  1516. The ID of the associated chat assistant.
  1517. - `page`: (*Filter parameter*), `integer`
  1518. Specifies the page on which the sessions will be displayed. Defaults to `1`.
  1519. - `page_size`: (*Filter parameter*), `integer`
  1520. The number of sessions on each page. Defaults to `30`.
  1521. - `orderby`: (*Filter parameter*), `string`
  1522. The field by which sessions should be sorted. Available options:
  1523. - `create_time` (default)
  1524. - `update_time`
  1525. - `desc`: (*Filter parameter*), `boolean`
  1526. Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
  1527. - `name`: (*Filter parameter*) `string`
  1528. The name of the chat session to retrieve.
  1529. - `id`: (*Filter parameter*), `string`
  1530. The ID of the chat session to retrieve.
  1531. - `user_id`: (*Filter parameter*), `string`
  1532. The optional user-defined ID passed in when creating session.
  1533. #### Response
  1534. Success:
  1535. ```json
  1536. {
  1537. "code": 0,
  1538. "data": [
  1539. {
  1540. "chat": "2ca4b22e878011ef88fe0242ac120005",
  1541. "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1542. "create_time": 1728636403974,
  1543. "id": "578d541e87ad11ef96b90242ac120006",
  1544. "messages": [
  1545. {
  1546. "content": "Hi! I am your assistant,can I help you?",
  1547. "role": "assistant"
  1548. }
  1549. ],
  1550. "name": "new session",
  1551. "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1552. "update_time": 1728636403974
  1553. }
  1554. ]
  1555. }
  1556. ```
  1557. Failure:
  1558. ```json
  1559. {
  1560. "code": 102,
  1561. "message": "The session doesn't exist"
  1562. }
  1563. ```
  1564. ---
  1565. ### Delete chat assistant's sessions
  1566. **DELETE** `/api/v1/chats/{chat_id}/sessions`
  1567. Deletes sessions of a chat assistant by ID.
  1568. #### Request
  1569. - Method: DELETE
  1570. - URL: `/api/v1/chats/{chat_id}/sessions`
  1571. - Headers:
  1572. - `'content-Type: application/json'`
  1573. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1574. - Body:
  1575. - `"ids"`: `list[string]`
  1576. ##### Request example
  1577. ```bash
  1578. curl --request DELETE \
  1579. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1580. --header 'Content-Type: application/json' \
  1581. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1582. --data '
  1583. {
  1584. "ids": ["test_1", "test_2"]
  1585. }'
  1586. ```
  1587. ##### Request Parameters
  1588. - `chat_id`: (*Path parameter*)
  1589. The ID of the associated chat assistant.
  1590. - `"ids"`: (*Body Parameter*), `list[string]`
  1591. The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
  1592. #### Response
  1593. Success:
  1594. ```json
  1595. {
  1596. "code": 0
  1597. }
  1598. ```
  1599. Failure:
  1600. ```json
  1601. {
  1602. "code": 102,
  1603. "message": "The chat doesn't own the session"
  1604. }
  1605. ```
  1606. ---
  1607. ### Converse with chat assistant
  1608. **POST** `/api/v1/chats/{chat_id}/completions`
  1609. Asks a specified chat assistant a question to start an AI-powered conversation.
  1610. :::tip NOTE
  1611. - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
  1612. - In streaming mode, the last message is an empty message:
  1613. ```json
  1614. data:
  1615. {
  1616. "code": 0,
  1617. "data": true
  1618. }
  1619. ```
  1620. :::
  1621. #### Request
  1622. - Method: POST
  1623. - URL: `/api/v1/chats/{chat_id}/completions`
  1624. - Headers:
  1625. - `'content-Type: application/json'`
  1626. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1627. - Body:
  1628. - `"question"`: `string`
  1629. - `"stream"`: `boolean`
  1630. - `"session_id"`: `string` (optional)
  1631. - `"user_id`: `string` (optional)
  1632. ##### Request example
  1633. ```bash
  1634. curl --request POST \
  1635. --url http://{address}/api/v1/chats/{chat_id}/completions \
  1636. --header 'Content-Type: application/json' \
  1637. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1638. --data-binary '
  1639. {
  1640. }'
  1641. ```
  1642. ```bash
  1643. curl --request POST \
  1644. --url http://{address}/api/v1/chats/{chat_id}/completions \
  1645. --header 'Content-Type: application/json' \
  1646. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1647. --data-binary '
  1648. {
  1649. "question": "Who are you",
  1650. "stream": true,
  1651. "session_id":"9fa7691cb85c11ef9c5f0242ac120005"
  1652. }'
  1653. ```
  1654. ##### Request Parameters
  1655. - `chat_id`: (*Path parameter*)
  1656. The ID of the associated chat assistant.
  1657. - `"question"`: (*Body Parameter*), `string`, *Required*
  1658. The question to start an AI-powered conversation.
  1659. - `"stream"`: (*Body Parameter*), `boolean`
  1660. Indicates whether to output responses in a streaming way:
  1661. - `true`: Enable streaming (default).
  1662. - `false`: Disable streaming.
  1663. - `"session_id"`: (*Body Parameter*)
  1664. The ID of session. If it is not provided, a new session will be generated.
  1665. - `"user_id"`: (*Body parameter*), `string`
  1666. The optional user-defined ID. Valid *only* when no `session_id` is provided.
  1667. #### Response
  1668. Success without `session_id`:
  1669. ```json
  1670. data:{
  1671. "code": 0,
  1672. "message": "",
  1673. "data": {
  1674. "answer": "Hi! I'm your assistant, what can I do for you?",
  1675. "reference": {},
  1676. "audio_binary": null,
  1677. "id": null,
  1678. "session_id": "b01eed84b85611efa0e90242ac120005"
  1679. }
  1680. }
  1681. data:{
  1682. "code": 0,
  1683. "message": "",
  1684. "data": true
  1685. }
  1686. ```
  1687. Success with `session_id`:
  1688. ```json
  1689. data:{
  1690. "code": 0,
  1691. "data": {
  1692. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a",
  1693. "reference": {},
  1694. "audio_binary": null,
  1695. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1696. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1697. }
  1698. }
  1699. data:{
  1700. "code": 0,
  1701. "data": {
  1702. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and",
  1703. "reference": {},
  1704. "audio_binary": null,
  1705. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1706. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1707. }
  1708. }
  1709. data:{
  1710. "code": 0,
  1711. "data": {
  1712. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and any relevant chat history.",
  1713. "reference": {},
  1714. "audio_binary": null,
  1715. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1716. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1717. }
  1718. }
  1719. data:{
  1720. "code": 0,
  1721. "data": {
  1722. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base ##0$$. My responses are based on the information available in the knowledge base and any relevant chat history.",
  1723. "reference": {
  1724. "total": 1,
  1725. "chunks": [
  1726. {
  1727. "id": "faf26c791128f2d5e821f822671063bd",
  1728. "content": "xxxxxxxx",
  1729. "document_id": "dd58f58e888511ef89c90242ac120006",
  1730. "document_name": "1.txt",
  1731. "dataset_id": "8e83e57a884611ef9d760242ac120006",
  1732. "image_id": "",
  1733. "similarity": 0.7,
  1734. "vector_similarity": 0.0,
  1735. "term_similarity": 1.0,
  1736. "positions": [
  1737. ""
  1738. ]
  1739. }
  1740. ],
  1741. "doc_aggs": [
  1742. {
  1743. "doc_name": "1.txt",
  1744. "doc_id": "dd58f58e888511ef89c90242ac120006",
  1745. "count": 1
  1746. }
  1747. ]
  1748. },
  1749. "prompt": "xxxxxxxxxxx",
  1750. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1751. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1752. }
  1753. }
  1754. data:{
  1755. "code": 0,
  1756. "data": true
  1757. }
  1758. ```
  1759. Failure:
  1760. ```json
  1761. {
  1762. "code": 102,
  1763. "message": "Please input your question."
  1764. }
  1765. ```
  1766. ---
  1767. ### Create session with agent
  1768. **POST** `/api/v1/agents/{agent_id}/sessions`
  1769. Creates a session with an agent.
  1770. #### Request
  1771. - Method: POST
  1772. - URL: `/api/v1/agents/{agent_id}/sessions?user_id={user_id}`
  1773. - Headers:
  1774. - `'content-Type: application/json' or 'multipart/form-data'`
  1775. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1776. - Body:
  1777. - the required parameters:`str`
  1778. - other parameters:
  1779. The parameters in the begin component.
  1780. ##### Request example
  1781. If `begin` component in the agent doesn't have required parameters:
  1782. ```bash
  1783. curl --request POST \
  1784. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  1785. --header 'Content-Type: application/json' \
  1786. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1787. --data '{
  1788. }'
  1789. ```
  1790. If `begin` component in the agent has required parameters:
  1791. ```bash
  1792. curl --request POST \
  1793. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  1794. --header 'Content-Type: application/json' \
  1795. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1796. --data '{
  1797. "lang":"Japanese",
  1798. "file":"Who are you"
  1799. }'
  1800. ```
  1801. If `begin` component in the agent has required file parameters:
  1802. ```bash
  1803. curl --request POST \
  1804. --url http://{address}/api/v1/agents/{agent_id}/sessions?user_id={user_id} \
  1805. --header 'Content-Type: multipart/form-data' \
  1806. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1807. --form '<FILE_KEY>=@./test1.png'
  1808. ```
  1809. ##### Request parameters
  1810. - `agent_id`: (*Path parameter*)
  1811. The ID of the associated agent.
  1812. - `user_id`: (*Filter parameter*), string
  1813. The optional user-defined ID for parsing docs(especially images) when creating session while uploading files.
  1814. #### Response
  1815. Success:
  1816. ```json
  1817. {
  1818. "code": 0,
  1819. "data": {
  1820. "agent_id": "b4a39922b76611efaa1a0242ac120006",
  1821. "dsl": {
  1822. "answer": [],
  1823. "components": {
  1824. "Answer:GreenReadersDrum": {
  1825. "downstream": [],
  1826. "obj": {
  1827. "component_name": "Answer",
  1828. "inputs": [],
  1829. "output": null,
  1830. "params": {}
  1831. },
  1832. "upstream": []
  1833. },
  1834. "begin": {
  1835. "downstream": [],
  1836. "obj": {
  1837. "component_name": "Begin",
  1838. "inputs": [],
  1839. "output": {},
  1840. "params": {}
  1841. },
  1842. "upstream": []
  1843. }
  1844. },
  1845. "embed_id": "",
  1846. "graph": {
  1847. "edges": [],
  1848. "nodes": [
  1849. {
  1850. "data": {
  1851. "label": "Begin",
  1852. "name": "begin"
  1853. },
  1854. "dragging": false,
  1855. "height": 44,
  1856. "id": "begin",
  1857. "position": {
  1858. "x": 53.25688640427177,
  1859. "y": 198.37155679786412
  1860. },
  1861. "positionAbsolute": {
  1862. "x": 53.25688640427177,
  1863. "y": 198.37155679786412
  1864. },
  1865. "selected": false,
  1866. "sourcePosition": "left",
  1867. "targetPosition": "right",
  1868. "type": "beginNode",
  1869. "width": 200
  1870. },
  1871. {
  1872. "data": {
  1873. "form": {},
  1874. "label": "Answer",
  1875. "name": "dialog_0"
  1876. },
  1877. "dragging": false,
  1878. "height": 44,
  1879. "id": "Answer:GreenReadersDrum",
  1880. "position": {
  1881. "x": 360.43473114516974,
  1882. "y": 207.29298425089348
  1883. },
  1884. "positionAbsolute": {
  1885. "x": 360.43473114516974,
  1886. "y": 207.29298425089348
  1887. },
  1888. "selected": false,
  1889. "sourcePosition": "right",
  1890. "targetPosition": "left",
  1891. "type": "logicNode",
  1892. "width": 200
  1893. }
  1894. ]
  1895. },
  1896. "history": [],
  1897. "messages": [],
  1898. "path": [
  1899. [
  1900. "begin"
  1901. ],
  1902. []
  1903. ],
  1904. "reference": []
  1905. },
  1906. "id": "2581031eb7a311efb5200242ac120005",
  1907. "message": [
  1908. {
  1909. "content": "Hi! I'm your smart assistant. What can I do for you?",
  1910. "role": "assistant"
  1911. }
  1912. ],
  1913. "source": "agent",
  1914. "user_id": "69736c5e723611efb51b0242ac120007"
  1915. }
  1916. }
  1917. ```
  1918. Failure:
  1919. ```json
  1920. {
  1921. "code": 102,
  1922. "message": "Agent not found."
  1923. }
  1924. ```
  1925. ---
  1926. ### Converse with agent
  1927. **POST** `/api/v1/agents/{agent_id}/completions`
  1928. Asks a specified agent a question to start an AI-powered conversation.
  1929. :::tip NOTE
  1930. - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
  1931. - In streaming mode, the last message is an empty message:
  1932. ```json
  1933. data:
  1934. {
  1935. "code": 0,
  1936. "data": true
  1937. }
  1938. ```
  1939. :::
  1940. #### Request
  1941. - Method: POST
  1942. - URL: `/api/v1/agents/{agent_id}/completions`
  1943. - Headers:
  1944. - `'content-Type: application/json'`
  1945. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1946. - Body:
  1947. - `"question"`: `string`
  1948. - `"stream"`: `boolean`
  1949. - `"session_id"`: `string`
  1950. - `"user_id"`: `string`(optional)
  1951. - other parameters: `string`
  1952. ##### Request example
  1953. If the `begin` component doesn't have parameters, the following code will create a session.
  1954. ```bash
  1955. curl --request POST \
  1956. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1957. --header 'Content-Type: application/json' \
  1958. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1959. --data-binary '
  1960. {
  1961. }'
  1962. ```
  1963. If the `begin` component have parameters, the following code will create a session.
  1964. ```bash
  1965. curl --request POST \
  1966. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1967. --header 'Content-Type: application/json' \
  1968. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1969. --data-binary '
  1970. {
  1971. "lang":"English",
  1972. "file":"How is the weather tomorrow?"
  1973. }'
  1974. ```
  1975. The following code will execute the completion process
  1976. ```bash
  1977. curl --request POST \
  1978. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1979. --header 'Content-Type: application/json' \
  1980. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1981. --data-binary '
  1982. {
  1983. "question": "Hello",
  1984. "stream": true,
  1985. "session_id": "cb2f385cb86211efa36e0242ac120005"
  1986. }'
  1987. ```
  1988. ##### Request Parameters
  1989. - `agent_id`: (*Path parameter*), `string`
  1990. The ID of the associated agent.
  1991. - `"question"`: (*Body Parameter*), `string`, *Required*
  1992. The question to start an AI-powered conversation.
  1993. - `"stream"`: (*Body Parameter*), `boolean`
  1994. Indicates whether to output responses in a streaming way:
  1995. - `true`: Enable streaming (default).
  1996. - `false`: Disable streaming.
  1997. - `"session_id"`: (*Body Parameter*)
  1998. The ID of the session. If it is not provided, a new session will be generated.
  1999. - `"user_id"`: (*Body parameter*), `string`
  2000. The optional user-defined ID. Valid *only* when no `session_id` is provided.
  2001. - Other parameters: (*Body Parameter*)
  2002. The parameters in the begin component.
  2003. #### Response
  2004. success without `session_id` provided and with no parameters in the `begin` component:
  2005. ```json
  2006. data:{
  2007. "code": 0,
  2008. "message": "",
  2009. "data": {
  2010. "answer": "Hi! I'm your smart assistant. What can I do for you?",
  2011. "reference": {},
  2012. "id": "31e6091d-88d4-441b-ac65-eae1c055be7b",
  2013. "session_id": "2987ad3eb85f11efb2a70242ac120005"
  2014. }
  2015. }
  2016. data:{
  2017. "code": 0,
  2018. "message": "",
  2019. "data": true
  2020. }
  2021. ```
  2022. Success without `session_id` provided and with parameters in the `begin` component:
  2023. ```json
  2024. data:{
  2025. "code": 0,
  2026. "message": "",
  2027. "data": {
  2028. "session_id": "eacb36a0bdff11ef97120242ac120006",
  2029. "answer": "",
  2030. "reference": [],
  2031. "param": [
  2032. {
  2033. "key": "lang",
  2034. "name": "Target Language",
  2035. "optional": false,
  2036. "type": "line",
  2037. "value": "English"
  2038. },
  2039. {
  2040. "key": "file",
  2041. "name": "Files",
  2042. "optional": false,
  2043. "type": "file",
  2044. "value": "How is the weather tomorrow?"
  2045. },
  2046. {
  2047. "key": "hhyt",
  2048. "name": "hhty",
  2049. "optional": true,
  2050. "type": "line"
  2051. }
  2052. ]
  2053. }
  2054. }
  2055. data:
  2056. ```
  2057. Success with parameters in the `begin` component:
  2058. ```json
  2059. data:{
  2060. "code": 0,
  2061. "message": "",
  2062. "data": {
  2063. "answer": "How",
  2064. "reference": {},
  2065. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2066. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2067. }
  2068. }
  2069. data:{
  2070. "code": 0,
  2071. "message": "",
  2072. "data": {
  2073. "answer": "How is",
  2074. "reference": {},
  2075. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2076. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2077. }
  2078. }
  2079. data:{
  2080. "code": 0,
  2081. "message": "",
  2082. "data": {
  2083. "answer": "How is the",
  2084. "reference": {},
  2085. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2086. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2087. }
  2088. }
  2089. data:{
  2090. "code": 0,
  2091. "message": "",
  2092. "data": {
  2093. "answer": "How is the weather",
  2094. "reference": {},
  2095. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2096. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2097. }
  2098. }
  2099. data:{
  2100. "code": 0,
  2101. "message": "",
  2102. "data": {
  2103. "answer": "How is the weather tomorrow",
  2104. "reference": {},
  2105. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2106. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2107. }
  2108. }
  2109. data:{
  2110. "code": 0,
  2111. "message": "",
  2112. "data": {
  2113. "answer": "How is the weather tomorrow?",
  2114. "reference": {},
  2115. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2116. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2117. }
  2118. }
  2119. data:{
  2120. "code": 0,
  2121. "message": "",
  2122. "data": {
  2123. "answer": "How is the weather tomorrow?",
  2124. "reference": {},
  2125. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2126. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2127. }
  2128. }
  2129. data:{
  2130. "code": 0,
  2131. "message": "",
  2132. "data": true
  2133. }
  2134. ```
  2135. Failure:
  2136. ```json
  2137. {
  2138. "code": 102,
  2139. "message": "`question` is required."
  2140. }
  2141. ```
  2142. ---
  2143. ### List agent sessions
  2144. **GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}&user_id={user_id}`
  2145. Lists sessions associated with a specified agent.
  2146. #### Request
  2147. - Method: GET
  2148. - URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
  2149. - Headers:
  2150. - `'Authorization: Bearer <YOUR_API_KEY>'`
  2151. ##### Request example
  2152. ```bash
  2153. curl --request GET \
  2154. --url http://{address}/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}&user_id={user_id} \
  2155. --header 'Authorization: Bearer <YOUR_API_KEY>'
  2156. ```
  2157. ##### Request Parameters
  2158. - `agent_id`: (*Path parameter*)
  2159. The ID of the associated agent.
  2160. - `page`: (*Filter parameter*), `integer`
  2161. Specifies the page on which the sessions will be displayed. Defaults to `1`.
  2162. - `page_size`: (*Filter parameter*), `integer`
  2163. The number of sessions on each page. Defaults to `30`.
  2164. - `orderby`: (*Filter parameter*), `string`
  2165. The field by which sessions should be sorted. Available options:
  2166. - `create_time` (default)
  2167. - `update_time`
  2168. - `desc`: (*Filter parameter*), `boolean`
  2169. Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
  2170. - `id`: (*Filter parameter*), `string`
  2171. The ID of the agent session to retrieve.
  2172. - `user_id`: (*Filter parameter*), `string`
  2173. The optional user-defined ID passed in when creating session.
  2174. #### Response
  2175. Success:
  2176. ```json
  2177. {
  2178. "code": 0,
  2179. "data": {
  2180. "agent_id": "e9e2b9c2b2f911ef801d0242ac120006",
  2181. "dsl": {
  2182. "answer": [],
  2183. "components": {
  2184. "Answer:OrangeTermsBurn": {
  2185. "downstream": [],
  2186. "obj": {
  2187. "component_name": "Answer",
  2188. "params": {}
  2189. },
  2190. "upstream": []
  2191. },
  2192. "Generate:SocialYearsRemain": {
  2193. "downstream": [],
  2194. "obj": {
  2195. "component_name": "Generate",
  2196. "params": {
  2197. "cite": true,
  2198. "frequency_penalty": 0.7,
  2199. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  2200. "max_tokens": 256,
  2201. "message_history_window_size": 12,
  2202. "parameters": [],
  2203. "presence_penalty": 0.4,
  2204. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  2205. "temperature": 0.1,
  2206. "top_p": 0.3
  2207. }
  2208. },
  2209. "upstream": []
  2210. },
  2211. "begin": {
  2212. "downstream": [],
  2213. "obj": {
  2214. "component_name": "Begin",
  2215. "params": {}
  2216. },
  2217. "upstream": []
  2218. }
  2219. },
  2220. "graph": {
  2221. "edges": [],
  2222. "nodes": [
  2223. {
  2224. "data": {
  2225. "label": "Begin",
  2226. "name": "begin"
  2227. },
  2228. "height": 44,
  2229. "id": "begin",
  2230. "position": {
  2231. "x": 50,
  2232. "y": 200
  2233. },
  2234. "sourcePosition": "left",
  2235. "targetPosition": "right",
  2236. "type": "beginNode",
  2237. "width": 200
  2238. },
  2239. {
  2240. "data": {
  2241. "form": {
  2242. "cite": true,
  2243. "frequencyPenaltyEnabled": true,
  2244. "frequency_penalty": 0.7,
  2245. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  2246. "maxTokensEnabled": true,
  2247. "max_tokens": 256,
  2248. "message_history_window_size": 12,
  2249. "parameters": [],
  2250. "presencePenaltyEnabled": true,
  2251. "presence_penalty": 0.4,
  2252. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  2253. "temperature": 0.1,
  2254. "temperatureEnabled": true,
  2255. "topPEnabled": true,
  2256. "top_p": 0.3
  2257. },
  2258. "label": "Generate",
  2259. "name": "Generate Answer_0"
  2260. },
  2261. "dragging": false,
  2262. "height": 105,
  2263. "id": "Generate:SocialYearsRemain",
  2264. "position": {
  2265. "x": 561.3457829707513,
  2266. "y": 178.7211182312641
  2267. },
  2268. "positionAbsolute": {
  2269. "x": 561.3457829707513,
  2270. "y": 178.7211182312641
  2271. },
  2272. "selected": true,
  2273. "sourcePosition": "right",
  2274. "targetPosition": "left",
  2275. "type": "generateNode",
  2276. "width": 200
  2277. },
  2278. {
  2279. "data": {
  2280. "form": {},
  2281. "label": "Answer",
  2282. "name": "Dialogue_0"
  2283. },
  2284. "height": 44,
  2285. "id": "Answer:OrangeTermsBurn",
  2286. "position": {
  2287. "x": 317.2368194777658,
  2288. "y": 218.30635555445093
  2289. },
  2290. "sourcePosition": "right",
  2291. "targetPosition": "left",
  2292. "type": "logicNode",
  2293. "width": 200
  2294. }
  2295. ]
  2296. },
  2297. "history": [],
  2298. "messages": [],
  2299. "path": [],
  2300. "reference": []
  2301. },
  2302. "id": "792dde22b2fa11ef97550242ac120006",
  2303. "message": [
  2304. {
  2305. "content": "Hi! I'm your smart assistant. What can I do for you?",
  2306. "role": "assistant"
  2307. }
  2308. ],
  2309. "source": "agent",
  2310. "user_id": ""
  2311. }
  2312. }
  2313. ```
  2314. Failure:
  2315. ```json
  2316. {
  2317. "code": 102,
  2318. "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
  2319. }
  2320. ```
  2321. ---
  2322. ## AGENT MANAGEMENT
  2323. ---
  2324. ### List agents
  2325. **GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
  2326. Lists agents.
  2327. #### Request
  2328. - Method: GET
  2329. - URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
  2330. - Headers:
  2331. - `'Authorization: Bearer <YOUR_API_KEY>'`
  2332. ##### Request example
  2333. ```bash
  2334. curl --request GET \
  2335. --url http://{address}/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} \
  2336. --header 'Authorization: Bearer <YOUR_API_KEY>'
  2337. ```
  2338. ##### Request parameters
  2339. - `page`: (*Filter parameter*), `integer`
  2340. Specifies the page on which the agents will be displayed. Defaults to `1`.
  2341. - `page_size`: (*Filter parameter*), `integer`
  2342. The number of agents on each page. Defaults to `30`.
  2343. - `orderby`: (*Filter parameter*), `string`
  2344. The attribute by which the results are sorted. Available options:
  2345. - `create_time` (default)
  2346. - `update_time`
  2347. - `desc`: (*Filter parameter*), `boolean`
  2348. Indicates whether the retrieved agents should be sorted in descending order. Defaults to `true`.
  2349. - `id`: (*Filter parameter*), `string`
  2350. The ID of the agent to retrieve.
  2351. - `name`: (*Filter parameter*), `string`
  2352. The name of the agent to retrieve.
  2353. #### Response
  2354. Success:
  2355. ```json
  2356. {
  2357. "code": 0,
  2358. "data": [
  2359. {
  2360. "avatar": null,
  2361. "canvas_type": null,
  2362. "create_date": "Thu, 05 Dec 2024 19:10:36 GMT",
  2363. "create_time": 1733397036424,
  2364. "description": null,
  2365. "dsl": {
  2366. "answer": [],
  2367. "components": {
  2368. "begin": {
  2369. "downstream": [],
  2370. "obj": {
  2371. "component_name": "Begin",
  2372. "params": {}
  2373. },
  2374. "upstream": []
  2375. }
  2376. },
  2377. "graph": {
  2378. "edges": [],
  2379. "nodes": [
  2380. {
  2381. "data": {
  2382. "label": "Begin",
  2383. "name": "begin"
  2384. },
  2385. "height": 44,
  2386. "id": "begin",
  2387. "position": {
  2388. "x": 50,
  2389. "y": 200
  2390. },
  2391. "sourcePosition": "left",
  2392. "targetPosition": "right",
  2393. "type": "beginNode",
  2394. "width": 200
  2395. }
  2396. ]
  2397. },
  2398. "history": [],
  2399. "messages": [],
  2400. "path": [],
  2401. "reference": []
  2402. },
  2403. "id": "8d9ca0e2b2f911ef9ca20242ac120006",
  2404. "title": "123465",
  2405. "update_date": "Thu, 05 Dec 2024 19:10:56 GMT",
  2406. "update_time": 1733397056801,
  2407. "user_id": "69736c5e723611efb51b0242ac120007"
  2408. }
  2409. ]
  2410. }
  2411. ```
  2412. Failure:
  2413. ```json
  2414. {
  2415. "code": 102,
  2416. "message": "The agent doesn't exist."
  2417. }
  2418. ```
  2419. ---