您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

http_api_reference.md 95KB

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