You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101
  1. # DRAFT! HTTP API Reference
  2. **THE API REFERENCES BELOW ARE STILL UNDER DEVELOPMENT.**
  3. ---
  4. :::tip API GROUPING
  5. Dataset Management
  6. :::
  7. ---
  8. ## Create dataset
  9. **POST** `/api/v1/datasets`
  10. Creates a dataset.
  11. ### Request
  12. - Method: POST
  13. - URL: `/api/v1/datasets`
  14. - Headers:
  15. - `'content-Type: application/json'`
  16. - `'Authorization: Bearer {YOUR_API_KEY}'`
  17. - Body:
  18. - `"name"`: `string`
  19. - `"avatar"`: `string`
  20. - `"description"`: `string`
  21. - `"language"`: `string`
  22. - `"embedding_model"`: `string`
  23. - `"permission"`: `string`
  24. - `"chunk_method"`: `string`
  25. - `"parser_config"`: `object`
  26. #### Request example
  27. ```bash
  28. curl --request POST \
  29. --url http://{address}/api/v1/datasets \
  30. --header 'Content-Type: application/json' \
  31. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  32. --data '{
  33. "name": "test_1"
  34. }'
  35. ```
  36. #### Request parameters
  37. - `"name"`: (*Body parameter*), `string`, *Required*
  38. The unique name of the dataset to create. It must adhere to the following requirements:
  39. - Permitted characters include:
  40. - English letters (a-z, A-Z)
  41. - Digits (0-9)
  42. - "_" (underscore)
  43. - Must begin with an English letter or underscore.
  44. - Maximum 65,535 characters.
  45. - Case-insensitive.
  46. - `"avatar"`: (*Body parameter*), `string`
  47. Base64 encoding of the avatar.
  48. - `"description"`: (*Body parameter*), `string`
  49. A brief description of the dataset to create.
  50. - `"language"`: (*Body parameter*), `string`
  51. The language setting of the dataset to create. Available options:
  52. - `"English"` (Default)
  53. - `"Chinese"`
  54. - `"embedding_model"`: (*Body parameter*), `string`
  55. The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
  56. - `"permission"`: (*Body parameter*), `string`
  57. Specifies who can access the dataset to create. You can set it only to `"me"` for now.
  58. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  59. The chunking method of the dataset to create. Available options:
  60. - `"naive"`: General (default)
  61. - `"manual"`: Manual
  62. - `"qa"`: Q&A
  63. - `"table"`: Table
  64. - `"paper"`: Paper
  65. - `"book"`: Book
  66. - `"laws"`: Laws
  67. - `"presentation"`: Presentation
  68. - `"picture"`: Picture
  69. - `"one"`: One
  70. - `"knowledge_graph"`: Knowledge Graph
  71. - `"parser_config"`: (*Body parameter*), `object`
  72. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  73. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  74. - `"chunk_token_count"`: Defaults to `128`.
  75. - `"layout_recognize"`: Defaults to `true`.
  76. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  77. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  78. - `"task_page_size"`: Defaults to `12`. For PDF only.
  79. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  80. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  81. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  82. - If `"chunk_method"` is `"table"` or `"one"`, `"parser_config"` is an empty JSON object.
  83. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  84. - `"chunk_token_count"`: Defaults to `128`.
  85. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  86. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  87. ### Response
  88. Success:
  89. ```json
  90. {
  91. "code": 0,
  92. "data": {
  93. "avatar": null,
  94. "chunk_count": 0,
  95. "chunk_method": "naive",
  96. "create_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  97. "create_time": 1729761247434,
  98. "created_by": "69736c5e723611efb51b0242ac120007",
  99. "description": null,
  100. "document_count": 0,
  101. "embedding_model": "BAAI/bge-large-zh-v1.5",
  102. "id": "527fa74891e811ef9c650242ac120006",
  103. "language": "English",
  104. "name": "test_1",
  105. "parser_config": {
  106. "chunk_token_num": 128,
  107. "delimiter": "\\n!?;。;!?",
  108. "html4excel": false,
  109. "layout_recognize": true,
  110. "raptor": {
  111. "user_raptor": false
  112. }
  113. },
  114. "permission": "me",
  115. "similarity_threshold": 0.2,
  116. "status": "1",
  117. "tenant_id": "69736c5e723611efb51b0242ac120007",
  118. "token_num": 0,
  119. "update_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  120. "update_time": 1729761247434,
  121. "vector_similarity_weight": 0.3
  122. }
  123. }
  124. ```
  125. Failure:
  126. ```json
  127. {
  128. "code": 102,
  129. "message": "Duplicated knowledgebase name in creating dataset."
  130. }
  131. ```
  132. ---
  133. ## Delete datasets
  134. **DELETE** `/api/v1/datasets`
  135. Deletes datasets by ID.
  136. ### Request
  137. - Method: DELETE
  138. - URL: `/api/v1/datasets`
  139. - Headers:
  140. - `'content-Type: application/json'`
  141. - `'Authorization: Bearer {YOUR_API_KEY}'`
  142. - Body:
  143. - `"ids"`: `list[string]`
  144. #### Request example
  145. ```bash
  146. curl --request DELETE \
  147. --url http://{address}/api/v1/datasets \
  148. --header 'Content-Type: application/json' \
  149. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  150. --data '{"ids": ["test_1", "test_2"]}'
  151. ```
  152. #### Request parameters
  153. - `"ids"`: (*Body parameter*), `list[string]`
  154. The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
  155. ### Response
  156. Success:
  157. ```json
  158. {
  159. "code": 0
  160. }
  161. ```
  162. Failure:
  163. ```json
  164. {
  165. "code": 102,
  166. "message": "You don't own the dataset."
  167. }
  168. ```
  169. ---
  170. ## Update dataset
  171. **PUT** `/api/v1/datasets/{dataset_id}`
  172. Updates configurations for a specified dataset.
  173. ### Request
  174. - Method: PUT
  175. - URL: `/api/v1/datasets/{dataset_id}`
  176. - Headers:
  177. - `'content-Type: application/json'`
  178. - `'Authorization: Bearer {YOUR_API_KEY}'`
  179. - Body:
  180. - `"name"`: `string`
  181. - `"embedding_model"`: `string`
  182. - `"chunk_method"`: `enum<string>`
  183. #### Request example
  184. ```bash
  185. curl --request PUT \
  186. --url http://{address}/api/v1/datasets/{dataset_id} \
  187. --header 'Content-Type: application/json' \
  188. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  189. --data '
  190. {
  191. "name": "updated_dataset",
  192. }'
  193. ```
  194. #### Request parameters
  195. - `dataset_id`: (*Path parameter*)
  196. The ID of the dataset to update.
  197. - `"name"`: (*Body parameter*), `string`
  198. The revised name of the dataset.
  199. - `"embedding_model"`: (*Body parameter*), `string`
  200. The updated embedding model name.
  201. - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
  202. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  203. The chunking method for the dataset. Available options:
  204. - `"naive"`: General
  205. - `"manual`: Manual
  206. - `"qa"`: Q&A
  207. - `"table"`: Table
  208. - `"paper"`: Paper
  209. - `"book"`: Book
  210. - `"laws"`: Laws
  211. - `"presentation"`: Presentation
  212. - `"picture"`: Picture
  213. - `"one"`:One
  214. - `"knowledge_graph"`: Knowledge Graph
  215. ### Response
  216. Success:
  217. ```json
  218. {
  219. "code": 0
  220. }
  221. ```
  222. Failure:
  223. ```json
  224. {
  225. "code": 102,
  226. "message": "Can't change tenant_id."
  227. }
  228. ```
  229. ---
  230. ## List datasets
  231. **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  232. Lists datasets.
  233. ### Request
  234. - Method: GET
  235. - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  236. - Headers:
  237. - `'Authorization: Bearer {YOUR_API_KEY}'`
  238. #### Request example
  239. ```bash
  240. curl --request GET \
  241. --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  242. --header 'Authorization: Bearer {YOUR_API_KEY}'
  243. ```
  244. #### Request parameters
  245. - `page`: (*Filter parameter*)
  246. Specifies the page on which the datasets will be displayed. Defaults to `1`.
  247. - `page_size`: (*Filter parameter*)
  248. The number of datasets on each page. Defaults to `1024`.
  249. - `orderby`: (*Filter parameter*)
  250. The field by which datasets should be sorted. Available options:
  251. - `create_time` (default)
  252. - `update_time`
  253. - `desc`: (*Filter parameter*)
  254. Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
  255. - `name`: (*Filter parameter*)
  256. The name of the dataset to retrieve.
  257. - `id`: (*Filter parameter*)
  258. The ID of the dataset to retrieve.
  259. ### Response
  260. Success:
  261. ```json
  262. {
  263. "code": 0,
  264. "data": [
  265. {
  266. "avatar": "",
  267. "chunk_count": 59,
  268. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  269. "create_time": 1726276357324,
  270. "created_by": "69736c5e723611efb51b0242ac120007",
  271. "description": null,
  272. "document_count": 1,
  273. "embedding_model": "BAAI/bge-large-zh-v1.5",
  274. "id": "6e211ee0723611efa10a0242ac120007",
  275. "language": "English",
  276. "name": "mysql",
  277. "chunk_method": "knowledge_graph",
  278. "parser_config": {
  279. "chunk_token_num": 8192,
  280. "delimiter": "\\n!?;。;!?",
  281. "entity_types": [
  282. "organization",
  283. "person",
  284. "location",
  285. "event",
  286. "time"
  287. ]
  288. },
  289. "permission": "me",
  290. "similarity_threshold": 0.2,
  291. "status": "1",
  292. "tenant_id": "69736c5e723611efb51b0242ac120007",
  293. "token_num": 12744,
  294. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  295. "update_time": 1728533243536,
  296. "vector_similarity_weight": 0.3
  297. }
  298. ]
  299. }
  300. ```
  301. Failure:
  302. ```json
  303. {
  304. "code": 102,
  305. "message": "The dataset doesn't exist"
  306. }
  307. ```
  308. ---
  309. :::tip API GROUPING
  310. File Management within Dataset
  311. :::
  312. ---
  313. ## Upload documents
  314. **POST** `/api/v1/datasets/{dataset_id}/documents`
  315. Uploads documents to a specified dataset.
  316. ### Request
  317. - Method: POST
  318. - URL: `/api/v1/datasets/{dataset_id}/documents`
  319. - Headers:
  320. - `'Content-Type: multipart/form-data'`
  321. - `'Authorization: Bearer {YOUR_API_KEY}'`
  322. - Form:
  323. - `'file=@{FILE_PATH}'`
  324. #### Request example
  325. ```bash
  326. curl --request POST \
  327. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  328. --header 'Content-Type: multipart/form-data' \
  329. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  330. --form 'file=@./test1.txt' \
  331. --form 'file=@./test2.pdf'
  332. ```
  333. #### Request parameters
  334. - `dataset_id`: (*Path parameter*)
  335. The ID of the dataset to which the documents will be uploaded.
  336. - `'file'`: (*Body parameter*)
  337. A document to upload.
  338. ### Response
  339. Success:
  340. ```json
  341. {
  342. "code": 0,
  343. "data": [
  344. {
  345. "chunk_method": "naive",
  346. "created_by": "69736c5e723611efb51b0242ac120007",
  347. "dataset_id": "527fa74891e811ef9c650242ac120006",
  348. "id": "b330ec2e91ec11efbc510242ac120004",
  349. "location": "1.txt",
  350. "name": "1.txt",
  351. "parser_config": {
  352. "chunk_token_num": 128,
  353. "delimiter": "\\n!?;。;!?",
  354. "html4excel": false,
  355. "layout_recognize": true,
  356. "raptor": {
  357. "user_raptor": false
  358. }
  359. },
  360. "run": "UNSTART",
  361. "size": 17966,
  362. "thumbnail": "",
  363. "type": "doc"
  364. }
  365. ]
  366. }
  367. ```
  368. Failure:
  369. ```json
  370. {
  371. "code": 101,
  372. "message": "No file part!"
  373. }
  374. ```
  375. ---
  376. ## Update document
  377. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  378. Updates configurations for a specified document.
  379. ### Request
  380. - Method: PUT
  381. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  382. - Headers:
  383. - `'content-Type: application/json'`
  384. - `'Authorization: Bearer {YOUR_API_KEY}'`
  385. - Body:
  386. - `"name"`:`string`
  387. - `"chunk_method"`:`string`
  388. - `"parser_config"`:`object`
  389. #### Request example
  390. ```bash
  391. curl --request PUT \
  392. --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
  393. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  394. --header 'Content-Type: application/json' \
  395. --data '
  396. {
  397. "name": "manual.txt",
  398. "chunk_method": "manual",
  399. "parser_config": {"chunk_token_count": 128}
  400. }'
  401. ```
  402. #### Request parameters
  403. - `dataset_id`: (*Path parameter*)
  404. The ID of the associated dataset.
  405. - `document_id`: (*Path parameter*)
  406. The ID of the document to update.
  407. - `"name"`: (*Body parameter*), `string`
  408. - `"chunk_method"`: (*Body parameter*), `string`
  409. The parsing method to apply to the document:
  410. - `"naive"`: General
  411. - `"manual`: Manual
  412. - `"qa"`: Q&A
  413. - `"table"`: Table
  414. - `"paper"`: Paper
  415. - `"book"`: Book
  416. - `"laws"`: Laws
  417. - `"presentation"`: Presentation
  418. - `"picture"`: Picture
  419. - `"one"`: One
  420. - `"knowledge_graph"`: Knowledge Graph
  421. - `"parser_config"`: (*Body parameter*), `object`
  422. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  423. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  424. - `"chunk_token_count"`: Defaults to `128`.
  425. - `"layout_recognize"`: Defaults to `true`.
  426. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  427. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  428. - `"task_page_size"`: Defaults to `12`. For PDF only.
  429. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  430. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  431. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  432. - If `"chunk_method"` is `"table"` or `"one"`, `"parser_config"` is an empty JSON object.
  433. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  434. - `"chunk_token_count"`: Defaults to `128`.
  435. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  436. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  437. ### Response
  438. Success:
  439. ```json
  440. {
  441. "code": 0
  442. }
  443. ```
  444. Failure:
  445. ```json
  446. {
  447. "code": 102,
  448. "message": "The dataset does not have the document."
  449. }
  450. ```
  451. ---
  452. ## Download document
  453. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  454. Downloads a document from a specified dataset.
  455. ### Request
  456. - Method: GET
  457. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  458. - Headers:
  459. - `'Authorization: Bearer {YOUR_API_KEY}'`
  460. - Output:
  461. - `'{PATH_TO_THE_FILE}'`
  462. #### Request example
  463. ```bash
  464. curl --request GET \
  465. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
  466. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  467. --output ./ragflow.txt
  468. ```
  469. #### Request parameters
  470. - `dataset_id`: (*Path parameter*)
  471. The associated dataset ID.
  472. - `documents_id`: (*Path parameter*)
  473. The ID of the document to download.
  474. ### Response
  475. Success:
  476. ```text
  477. This is a test to verify the file download feature.
  478. ```
  479. Failure:
  480. ```json
  481. {
  482. "code": 102,
  483. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  484. }
  485. ```
  486. ---
  487. ## List documents
  488. **GET** `/api/v1/datasets/{dataset_id}/documents?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}`
  489. Lists documents in a specified dataset.
  490. ### Request
  491. - Method: GET
  492. - URL: `/api/v1/datasets/{dataset_id}/documents?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name}`
  493. - Headers:
  494. - `'content-Type: application/json'`
  495. - `'Authorization: Bearer {YOUR_API_KEY}'`
  496. #### Request example
  497. ```bash
  498. curl --request GET \
  499. --url http://{address}/api/v1/datasets/{dataset_id}/documents?keywords={keywords}&offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&id={document_id} \
  500. --header 'Authorization: Bearer {YOUR_API_KEY}'
  501. ```
  502. #### Request parameters
  503. - `dataset_id`: (*Path parameter*)
  504. The associated dataset ID.
  505. - `keywords`: (*Filter parameter*), `string`
  506. The keywords used to match document titles.
  507. - `offset`: (*Filter parameter*), `integer`
  508. The starting index for the documents to retrieve. Typically used in conjunction with `limit`. Defaults to `1`.
  509. - `limit`: (*Filter parameter*), `integer`
  510. The maximum number of documents to retrieve. Defaults to `1024`.
  511. - `orderby`: (*Filter parameter*), `string`
  512. The field by which documents should be sorted. Available options:
  513. - `create_time` (default)
  514. - `update_time`
  515. - `desc`: (*Filter parameter*), `boolean`
  516. Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
  517. - `id`: (*Filter parameter*), `string`
  518. The ID of the document to retrieve.
  519. ### Response
  520. Success:
  521. ```json
  522. {
  523. "code": 0,
  524. "data": {
  525. "docs": [
  526. {
  527. "chunk_count": 0,
  528. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  529. "create_time": 1728897061948,
  530. "created_by": "69736c5e723611efb51b0242ac120007",
  531. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  532. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  533. "location": "Test_2.txt",
  534. "name": "Test_2.txt",
  535. "parser_config": {
  536. "chunk_token_count": 128,
  537. "delimiter": "\n!?。;!?",
  538. "layout_recognize": true,
  539. "task_page_size": 12
  540. },
  541. "parser_method": "naive",
  542. "process_begin_at": null,
  543. "process_duation": 0.0,
  544. "progress": 0.0,
  545. "progress_msg": "",
  546. "run": "0",
  547. "size": 7,
  548. "source_type": "local",
  549. "status": "1",
  550. "thumbnail": null,
  551. "token_count": 0,
  552. "type": "doc",
  553. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  554. "update_time": 1728897061948
  555. }
  556. ],
  557. "total": 1
  558. }
  559. }
  560. ```
  561. Failure:
  562. ```json
  563. {
  564. "code": 102,
  565. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  566. }
  567. ```
  568. ---
  569. ## Delete documents
  570. **DELETE** `/api/v1/datasets/{dataset_id}/documents`
  571. Deletes documents by ID.
  572. ### Request
  573. - Method: DELETE
  574. - URL: `/api/v1/datasets/{dataset_id}/documents`
  575. - Headers:
  576. - `'Content-Type: application/json'`
  577. - `'Authorization: Bearer {YOUR_API_KEY}'`
  578. - Body:
  579. - `"ids"`: `list[string]`
  580. #### Request example
  581. ```bash
  582. curl --request DELETE \
  583. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  584. --header 'Content-Type: application/json' \
  585. --header 'Authorization: {YOUR_API_KEY}' \
  586. --data '
  587. {
  588. "ids": ["id_1","id_2"]
  589. }'
  590. ```
  591. #### Request parameters
  592. - `dataset_id`: (*Path parameter*)
  593. The associated dataset ID.
  594. - `"ids"`: (*Body parameter*), `list[string]`
  595. The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
  596. ### Response
  597. Success:
  598. ```json
  599. {
  600. "code": 0
  601. }.
  602. ```
  603. Failure:
  604. ```json
  605. {
  606. "code": 102,
  607. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  608. }
  609. ```
  610. ---
  611. ## Parse documents
  612. **POST** `/api/v1/datasets/{dataset_id}/chunks`
  613. Parses documents in a specified dataset.
  614. ### Request
  615. - Method: POST
  616. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  617. - Headers:
  618. - `'content-Type: application/json'`
  619. - 'Authorization: Bearer {YOUR_API_KEY}'
  620. - Body:
  621. - `"document_ids"`: `list[string]`
  622. #### Request example
  623. ```bash
  624. curl --request POST \
  625. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  626. --header 'Content-Type: application/json' \
  627. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  628. --data '
  629. {
  630. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  631. }'
  632. ```
  633. #### Request parameters
  634. - `dataset_id`: (*Path parameter*)
  635. The dataset ID.
  636. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  637. The IDs of the documents to parse.
  638. ### Response
  639. Success:
  640. ```json
  641. {
  642. "code": 0
  643. }
  644. ```
  645. Failure:
  646. ```json
  647. {
  648. "code": 102,
  649. "message": "`document_ids` is required"
  650. }
  651. ```
  652. ---
  653. ## Stop parsing documents
  654. **DELETE** `/api/v1/datasets/{dataset_id}/chunks`
  655. Stops parsing specified documents.
  656. ### Request
  657. - Method: DELETE
  658. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  659. - Headers:
  660. - `'content-Type: application/json'`
  661. - `'Authorization: Bearer {YOUR_API_KEY}'`
  662. - Body:
  663. - `"document_ids"`: `list[string]`
  664. #### Request example
  665. ```bash
  666. curl --request DELETE \
  667. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  668. --header 'Content-Type: application/json' \
  669. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  670. --data '
  671. {
  672. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  673. }'
  674. ```
  675. #### Request parameters
  676. - `dataset_id`: (*Path parameter*)
  677. The associated dataset ID.
  678. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  679. The IDs of the documents for which the parsing should be stopped.
  680. ### Response
  681. Success:
  682. ```json
  683. {
  684. "code": 0
  685. }
  686. ```
  687. Failure:
  688. ```json
  689. {
  690. "code": 102,
  691. "message": "`document_ids` is required"
  692. }
  693. ```
  694. ---
  695. ## Add chunks
  696. **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  697. Adds a chunk to a specified document in a specified dataset.
  698. ### Request
  699. - Method: POST
  700. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  701. - Headers:
  702. - `'content-Type: application/json'`
  703. - `'Authorization: Bearer {YOUR_API_KEY}'`
  704. - Body:
  705. - `"content"`: `string`
  706. - `"important_keywords"`: `list[string]`
  707. #### Request example
  708. ```bash
  709. curl --request POST \
  710. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  711. --header 'Content-Type: application/json' \
  712. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  713. --data '
  714. {
  715. "content": "<SOME_CHUNK_CONTENT_HERE>"
  716. }'
  717. ```
  718. #### Request parameters
  719. - `dataset_id`: (*Path parameter*)
  720. The associated dataset ID.
  721. - `document_ids`: (*Path parameter*)
  722. The associated document ID.
  723. - `"content"`: (*Body parameter*), `string`, *Required*
  724. The text content of the chunk.
  725. - `"important_keywords`(*Body parameter*), `list[string]`
  726. The key terms or phrases to tag with the chunk.
  727. ### Response
  728. Success:
  729. ```json
  730. {
  731. "code": 0,
  732. "data": {
  733. "chunk": {
  734. "content": "ragflow content",
  735. "create_time": "2024-10-16 08:05:04",
  736. "create_timestamp": 1729065904.581025,
  737. "dataset_id": [
  738. "c7ee74067a2c11efb21c0242ac120006"
  739. ],
  740. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  741. "id": "d78435d142bd5cf6704da62c778795c5",
  742. "important_keywords": []
  743. }
  744. }
  745. }
  746. ```
  747. Failure:
  748. ```json
  749. {
  750. "code": 102,
  751. "message": "`content` is required"
  752. }
  753. ```
  754. ---
  755. ## List chunks
  756. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={id}`
  757. Lists chunks in a specified document.
  758. ### Request
  759. - Method: GET
  760. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id}`
  761. - Headers:
  762. - `'Authorization: Bearer {YOUR_API_KEY}'`
  763. #### Request example
  764. ```bash
  765. curl --request GET \
  766. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id} \
  767. --header 'Authorization: Bearer {YOUR_API_KEY}'
  768. ```
  769. #### Request parameters
  770. - `dataset_id`: (*Path parameter*)
  771. The associated dataset ID.
  772. - `document_ids`: (*Path parameter*)
  773. The associated document ID.
  774. - `keywords`(*Filter parameter*), `string`
  775. The keywords used to match chunk content.
  776. - `offset`(*Filter parameter*), `string`
  777. The starting index for the chunks to retrieve. Defaults to `1`.
  778. - `limit`(*Filter parameter*), `integer`
  779. The maximum number of chunks to retrieve. Default: `1024`
  780. - `id`(*Filter parameter*), `string`
  781. The ID of the chunk to retrieve.
  782. ### Response
  783. Success:
  784. ```json
  785. {
  786. "code": 0,
  787. "data": {
  788. "chunks": [
  789. {
  790. "available_int": 1,
  791. "content": "This is a test content.",
  792. "docnm_kwd": "1.txt",
  793. "document_id": "b330ec2e91ec11efbc510242ac120004",
  794. "id": "b48c170e90f70af998485c1065490726",
  795. "image_id": "",
  796. "important_keywords": "",
  797. "positions": [
  798. ""
  799. ]
  800. }
  801. ],
  802. "doc": {
  803. "chunk_count": 1,
  804. "chunk_method": "naive",
  805. "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
  806. "create_time": 1729763127646,
  807. "created_by": "69736c5e723611efb51b0242ac120007",
  808. "dataset_id": "527fa74891e811ef9c650242ac120006",
  809. "id": "b330ec2e91ec11efbc510242ac120004",
  810. "location": "1.txt",
  811. "name": "1.txt",
  812. "parser_config": {
  813. "chunk_token_num": 128,
  814. "delimiter": "\\n!?;。;!?",
  815. "html4excel": false,
  816. "layout_recognize": true,
  817. "raptor": {
  818. "user_raptor": false
  819. }
  820. },
  821. "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
  822. "process_duation": 0.54213,
  823. "progress": 0.0,
  824. "progress_msg": "Task dispatched...",
  825. "run": "2",
  826. "size": 17966,
  827. "source_type": "local",
  828. "status": "1",
  829. "thumbnail": "",
  830. "token_count": 8,
  831. "type": "doc",
  832. "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
  833. "update_time": 1729767795721
  834. },
  835. "total": 1
  836. }
  837. }
  838. ```
  839. Failure:
  840. ```json
  841. {
  842. "code": 102,
  843. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  844. }
  845. ```
  846. ---
  847. ## Delete chunks
  848. **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  849. Deletes chunks by ID.
  850. ### Request
  851. - Method: DELETE
  852. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  853. - Headers:
  854. - `'content-Type: application/json'`
  855. - `'Authorization: Bearer {YOUR_API_KEY}'`
  856. - Body:
  857. - `"chunk_ids"`: `list[string]`
  858. #### Request example
  859. ```bash
  860. curl --request DELETE \
  861. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  862. --header 'Content-Type: application/json' \
  863. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  864. --data '
  865. {
  866. "chunk_ids": ["test_1", "test_2"]
  867. }'
  868. ```
  869. #### Request parameters
  870. - `dataset_id`: (*Path parameter*)
  871. The associated dataset ID.
  872. - `document_ids`: (*Path parameter*)
  873. The associated document ID.
  874. - `"chunk_ids"`: (*Body parameter*), `list[string]`
  875. The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
  876. ### Response
  877. Success:
  878. ```json
  879. {
  880. "code": 0
  881. }
  882. ```
  883. Failure:
  884. ```json
  885. {
  886. "code": 102,
  887. "message": "`chunk_ids` is required"
  888. }
  889. ```
  890. ---
  891. ## Update chunk
  892. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  893. Updates content or configurations for a specified chunk.
  894. ### Request
  895. - Method: PUT
  896. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  897. - Headers:
  898. - `'content-Type: application/json'`
  899. - `'Authorization: Bearer {YOUR_API_KEY}'`
  900. - Body:
  901. - `"content"`: `string`
  902. - `"important_keywords"`: `string`
  903. - `"available"`: `integer`
  904. #### Request example
  905. ```bash
  906. curl --request PUT \
  907. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
  908. --header 'Content-Type: application/json' \
  909. --header 'Authorization: {YOUR_API_KEY}' \
  910. --data '
  911. {
  912. "content": "ragflow123",
  913. "important_keywords": [],
  914. }'
  915. ```
  916. #### Request parameters
  917. - `dataset_id`: (*Path parameter*)
  918. The associated dataset ID.
  919. - `document_ids`: (*Path parameter*)
  920. The associated document ID.
  921. - `chunk_id`: (*Path parameter*)
  922. The ID of the chunk to update.
  923. - `"content"`: (*Body parameter*), `string`
  924. The text content of the chunk.
  925. - `"important_keywords"`: (*Body parameter*), `list[string]`
  926. A list of key terms or phrases to tag with the chunk.
  927. - `"available"`: (*Body parameter*) `boolean`
  928. The chunk's availability status in the dataset. Value options:
  929. - `true`: Available (default)
  930. - `false`: Unavailable
  931. ### Response
  932. Success:
  933. ```json
  934. {
  935. "code": 0
  936. }
  937. ```
  938. Failure:
  939. ```json
  940. {
  941. "code": 102,
  942. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  943. }
  944. ```
  945. ---
  946. ## Retrieve chunks
  947. **POST** `/api/v1/retrieval`
  948. Retrieves chunks from specified datasets.
  949. ### Request
  950. - Method: POST
  951. - URL: `/api/v1/retrieval`
  952. - Headers:
  953. - `'content-Type: application/json'`
  954. - `'Authorization: Bearer {YOUR_API_KEY}'`
  955. - Body:
  956. - `"question"`: `string`
  957. - `"dataset_ids"`: `list[string]`
  958. - `"document_ids"`: `list[string]`
  959. - `"offset"`: `integer`
  960. - `"limit"`: `integer`
  961. - `"similarity_threshold"`: `float`
  962. - `"vector_similarity_weight"`: `float`
  963. - `"top_k"`: `integer`
  964. - `"rerank_id"`: `string`
  965. - `"keyword"`: `boolean`
  966. - `"highlight"`: `boolean`
  967. #### Request example
  968. ```bash
  969. curl --request POST \
  970. --url http://{address}/api/v1/retrieval \
  971. --header 'Content-Type: application/json' \
  972. --header 'Authorization: {YOUR_API_KEY}' \
  973. --data '
  974. {
  975. "question": "What is advantage of ragflow?",
  976. "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
  977. "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
  978. }'
  979. ```
  980. #### Request parameter
  981. - `"question"`: (*Body parameter*), `string`, *Required*
  982. The user query or query keywords.
  983. - `"dataset_ids"`: (*Body parameter*) `list[string]`
  984. The IDs of the datasets to search. If you do not set this argument, ensure that you set `"document_ids"`.
  985. - `"document_ids"`: (*Body parameter*), `list[string]`
  986. 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"`.
  987. - `"offset"`: (*Body parameter*), `integer`
  988. The starting index for the documents to retrieve. Defaults to `1`.
  989. - `"limit"`: (*Body parameter*)
  990. The maximum number of chunks to retrieve. Defaults to `1024`.
  991. - `"similarity_threshold"`: (*Body parameter*)
  992. The minimum similarity score. Defaults to `0.2`.
  993. - `"vector_similarity_weight"`: (*Body parameter*), `float`
  994. 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.
  995. - `"top_k"`: (*Body parameter*), `integer`
  996. The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
  997. - `"rerank_id"`: (*Body parameter*), `integer`
  998. The ID of the rerank model.
  999. - `"keyword"`: (*Body parameter*), `boolean`
  1000. Indicates whether to enable keyword-based matching:
  1001. - `true`: Enable keyword-based matching.
  1002. - `false`: Disable keyword-based matching (default).
  1003. - `"highlight"`: (*Body parameter*), `boolean`
  1004. Specifies whether to enable highlighting of matched terms in the results:
  1005. - `true`: Enable highlighting of matched terms.
  1006. - `false`: Disable highlighting of matched terms (default).
  1007. ### Response
  1008. Success:
  1009. ```json
  1010. {
  1011. "code": 0,
  1012. "data": {
  1013. "chunks": [
  1014. {
  1015. "content": "ragflow content",
  1016. "content_ltks": "ragflow content",
  1017. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  1018. "document_keyword": "1.txt",
  1019. "highlight": "<em>ragflow</em> content",
  1020. "id": "d78435d142bd5cf6704da62c778795c5",
  1021. "img_id": "",
  1022. "important_keywords": [
  1023. ""
  1024. ],
  1025. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1026. "positions": [
  1027. ""
  1028. ],
  1029. "similarity": 0.9669436601210759,
  1030. "term_similarity": 1.0,
  1031. "vector_similarity": 0.8898122004035864
  1032. }
  1033. ],
  1034. "doc_aggs": [
  1035. {
  1036. "count": 1,
  1037. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1038. "doc_name": "1.txt"
  1039. }
  1040. ],
  1041. "total": 1
  1042. }
  1043. }
  1044. ```
  1045. Failure:
  1046. ```json
  1047. {
  1048. "code": 102,
  1049. "message": "`datasets` is required."
  1050. }
  1051. ```
  1052. ---
  1053. :::tip API GROUPING
  1054. Chat Assistant Management
  1055. :::
  1056. ---
  1057. ## Create chat assistant
  1058. **POST** `/api/v1/chats`
  1059. Creates a chat assistant.
  1060. ### Request
  1061. - Method: POST
  1062. - URL: `/api/v1/chats`
  1063. - Headers:
  1064. - `'content-Type: application/json'`
  1065. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1066. - Body:
  1067. - `"name"`: `string`
  1068. - `"avatar"`: `string`
  1069. - `"dataset_ids"`: `list[string]`
  1070. - `"llm"`: `object`
  1071. - `"prompt"`: `object`
  1072. #### Request example
  1073. ```shell
  1074. curl --request POST \
  1075. --url http://{address}/api/v1/chats \
  1076. --header 'Content-Type: application/json' \
  1077. --header 'Authorization: Bearer {YOUR_API_KEY}'
  1078. --data '{
  1079. "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
  1080. "name":"new_chat_1"
  1081. }'
  1082. ```
  1083. #### Request parameters
  1084. - `"name"`: (*Body parameter*), `string`, *Required*
  1085. The name of the chat assistant.
  1086. - `"avatar"`: (*Body parameter*), `string`
  1087. Base64 encoding of the avatar.
  1088. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1089. The IDs of the associated datasets.
  1090. - `"llm"`: (*Body parameter*), `object`
  1091. 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:
  1092. - `"model_name"`, `string`
  1093. The chat model name. If not set, the user's default chat model will be used.
  1094. - `"temperature"`: `float`
  1095. 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`.
  1096. - `"top_p"`: `float`
  1097. 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`
  1098. - `"presence_penalty"`: `float`
  1099. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1100. - `"frequency penalty"`: `float`
  1101. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1102. - `"max_token"`: `integer`
  1103. The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
  1104. - `"prompt"`: (*Body parameter*), `object`
  1105. 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:
  1106. - `"similarity_threshold"`: `float` RAGFlow uses a hybrid of weighted keyword similarity and vector cosine similarity 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`.
  1107. - `"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`.
  1108. - `"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`.
  1109. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1110. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1111. - All the variables in 'System' should be curly bracketed.
  1112. - The default value is `[{"key": "knowledge", "optional": true}]`.
  1113. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1114. - `"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.
  1115. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1116. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1117. - `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset 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.
  1118. Here is the knowledge base:
  1119. {knowledge}
  1120. The above is the knowledge base.`
  1121. ### Response
  1122. Success:
  1123. ```json
  1124. {
  1125. "code": 0,
  1126. "data": {
  1127. "avatar": "",
  1128. "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1129. "create_time": 1729768709023,
  1130. "dataset_ids": [
  1131. "527fa74891e811ef9c650242ac120006"
  1132. ],
  1133. "description": "A helpful Assistant",
  1134. "do_refer": "1",
  1135. "id": "b1f2f15691f911ef81180242ac120003",
  1136. "language": "English",
  1137. "llm": {
  1138. "frequency_penalty": 0.7,
  1139. "max_tokens": 512,
  1140. "model_name": "qwen-plus@Tongyi-Qianwen",
  1141. "presence_penalty": 0.4,
  1142. "temperature": 0.1,
  1143. "top_p": 0.3
  1144. },
  1145. "name": "12234",
  1146. "prompt": {
  1147. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1148. "keywords_similarity_weight": 0.3,
  1149. "opener": "Hi! I'm your assistant, what can I do for you?",
  1150. "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 Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.",
  1151. "rerank_model": "",
  1152. "similarity_threshold": 0.2,
  1153. "top_n": 6,
  1154. "variables": [
  1155. {
  1156. "key": "knowledge",
  1157. "optional": false
  1158. }
  1159. ]
  1160. },
  1161. "prompt_type": "simple",
  1162. "status": "1",
  1163. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1164. "top_k": 1024,
  1165. "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1166. "update_time": 1729768709023
  1167. }
  1168. }
  1169. ```
  1170. Failure:
  1171. ```json
  1172. {
  1173. "code": 102,
  1174. "message": "Duplicated chat name in creating dataset."
  1175. }
  1176. ```
  1177. ---
  1178. ## Update chat assistant
  1179. **PUT** `/api/v1/chats/{chat_id}`
  1180. Updates configurations for a specified chat assistant.
  1181. ### Request
  1182. - Method: PUT
  1183. - URL: `/api/v1/chats/{chat_id}`
  1184. - Headers:
  1185. - `'content-Type: application/json'`
  1186. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1187. - Body:
  1188. - `"name"`: `string`
  1189. - `"avatar"`: `string`
  1190. - `"dataset_ids"`: `list[string]`
  1191. - `"llm"`: `object`
  1192. - `"prompt"`: `object`
  1193. #### Request example
  1194. ```bash
  1195. curl --request PUT \
  1196. --url http://{address}/api/v1/chats/{chat_id} \
  1197. --header 'Content-Type: application/json' \
  1198. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  1199. --data '
  1200. {
  1201. "name":"Test"
  1202. }'
  1203. ```
  1204. #### Parameters
  1205. - `chat_id`: (*Path parameter*)
  1206. The ID of the chat assistant to update.
  1207. - `"name"`: (*Body parameter*), `string`, *Required*
  1208. The revised name of the chat assistant.
  1209. - `"avatar"`: (*Body parameter*), `string`
  1210. Base64 encoding of the avatar.
  1211. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1212. The IDs of the associated datasets.
  1213. - `"llm"`: (*Body parameter*), `object`
  1214. 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:
  1215. - `"model_name"`, `string`
  1216. The chat model name. If not set, the user's default chat model will be used.
  1217. - `"temperature"`: `float`
  1218. 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`.
  1219. - `"top_p"`: `float`
  1220. 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`
  1221. - `"presence_penalty"`: `float`
  1222. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1223. - `"frequency penalty"`: `float`
  1224. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1225. - `"max_token"`: `integer`
  1226. The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
  1227. - `"prompt"`: (*Body parameter*), `object`
  1228. Instructions for the LLM to follow. A `prompt` object contains the following attributes:
  1229. - `"similarity_threshold"`: `float` RAGFlow uses a hybrid of weighted keyword similarity and vector cosine similarity 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`.
  1230. - `"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`.
  1231. - `"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`.
  1232. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1233. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1234. - All the variables in 'System' should be curly bracketed.
  1235. - The default value is `[{"key": "knowledge", "optional": true}]`
  1236. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1237. - `"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.
  1238. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1239. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1240. - `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset 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.
  1241. Here is the knowledge base:
  1242. {knowledge}
  1243. The above is the knowledge base.`
  1244. ### Response
  1245. Success:
  1246. ```json
  1247. {
  1248. "code": 0
  1249. }
  1250. ```
  1251. Failure:
  1252. ```json
  1253. {
  1254. "code": 102,
  1255. "message": "Duplicated chat name in updating dataset."
  1256. }
  1257. ```
  1258. ---
  1259. ## Delete chat assistants
  1260. **DELETE** `/api/v1/chats`
  1261. Deletes chat assistants by ID.
  1262. ### Request
  1263. - Method: DELETE
  1264. - URL: `/api/v1/chats`
  1265. - Headers:
  1266. - `'content-Type: application/json'`
  1267. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1268. - Body:
  1269. - `"ids"`: `list[string]`
  1270. #### Request example
  1271. ```bash
  1272. curl --request DELETE \
  1273. --url http://{address}/api/v1/chats \
  1274. --header 'Content-Type: application/json' \
  1275. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  1276. --data '
  1277. {
  1278. "ids": ["test_1", "test_2"]
  1279. }'
  1280. ```
  1281. #### Request parameters
  1282. - `"ids"`: (*Body parameter*), `list[string]`
  1283. The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
  1284. ### Response
  1285. Success:
  1286. ```json
  1287. {
  1288. "code": 0
  1289. }
  1290. ```
  1291. Failure:
  1292. ```json
  1293. {
  1294. "code": 102,
  1295. "message": "ids are required"
  1296. }
  1297. ```
  1298. ---
  1299. ## List chat assistants
  1300. **GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
  1301. Lists chat assistants.
  1302. ### Request
  1303. - Method: GET
  1304. - URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1305. - Headers:
  1306. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1307. #### Request example
  1308. ```bash
  1309. curl --request GET \
  1310. --url http://{address}/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1311. --header 'Authorization: Bearer {YOUR_API_KEY}'
  1312. ```
  1313. #### Request parameters
  1314. - `page`: (*Filter parameter*), `integer`
  1315. Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
  1316. - `page_size`: (*Filter parameter*), `integer`
  1317. The number of chat assistants on each page. Defaults to `1024`.
  1318. - `orderby`: (*Filter parameter*), `string`
  1319. The attribute by which the results are sorted. Available options:
  1320. - `create_time` (default)
  1321. - `update_time`
  1322. - `desc`: (*Filter parameter*), `boolean`
  1323. Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `true`.
  1324. - `id`: (*Filter parameter*), `string`
  1325. The ID of the chat assistant to retrieve.
  1326. - `name`: (*Filter parameter*), `string`
  1327. The name of the chat assistant to retrieve.
  1328. ### Response
  1329. Success:
  1330. ```json
  1331. {
  1332. "code": 0,
  1333. "data": [
  1334. {
  1335. "avatar": "",
  1336. "create_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1337. "create_time": 1729232406637,
  1338. "description": "A helpful Assistant",
  1339. "do_refer": "1",
  1340. "id": "04d0d8e28d1911efa3630242ac120006",
  1341. "dataset_ids": ["527fa74891e811ef9c650242ac120006"],
  1342. "language": "English",
  1343. "llm": {
  1344. "frequency_penalty": 0.7,
  1345. "max_tokens": 512,
  1346. "model_name": "qwen-plus@Tongyi-Qianwen",
  1347. "presence_penalty": 0.4,
  1348. "temperature": 0.1,
  1349. "top_p": 0.3
  1350. },
  1351. "name": "13243",
  1352. "prompt": {
  1353. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1354. "keywords_similarity_weight": 0.3,
  1355. "opener": "Hi! I'm your assistant, what can I do for you?",
  1356. "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 Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.",
  1357. "rerank_model": "",
  1358. "similarity_threshold": 0.2,
  1359. "top_n": 6,
  1360. "variables": [
  1361. {
  1362. "key": "knowledge",
  1363. "optional": false
  1364. }
  1365. ]
  1366. },
  1367. "prompt_type": "simple",
  1368. "status": "1",
  1369. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1370. "top_k": 1024,
  1371. "update_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1372. "update_time": 1729232406638
  1373. }
  1374. ]
  1375. }
  1376. ```
  1377. Failure:
  1378. ```json
  1379. {
  1380. "code": 102,
  1381. "message": "The chat doesn't exist"
  1382. }
  1383. ```
  1384. ## Create session
  1385. **POST** `/api/v1/chats/{chat_id}/sessions`
  1386. Creates a chat session.
  1387. ### Request
  1388. - Method: POST
  1389. - URL: `/api/v1/chats/{chat_id}/sessions`
  1390. - Headers:
  1391. - `'content-Type: application/json'`
  1392. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1393. - Body:
  1394. - `"name"`: `string`
  1395. #### Request example
  1396. ```bash
  1397. curl --request POST \
  1398. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1399. --header 'Content-Type: application/json' \
  1400. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  1401. --data '
  1402. {
  1403. "name": "new session"
  1404. }'
  1405. ```
  1406. #### Request parameters
  1407. - `chat_id`: (*Path parameter*)
  1408. The ID of the associated chat assistant.
  1409. - `"name"`: (*Body parameter*), `string`
  1410. The name of the chat session to create.
  1411. ### Response
  1412. Success:
  1413. ```json
  1414. {
  1415. "code": 0,
  1416. "data": {
  1417. "chat_id": "2ca4b22e878011ef88fe0242ac120005",
  1418. "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1419. "create_time": 1728636374571,
  1420. "id": "4606b4ec87ad11efbc4f0242ac120006",
  1421. "messages": [
  1422. {
  1423. "content": "Hi! I am your assistant,can I help you?",
  1424. "role": "assistant"
  1425. }
  1426. ],
  1427. "name": "new session",
  1428. "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1429. "update_time": 1728636374571
  1430. }
  1431. }
  1432. ```
  1433. Failure:
  1434. ```json
  1435. {
  1436. "code": 102,
  1437. "message": "Name can not be empty."
  1438. }
  1439. ```
  1440. ---
  1441. ## Update session
  1442. **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1443. Updates a chat session.
  1444. ### Request
  1445. - Method: PUT
  1446. - URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1447. - Headers:
  1448. - `'content-Type: application/json'`
  1449. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1450. - Body:
  1451. - `"name`: string
  1452. #### Request example
  1453. ```bash
  1454. curl --request PUT \
  1455. --url http://{address}/api/v1/chats/{chat_id}/sessions/{session_id} \
  1456. --header 'Content-Type: application/json' \
  1457. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  1458. --data '
  1459. {
  1460. "name": "<REVISED_SESSION_NAME_HERE>"
  1461. }'
  1462. ```
  1463. #### Request Parameter
  1464. - `chat_id`: (*Path parameter*)
  1465. The ID of the associated chat assistant.
  1466. - `session_id`: (*Path parameter*)
  1467. The ID of the session to update.
  1468. - `"name"`: (*Body Parameter), `string`
  1469. The revised name of the session.
  1470. ### Response
  1471. Success:
  1472. ```json
  1473. {
  1474. "code": 0
  1475. }
  1476. ```
  1477. Failure:
  1478. ```json
  1479. {
  1480. "code": 102,
  1481. "message": "Name cannot be empty."
  1482. }
  1483. ```
  1484. ---
  1485. ## List sessions
  1486. **GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
  1487. Lists sessions associated with a specified chat assistant.
  1488. ### Request
  1489. - Method: GET
  1490. - URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
  1491. - Headers:
  1492. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1493. #### Request example
  1494. ```bash
  1495. curl --request GET \
  1496. --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} \
  1497. --header 'Authorization: Bearer {YOUR_API_KEY}'
  1498. ```
  1499. #### Request Parameters
  1500. - `chat_id`: (*Path parameter*)
  1501. The ID of the associated chat assistant.
  1502. - `page`: (*Filter parameter*), `integer`
  1503. Specifies the page on which the sessions will be displayed. Defaults to `1`.
  1504. - `page_size`: (*Filter parameter*), `integer`
  1505. The number of sessions on each page. Defaults to `1024`.
  1506. - `orderby`: (*Filter parameter*), `string`
  1507. The field by which sessions should be sorted. Available options:
  1508. - `create_time` (default)
  1509. - `update_time`
  1510. - `desc`: (*Filter parameter*), `boolean`
  1511. Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
  1512. - `name`: (*Filter parameter*) `string`
  1513. The name of the chat session to retrieve.
  1514. - `id`: (*Filter parameter*), `string`
  1515. The ID of the chat session to retrieve.
  1516. ### Response
  1517. Success:
  1518. ```json
  1519. {
  1520. "code": 0,
  1521. "data": [
  1522. {
  1523. "chat": "2ca4b22e878011ef88fe0242ac120005",
  1524. "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1525. "create_time": 1728636403974,
  1526. "id": "578d541e87ad11ef96b90242ac120006",
  1527. "messages": [
  1528. {
  1529. "content": "Hi! I am your assistant,can I help you?",
  1530. "role": "assistant"
  1531. }
  1532. ],
  1533. "name": "new session",
  1534. "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1535. "update_time": 1728636403974
  1536. }
  1537. ]
  1538. }
  1539. ```
  1540. Failure:
  1541. ```json
  1542. {
  1543. "code": 102,
  1544. "message": "The session doesn't exist"
  1545. }
  1546. ```
  1547. ---
  1548. ## Delete sessions
  1549. **DELETE** `/api/v1/chats/{chat_id}/sessions`
  1550. Deletes sessions by ID.
  1551. ### Request
  1552. - Method: DELETE
  1553. - URL: `/api/v1/chats/{chat_id}/sessions`
  1554. - Headers:
  1555. - `'content-Type: application/json'`
  1556. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1557. - Body:
  1558. - `"ids"`: `list[string]`
  1559. #### Request example
  1560. ```bash
  1561. # Either id or name must be provided, but not both.
  1562. curl --request DELETE \
  1563. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1564. --header 'Content-Type: application/json' \
  1565. --header 'Authorization: Bear {YOUR_API_KEY}' \
  1566. --data '
  1567. {
  1568. "ids": ["test_1", "test_2"]
  1569. }'
  1570. ```
  1571. #### Request Parameters
  1572. - `chat_id`: (*Path parameter*)
  1573. The ID of the associated chat assistant.
  1574. - `"ids"`: (*Body Parameter*), `list[string]`
  1575. The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
  1576. ### Response
  1577. Success:
  1578. ```json
  1579. {
  1580. "code": 0
  1581. }
  1582. ```
  1583. Failure:
  1584. ```json
  1585. {
  1586. "code": 102,
  1587. "message": "The chat doesn't own the session"
  1588. }
  1589. ```
  1590. ---
  1591. ## Converse
  1592. **POST** `/api/v1/chats/{chat_id}/completions`
  1593. Asks a question to start an AI-powered conversation.
  1594. ### Request
  1595. - Method: POST
  1596. - URL: `/api/v1/chats/{chat_id}/completions`
  1597. - Headers:
  1598. - `'content-Type: application/json'`
  1599. - `'Authorization: Bearer {YOUR_API_KEY}'`
  1600. - Body:
  1601. - `"question"`: `string`
  1602. - `"stream"`: `boolean`
  1603. - `"session_id"`: `string`
  1604. #### Request example
  1605. ```bash
  1606. curl --request POST \
  1607. --url http://{address}/api/v1/chats/{chat_id}/completions \
  1608. --header 'Content-Type: application/json' \
  1609. --header 'Authorization: Bearer {YOUR_API_KEY}' \
  1610. --data-binary '
  1611. {
  1612. "question": "What is RAGFlow?",
  1613. "stream": true
  1614. }'
  1615. ```
  1616. #### Request Parameters
  1617. - `chat_id`: (*Path parameter*)
  1618. The ID of the associated chat assistant.
  1619. - `"question"`: (*Body Parameter*), `string` *Required*
  1620. The question to start an AI-powered conversation.
  1621. - `"stream"`: (*Body Parameter*), `boolean`
  1622. Indicates whether to output responses in a streaming way:
  1623. - `true`: Enable streaming.
  1624. - `false`: Disable streaming (default).
  1625. - `"session_id"`: (*Body Parameter*)
  1626. The ID of session. If it is not provided, a new session will be generated.
  1627. ### Response
  1628. Success:
  1629. ```json
  1630. data: {
  1631. "code": 0,
  1632. "data": {
  1633. "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide",
  1634. "reference": {},
  1635. "audio_binary": null,
  1636. "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
  1637. "session_id": "e14344d08d1a11efb6210242ac120004"
  1638. }
  1639. }
  1640. data: {
  1641. "code": 0,
  1642. "data": {
  1643. "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me",
  1644. "reference": {},
  1645. "audio_binary": null,
  1646. "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
  1647. "session_id": "e14344d08d1a11efb6210242ac120004"
  1648. }
  1649. }
  1650. data: {
  1651. "code": 0,
  1652. "data": {
  1653. "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me. How can I assist you today?",
  1654. "reference": {},
  1655. "audio_binary": null,
  1656. "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
  1657. "session_id": "e14344d08d1a11efb6210242ac120004"
  1658. }
  1659. }
  1660. data: {
  1661. "code": 0,
  1662. "data": {
  1663. "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me ##0$$. How can I assist you today?",
  1664. "reference": {
  1665. "total": 8,
  1666. "chunks": [
  1667. {
  1668. "chunk_id": "895d34de762e674b43e8613c6fb54c6d",
  1669. "content_ltks": "xxxx\r\n\r\n\"\"\"\r\nyou are an intellig assistant. pleas summar the content of the knowledg base to answer the question. pleas list thedata in the knowledg base and answer in detail. when all knowledg base content is irrelev to the question , your answer must includ the sentenc\"the answer you are lookfor isnot found in the knowledg base!\" answer needto consid chat history.\r\n here is the knowledg base:\r\n{ knowledg}\r\nthe abov is the knowledg base.\r\n\"\"\"\r\n1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\nxxxx ",
  1670. "content_with_weight": "xxxx\r\n\r\n\"\"\"\r\nYou 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.\r\n Here is the knowledge base:\r\n {knowledge}\r\n The above is the knowledge base.\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\nxxxx\r\n\r\n\"\"\"\r\nxxxx",
  1671. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1672. "docnm_kwd": "1.txt",
  1673. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1674. "important_kwd": [],
  1675. "img_id": "",
  1676. "similarity": 0.4442746624416507,
  1677. "vector_similarity": 0.3843936320913369,
  1678. "term_similarity": 0.4699379611632138,
  1679. "positions": [
  1680. ""
  1681. ]
  1682. }
  1683. ],
  1684. "doc_aggs": [
  1685. {
  1686. "doc_name": "1.txt",
  1687. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1688. "count": 1
  1689. }
  1690. ]
  1691. },
  1692. "prompt": "xxxx\r\n\r\n\"\"\"\r\nYou 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.\r\n Here is the knowledge base:\r\n {knowledge}\r\n The above is the knowledge base.\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\nxxxx\n\n### Query:\nwho are you,please answer me in English\n\n### Elapsed\n - Retrieval: 332.2 ms\n - LLM: 2972.1 ms",
  1693. "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
  1694. "session_id": "e14344d08d1a11efb6210242ac120004"
  1695. }
  1696. }
  1697. data:{
  1698. "code": 0,
  1699. "data": true
  1700. }
  1701. ```
  1702. Failure:
  1703. ```json
  1704. {
  1705. "code": 102,
  1706. "message": "Please input your question."
  1707. }
  1708. ```