選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

http_api_reference.md 80KB

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