Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101
  1. ---
  2. sidebar_position: 0
  3. slug: /http_api_reference
  4. ---
  5. # HTTP API Reference
  6. This document provides a complete reference for RAGFlow's RESTful API. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](../guides/develop/acquire_ragflow_api_key.md).
  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. You can set it only to `"me"` for now.
  62. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  63. The chunking method of the dataset to create. Available options:
  64. - `"naive"`: General (default)
  65. - `"manual"`: Manual
  66. - `"qa"`: Q&A
  67. - `"table"`: Table
  68. - `"paper"`: Paper
  69. - `"book"`: Book
  70. - `"laws"`: Laws
  71. - `"presentation"`: Presentation
  72. - `"picture"`: Picture
  73. - `"one"`: One
  74. - `"knowledge_graph"`: Knowledge Graph
  75. - `"email"`: Email
  76. - `"parser_config"`: (*Body parameter*), `object`
  77. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  78. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  79. - `"chunk_token_count"`: Defaults to `128`.
  80. - `"layout_recognize"`: Defaults to `true`.
  81. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  82. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  83. - `"task_page_size"`: Defaults to `12`. For PDF only.
  84. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  85. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  86. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  87. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  88. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  89. - `"chunk_token_count"`: Defaults to `128`.
  90. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  91. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  92. ### Response
  93. Success:
  94. ```json
  95. {
  96. "code": 0,
  97. "data": {
  98. "avatar": null,
  99. "chunk_count": 0,
  100. "chunk_method": "naive",
  101. "create_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  102. "create_time": 1729761247434,
  103. "created_by": "69736c5e723611efb51b0242ac120007",
  104. "description": null,
  105. "document_count": 0,
  106. "embedding_model": "BAAI/bge-large-zh-v1.5",
  107. "id": "527fa74891e811ef9c650242ac120006",
  108. "language": "English",
  109. "name": "test_1",
  110. "parser_config": {
  111. "chunk_token_num": 128,
  112. "delimiter": "\\n!?;。;!?",
  113. "html4excel": false,
  114. "layout_recognize": true,
  115. "raptor": {
  116. "user_raptor": false
  117. }
  118. },
  119. "permission": "me",
  120. "similarity_threshold": 0.2,
  121. "status": "1",
  122. "tenant_id": "69736c5e723611efb51b0242ac120007",
  123. "token_num": 0,
  124. "update_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  125. "update_time": 1729761247434,
  126. "vector_similarity_weight": 0.3
  127. }
  128. }
  129. ```
  130. Failure:
  131. ```json
  132. {
  133. "code": 102,
  134. "message": "Duplicated knowledgebase name in creating dataset."
  135. }
  136. ```
  137. ---
  138. ## Delete datasets
  139. **DELETE** `/api/v1/datasets`
  140. Deletes datasets by ID.
  141. ### Request
  142. - Method: DELETE
  143. - URL: `/api/v1/datasets`
  144. - Headers:
  145. - `'content-Type: application/json'`
  146. - `'Authorization: Bearer <YOUR_API_KEY>'`
  147. - Body:
  148. - `"ids"`: `list[string]`
  149. #### Request example
  150. ```bash
  151. curl --request DELETE \
  152. --url http://{address}/api/v1/datasets \
  153. --header 'Content-Type: application/json' \
  154. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  155. --data '{"ids": ["test_1", "test_2"]}'
  156. ```
  157. #### Request parameters
  158. - `"ids"`: (*Body parameter*), `list[string]`
  159. The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
  160. ### Response
  161. Success:
  162. ```json
  163. {
  164. "code": 0
  165. }
  166. ```
  167. Failure:
  168. ```json
  169. {
  170. "code": 102,
  171. "message": "You don't own the dataset."
  172. }
  173. ```
  174. ---
  175. ## Update dataset
  176. **PUT** `/api/v1/datasets/{dataset_id}`
  177. Updates configurations for a specified dataset.
  178. ### Request
  179. - Method: PUT
  180. - URL: `/api/v1/datasets/{dataset_id}`
  181. - Headers:
  182. - `'content-Type: application/json'`
  183. - `'Authorization: Bearer <YOUR_API_KEY>'`
  184. - Body:
  185. - `"name"`: `string`
  186. - `"embedding_model"`: `string`
  187. - `"chunk_method"`: `enum<string>`
  188. #### Request example
  189. ```bash
  190. curl --request PUT \
  191. --url http://{address}/api/v1/datasets/{dataset_id} \
  192. --header 'Content-Type: application/json' \
  193. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  194. --data '
  195. {
  196. "name": "updated_dataset",
  197. }'
  198. ```
  199. #### Request parameters
  200. - `dataset_id`: (*Path parameter*)
  201. The ID of the dataset to update.
  202. - `"name"`: (*Body parameter*), `string`
  203. The revised name of the dataset.
  204. - `"embedding_model"`: (*Body parameter*), `string`
  205. The updated embedding model name.
  206. - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
  207. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  208. The chunking method for the dataset. Available options:
  209. - `"naive"`: General
  210. - `"manual`: Manual
  211. - `"qa"`: Q&A
  212. - `"table"`: Table
  213. - `"paper"`: Paper
  214. - `"book"`: Book
  215. - `"laws"`: Laws
  216. - `"presentation"`: Presentation
  217. - `"picture"`: Picture
  218. - `"one"`:One
  219. - `"knowledge_graph"`: Knowledge Graph
  220. ### Response
  221. Success:
  222. ```json
  223. {
  224. "code": 0
  225. }
  226. ```
  227. Failure:
  228. ```json
  229. {
  230. "code": 102,
  231. "message": "Can't change tenant_id."
  232. }
  233. ```
  234. ---
  235. ## List datasets
  236. **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  237. Lists datasets.
  238. ### Request
  239. - Method: GET
  240. - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  241. - Headers:
  242. - `'Authorization: Bearer <YOUR_API_KEY>'`
  243. #### Request example
  244. ```bash
  245. curl --request GET \
  246. --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  247. --header 'Authorization: Bearer <YOUR_API_KEY>'
  248. ```
  249. #### Request parameters
  250. - `page`: (*Filter parameter*)
  251. Specifies the page on which the datasets will be displayed. Defaults to `1`.
  252. - `page_size`: (*Filter parameter*)
  253. The number of datasets on each page. Defaults to `1024`.
  254. - `orderby`: (*Filter parameter*)
  255. The field by which datasets should be sorted. Available options:
  256. - `create_time` (default)
  257. - `update_time`
  258. - `desc`: (*Filter parameter*)
  259. Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
  260. - `name`: (*Filter parameter*)
  261. The name of the dataset to retrieve.
  262. - `id`: (*Filter parameter*)
  263. The ID of the dataset to retrieve.
  264. ### Response
  265. Success:
  266. ```json
  267. {
  268. "code": 0,
  269. "data": [
  270. {
  271. "avatar": "",
  272. "chunk_count": 59,
  273. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  274. "create_time": 1726276357324,
  275. "created_by": "69736c5e723611efb51b0242ac120007",
  276. "description": null,
  277. "document_count": 1,
  278. "embedding_model": "BAAI/bge-large-zh-v1.5",
  279. "id": "6e211ee0723611efa10a0242ac120007",
  280. "language": "English",
  281. "name": "mysql",
  282. "chunk_method": "knowledge_graph",
  283. "parser_config": {
  284. "chunk_token_num": 8192,
  285. "delimiter": "\\n!?;。;!?",
  286. "entity_types": [
  287. "organization",
  288. "person",
  289. "location",
  290. "event",
  291. "time"
  292. ]
  293. },
  294. "permission": "me",
  295. "similarity_threshold": 0.2,
  296. "status": "1",
  297. "tenant_id": "69736c5e723611efb51b0242ac120007",
  298. "token_num": 12744,
  299. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  300. "update_time": 1728533243536,
  301. "vector_similarity_weight": 0.3
  302. }
  303. ]
  304. }
  305. ```
  306. Failure:
  307. ```json
  308. {
  309. "code": 102,
  310. "message": "The dataset doesn't exist"
  311. }
  312. ```
  313. ---
  314. :::tip API GROUPING
  315. File Management within Dataset
  316. :::
  317. ---
  318. ## Upload documents
  319. **POST** `/api/v1/datasets/{dataset_id}/documents`
  320. Uploads documents to a specified dataset.
  321. ### Request
  322. - Method: POST
  323. - URL: `/api/v1/datasets/{dataset_id}/documents`
  324. - Headers:
  325. - `'Content-Type: multipart/form-data'`
  326. - `'Authorization: Bearer <YOUR_API_KEY>'`
  327. - Form:
  328. - `'file=@{FILE_PATH}'`
  329. #### Request example
  330. ```bash
  331. curl --request POST \
  332. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  333. --header 'Content-Type: multipart/form-data' \
  334. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  335. --form 'file=@./test1.txt' \
  336. --form 'file=@./test2.pdf'
  337. ```
  338. #### Request parameters
  339. - `dataset_id`: (*Path parameter*)
  340. The ID of the dataset to which the documents will be uploaded.
  341. - `'file'`: (*Body parameter*)
  342. A document to upload.
  343. ### Response
  344. Success:
  345. ```json
  346. {
  347. "code": 0,
  348. "data": [
  349. {
  350. "chunk_method": "naive",
  351. "created_by": "69736c5e723611efb51b0242ac120007",
  352. "dataset_id": "527fa74891e811ef9c650242ac120006",
  353. "id": "b330ec2e91ec11efbc510242ac120004",
  354. "location": "1.txt",
  355. "name": "1.txt",
  356. "parser_config": {
  357. "chunk_token_num": 128,
  358. "delimiter": "\\n!?;。;!?",
  359. "html4excel": false,
  360. "layout_recognize": true,
  361. "raptor": {
  362. "user_raptor": false
  363. }
  364. },
  365. "run": "UNSTART",
  366. "size": 17966,
  367. "thumbnail": "",
  368. "type": "doc"
  369. }
  370. ]
  371. }
  372. ```
  373. Failure:
  374. ```json
  375. {
  376. "code": 101,
  377. "message": "No file part!"
  378. }
  379. ```
  380. ---
  381. ## Update document
  382. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  383. Updates configurations for a specified document.
  384. ### Request
  385. - Method: PUT
  386. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  387. - Headers:
  388. - `'content-Type: application/json'`
  389. - `'Authorization: Bearer <YOUR_API_KEY>'`
  390. - Body:
  391. - `"name"`:`string`
  392. - `"chunk_method"`:`string`
  393. - `"parser_config"`:`object`
  394. #### Request example
  395. ```bash
  396. curl --request PUT \
  397. --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
  398. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  399. --header 'Content-Type: application/json' \
  400. --data '
  401. {
  402. "name": "manual.txt",
  403. "chunk_method": "manual",
  404. "parser_config": {"chunk_token_count": 128}
  405. }'
  406. ```
  407. #### Request parameters
  408. - `dataset_id`: (*Path parameter*)
  409. The ID of the associated dataset.
  410. - `document_id`: (*Path parameter*)
  411. The ID of the document to update.
  412. - `"name"`: (*Body parameter*), `string`
  413. - `"chunk_method"`: (*Body parameter*), `string`
  414. The parsing method to apply to the document:
  415. - `"naive"`: General
  416. - `"manual`: Manual
  417. - `"qa"`: Q&A
  418. - `"table"`: Table
  419. - `"paper"`: Paper
  420. - `"book"`: Book
  421. - `"laws"`: Laws
  422. - `"presentation"`: Presentation
  423. - `"picture"`: Picture
  424. - `"one"`: One
  425. - `"knowledge_graph"`: Knowledge Graph
  426. - `"email"`: Email
  427. - `"parser_config"`: (*Body parameter*), `object`
  428. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  429. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  430. - `"chunk_token_count"`: Defaults to `128`.
  431. - `"layout_recognize"`: Defaults to `true`.
  432. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  433. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  434. - `"task_page_size"`: Defaults to `12`. For PDF only.
  435. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  436. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  437. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  438. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  439. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  440. - `"chunk_token_count"`: Defaults to `128`.
  441. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  442. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  443. ### Response
  444. Success:
  445. ```json
  446. {
  447. "code": 0
  448. }
  449. ```
  450. Failure:
  451. ```json
  452. {
  453. "code": 102,
  454. "message": "The dataset does not have the document."
  455. }
  456. ```
  457. ---
  458. ## Download document
  459. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  460. Downloads a document from a specified dataset.
  461. ### Request
  462. - Method: GET
  463. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  464. - Headers:
  465. - `'Authorization: Bearer <YOUR_API_KEY>'`
  466. - Output:
  467. - `'{PATH_TO_THE_FILE}'`
  468. #### Request example
  469. ```bash
  470. curl --request GET \
  471. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
  472. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  473. --output ./ragflow.txt
  474. ```
  475. #### Request parameters
  476. - `dataset_id`: (*Path parameter*)
  477. The associated dataset ID.
  478. - `documents_id`: (*Path parameter*)
  479. The ID of the document to download.
  480. ### Response
  481. Success:
  482. ```text
  483. This is a test to verify the file download feature.
  484. ```
  485. Failure:
  486. ```json
  487. {
  488. "code": 102,
  489. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  490. }
  491. ```
  492. ---
  493. ## List documents
  494. **GET** `/api/v1/datasets/{dataset_id}/documents?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  495. Lists documents in a specified dataset.
  496. ### Request
  497. - Method: GET
  498. - URL: `/api/v1/datasets/{dataset_id}/documents?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  499. - Headers:
  500. - `'content-Type: application/json'`
  501. - `'Authorization: Bearer <YOUR_API_KEY>'`
  502. #### Request example
  503. ```bash
  504. curl --request GET \
  505. --url http://{address}/api/v1/datasets/{dataset_id}/documents?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name} \
  506. --header 'Authorization: Bearer <YOUR_API_KEY>'
  507. ```
  508. #### Request parameters
  509. - `dataset_id`: (*Path parameter*)
  510. The associated dataset ID.
  511. - `keywords`: (*Filter parameter*), `string`
  512. The keywords used to match document titles.
  513. - `offset`: (*Filter parameter*), `integer`
  514. The starting index for the documents to retrieve. Typically used in conjunction with `limit`. Defaults to `1`.
  515. - `limit`: (*Filter parameter*), `integer`
  516. The maximum number of documents to retrieve. Defaults to `1024`.
  517. - `orderby`: (*Filter parameter*), `string`
  518. The field by which documents should be sorted. Available options:
  519. - `create_time` (default)
  520. - `update_time`
  521. - `desc`: (*Filter parameter*), `boolean`
  522. Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
  523. - `id`: (*Filter parameter*), `string`
  524. The ID of the document to retrieve.
  525. ### Response
  526. Success:
  527. ```json
  528. {
  529. "code": 0,
  530. "data": {
  531. "docs": [
  532. {
  533. "chunk_count": 0,
  534. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  535. "create_time": 1728897061948,
  536. "created_by": "69736c5e723611efb51b0242ac120007",
  537. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  538. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  539. "location": "Test_2.txt",
  540. "name": "Test_2.txt",
  541. "parser_config": {
  542. "chunk_token_count": 128,
  543. "delimiter": "\n!?。;!?",
  544. "layout_recognize": true,
  545. "task_page_size": 12
  546. },
  547. "parser_method": "naive",
  548. "process_begin_at": null,
  549. "process_duation": 0.0,
  550. "progress": 0.0,
  551. "progress_msg": "",
  552. "run": "0",
  553. "size": 7,
  554. "source_type": "local",
  555. "status": "1",
  556. "thumbnail": null,
  557. "token_count": 0,
  558. "type": "doc",
  559. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  560. "update_time": 1728897061948
  561. }
  562. ],
  563. "total": 1
  564. }
  565. }
  566. ```
  567. Failure:
  568. ```json
  569. {
  570. "code": 102,
  571. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  572. }
  573. ```
  574. ---
  575. ## Delete documents
  576. **DELETE** `/api/v1/datasets/{dataset_id}/documents`
  577. Deletes documents by ID.
  578. ### Request
  579. - Method: DELETE
  580. - URL: `/api/v1/datasets/{dataset_id}/documents`
  581. - Headers:
  582. - `'Content-Type: application/json'`
  583. - `'Authorization: Bearer <YOUR_API_KEY>'`
  584. - Body:
  585. - `"ids"`: `list[string]`
  586. #### Request example
  587. ```bash
  588. curl --request DELETE \
  589. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  590. --header 'Content-Type: application/json' \
  591. --header 'Authorization: <YOUR_API_KEY>' \
  592. --data '
  593. {
  594. "ids": ["id_1","id_2"]
  595. }'
  596. ```
  597. #### Request parameters
  598. - `dataset_id`: (*Path parameter*)
  599. The associated dataset ID.
  600. - `"ids"`: (*Body parameter*), `list[string]`
  601. The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
  602. ### Response
  603. Success:
  604. ```json
  605. {
  606. "code": 0
  607. }.
  608. ```
  609. Failure:
  610. ```json
  611. {
  612. "code": 102,
  613. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  614. }
  615. ```
  616. ---
  617. ## Parse documents
  618. **POST** `/api/v1/datasets/{dataset_id}/chunks`
  619. Parses documents in a specified dataset.
  620. ### Request
  621. - Method: POST
  622. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  623. - Headers:
  624. - `'content-Type: application/json'`
  625. - `'Authorization: Bearer <YOUR_API_KEY>'`
  626. - Body:
  627. - `"document_ids"`: `list[string]`
  628. #### Request example
  629. ```bash
  630. curl --request POST \
  631. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  632. --header 'Content-Type: application/json' \
  633. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  634. --data '
  635. {
  636. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  637. }'
  638. ```
  639. #### Request parameters
  640. - `dataset_id`: (*Path parameter*)
  641. The dataset ID.
  642. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  643. The IDs of the documents to parse.
  644. ### Response
  645. Success:
  646. ```json
  647. {
  648. "code": 0
  649. }
  650. ```
  651. Failure:
  652. ```json
  653. {
  654. "code": 102,
  655. "message": "`document_ids` is required"
  656. }
  657. ```
  658. ---
  659. ## Stop parsing documents
  660. **DELETE** `/api/v1/datasets/{dataset_id}/chunks`
  661. Stops parsing specified documents.
  662. ### Request
  663. - Method: DELETE
  664. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  665. - Headers:
  666. - `'content-Type: application/json'`
  667. - `'Authorization: Bearer <YOUR_API_KEY>'`
  668. - Body:
  669. - `"document_ids"`: `list[string]`
  670. #### Request example
  671. ```bash
  672. curl --request DELETE \
  673. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  674. --header 'Content-Type: application/json' \
  675. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  676. --data '
  677. {
  678. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  679. }'
  680. ```
  681. #### Request parameters
  682. - `dataset_id`: (*Path parameter*)
  683. The associated dataset ID.
  684. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  685. The IDs of the documents for which the parsing should be stopped.
  686. ### Response
  687. Success:
  688. ```json
  689. {
  690. "code": 0
  691. }
  692. ```
  693. Failure:
  694. ```json
  695. {
  696. "code": 102,
  697. "message": "`document_ids` is required"
  698. }
  699. ```
  700. ---
  701. ## Add chunks
  702. **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  703. Adds a chunk to a specified document in a specified dataset.
  704. ### Request
  705. - Method: POST
  706. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  707. - Headers:
  708. - `'content-Type: application/json'`
  709. - `'Authorization: Bearer <YOUR_API_KEY>'`
  710. - Body:
  711. - `"content"`: `string`
  712. - `"important_keywords"`: `list[string]`
  713. #### Request example
  714. ```bash
  715. curl --request POST \
  716. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  717. --header 'Content-Type: application/json' \
  718. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  719. --data '
  720. {
  721. "content": "<SOME_CHUNK_CONTENT_HERE>"
  722. }'
  723. ```
  724. #### Request parameters
  725. - `dataset_id`: (*Path parameter*)
  726. The associated dataset ID.
  727. - `document_ids`: (*Path parameter*)
  728. The associated document ID.
  729. - `"content"`: (*Body parameter*), `string`, *Required*
  730. The text content of the chunk.
  731. - `"important_keywords`(*Body parameter*), `list[string]`
  732. The key terms or phrases to tag with the chunk.
  733. ### Response
  734. Success:
  735. ```json
  736. {
  737. "code": 0,
  738. "data": {
  739. "chunk": {
  740. "content": "ragflow content",
  741. "create_time": "2024-10-16 08:05:04",
  742. "create_timestamp": 1729065904.581025,
  743. "dataset_id": [
  744. "c7ee74067a2c11efb21c0242ac120006"
  745. ],
  746. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  747. "id": "d78435d142bd5cf6704da62c778795c5",
  748. "important_keywords": []
  749. }
  750. }
  751. }
  752. ```
  753. Failure:
  754. ```json
  755. {
  756. "code": 102,
  757. "message": "`content` is required"
  758. }
  759. ```
  760. ---
  761. ## List chunks
  762. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={id}`
  763. Lists chunks in a specified document.
  764. ### Request
  765. - Method: GET
  766. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id}`
  767. - Headers:
  768. - `'Authorization: Bearer <YOUR_API_KEY>'`
  769. #### Request example
  770. ```bash
  771. curl --request GET \
  772. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id} \
  773. --header 'Authorization: Bearer <YOUR_API_KEY>'
  774. ```
  775. #### Request parameters
  776. - `dataset_id`: (*Path parameter*)
  777. The associated dataset ID.
  778. - `document_ids`: (*Path parameter*)
  779. The associated document ID.
  780. - `keywords`(*Filter parameter*), `string`
  781. The keywords used to match chunk content.
  782. - `offset`(*Filter parameter*), `string`
  783. The starting index for the chunks to retrieve. Defaults to `1`.
  784. - `limit`(*Filter parameter*), `integer`
  785. The maximum number of chunks to retrieve. Default: `1024`
  786. - `id`(*Filter parameter*), `string`
  787. The ID of the chunk to retrieve.
  788. ### Response
  789. Success:
  790. ```json
  791. {
  792. "code": 0,
  793. "data": {
  794. "chunks": [
  795. {
  796. "available_int": 1,
  797. "content": "This is a test content.",
  798. "docnm_kwd": "1.txt",
  799. "document_id": "b330ec2e91ec11efbc510242ac120004",
  800. "id": "b48c170e90f70af998485c1065490726",
  801. "image_id": "",
  802. "important_keywords": "",
  803. "positions": [
  804. ""
  805. ]
  806. }
  807. ],
  808. "doc": {
  809. "chunk_count": 1,
  810. "chunk_method": "naive",
  811. "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
  812. "create_time": 1729763127646,
  813. "created_by": "69736c5e723611efb51b0242ac120007",
  814. "dataset_id": "527fa74891e811ef9c650242ac120006",
  815. "id": "b330ec2e91ec11efbc510242ac120004",
  816. "location": "1.txt",
  817. "name": "1.txt",
  818. "parser_config": {
  819. "chunk_token_num": 128,
  820. "delimiter": "\\n!?;。;!?",
  821. "html4excel": false,
  822. "layout_recognize": true,
  823. "raptor": {
  824. "user_raptor": false
  825. }
  826. },
  827. "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
  828. "process_duation": 0.54213,
  829. "progress": 0.0,
  830. "progress_msg": "Task dispatched...",
  831. "run": "2",
  832. "size": 17966,
  833. "source_type": "local",
  834. "status": "1",
  835. "thumbnail": "",
  836. "token_count": 8,
  837. "type": "doc",
  838. "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
  839. "update_time": 1729767795721
  840. },
  841. "total": 1
  842. }
  843. }
  844. ```
  845. Failure:
  846. ```json
  847. {
  848. "code": 102,
  849. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  850. }
  851. ```
  852. ---
  853. ## Delete chunks
  854. **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  855. Deletes chunks by ID.
  856. ### Request
  857. - Method: DELETE
  858. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  859. - Headers:
  860. - `'content-Type: application/json'`
  861. - `'Authorization: Bearer <YOUR_API_KEY>'`
  862. - Body:
  863. - `"chunk_ids"`: `list[string]`
  864. #### Request example
  865. ```bash
  866. curl --request DELETE \
  867. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  868. --header 'Content-Type: application/json' \
  869. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  870. --data '
  871. {
  872. "chunk_ids": ["test_1", "test_2"]
  873. }'
  874. ```
  875. #### Request parameters
  876. - `dataset_id`: (*Path parameter*)
  877. The associated dataset ID.
  878. - `document_ids`: (*Path parameter*)
  879. The associated document ID.
  880. - `"chunk_ids"`: (*Body parameter*), `list[string]`
  881. The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
  882. ### Response
  883. Success:
  884. ```json
  885. {
  886. "code": 0
  887. }
  888. ```
  889. Failure:
  890. ```json
  891. {
  892. "code": 102,
  893. "message": "`chunk_ids` is required"
  894. }
  895. ```
  896. ---
  897. ## Update chunk
  898. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  899. Updates content or configurations for a specified chunk.
  900. ### Request
  901. - Method: PUT
  902. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  903. - Headers:
  904. - `'content-Type: application/json'`
  905. - `'Authorization: Bearer <YOUR_API_KEY>'`
  906. - Body:
  907. - `"content"`: `string`
  908. - `"important_keywords"`: `string`
  909. - `"available"`: `integer`
  910. #### Request example
  911. ```bash
  912. curl --request PUT \
  913. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
  914. --header 'Content-Type: application/json' \
  915. --header 'Authorization: <YOUR_API_KEY>' \
  916. --data '
  917. {
  918. "content": "ragflow123",
  919. "important_keywords": [],
  920. }'
  921. ```
  922. #### Request parameters
  923. - `dataset_id`: (*Path parameter*)
  924. The associated dataset ID.
  925. - `document_ids`: (*Path parameter*)
  926. The associated document ID.
  927. - `chunk_id`: (*Path parameter*)
  928. The ID of the chunk to update.
  929. - `"content"`: (*Body parameter*), `string`
  930. The text content of the chunk.
  931. - `"important_keywords"`: (*Body parameter*), `list[string]`
  932. A list of key terms or phrases to tag with the chunk.
  933. - `"available"`: (*Body parameter*) `boolean`
  934. The chunk's availability status in the dataset. Value options:
  935. - `true`: Available (default)
  936. - `false`: Unavailable
  937. ### Response
  938. Success:
  939. ```json
  940. {
  941. "code": 0
  942. }
  943. ```
  944. Failure:
  945. ```json
  946. {
  947. "code": 102,
  948. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  949. }
  950. ```
  951. ---
  952. ## Retrieve chunks
  953. **POST** `/api/v1/retrieval`
  954. Retrieves chunks from specified datasets.
  955. ### Request
  956. - Method: POST
  957. - URL: `/api/v1/retrieval`
  958. - Headers:
  959. - `'content-Type: application/json'`
  960. - `'Authorization: Bearer <YOUR_API_KEY>'`
  961. - Body:
  962. - `"question"`: `string`
  963. - `"dataset_ids"`: `list[string]`
  964. - `"document_ids"`: `list[string]`
  965. - `"offset"`: `integer`
  966. - `"limit"`: `integer`
  967. - `"similarity_threshold"`: `float`
  968. - `"vector_similarity_weight"`: `float`
  969. - `"top_k"`: `integer`
  970. - `"rerank_id"`: `string`
  971. - `"keyword"`: `boolean`
  972. - `"highlight"`: `boolean`
  973. #### Request example
  974. ```bash
  975. curl --request POST \
  976. --url http://{address}/api/v1/retrieval \
  977. --header 'Content-Type: application/json' \
  978. --header 'Authorization: <YOUR_API_KEY>' \
  979. --data '
  980. {
  981. "question": "What is advantage of ragflow?",
  982. "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
  983. "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
  984. }'
  985. ```
  986. #### Request parameter
  987. - `"question"`: (*Body parameter*), `string`, *Required*
  988. The user query or query keywords.
  989. - `"dataset_ids"`: (*Body parameter*) `list[string]`
  990. The IDs of the datasets to search. If you do not set this argument, ensure that you set `"document_ids"`.
  991. - `"document_ids"`: (*Body parameter*), `list[string]`
  992. 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"`.
  993. - `"offset"`: (*Body parameter*), `integer`
  994. The starting index for the documents to retrieve. Defaults to `1`.
  995. - `"limit"`: (*Body parameter*)
  996. The maximum number of chunks to retrieve. Defaults to `1024`.
  997. - `"similarity_threshold"`: (*Body parameter*)
  998. The minimum similarity score. Defaults to `0.2`.
  999. - `"vector_similarity_weight"`: (*Body parameter*), `float`
  1000. 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.
  1001. - `"top_k"`: (*Body parameter*), `integer`
  1002. The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
  1003. - `"rerank_id"`: (*Body parameter*), `integer`
  1004. The ID of the rerank model.
  1005. - `"keyword"`: (*Body parameter*), `boolean`
  1006. Indicates whether to enable keyword-based matching:
  1007. - `true`: Enable keyword-based matching.
  1008. - `false`: Disable keyword-based matching (default).
  1009. - `"highlight"`: (*Body parameter*), `boolean`
  1010. Specifies whether to enable highlighting of matched terms in the results:
  1011. - `true`: Enable highlighting of matched terms.
  1012. - `false`: Disable highlighting of matched terms (default).
  1013. ### Response
  1014. Success:
  1015. ```json
  1016. {
  1017. "code": 0,
  1018. "data": {
  1019. "chunks": [
  1020. {
  1021. "content": "ragflow content",
  1022. "content_ltks": "ragflow content",
  1023. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  1024. "document_keyword": "1.txt",
  1025. "highlight": "<em>ragflow</em> content",
  1026. "id": "d78435d142bd5cf6704da62c778795c5",
  1027. "img_id": "",
  1028. "important_keywords": [
  1029. ""
  1030. ],
  1031. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1032. "positions": [
  1033. ""
  1034. ],
  1035. "similarity": 0.9669436601210759,
  1036. "term_similarity": 1.0,
  1037. "vector_similarity": 0.8898122004035864
  1038. }
  1039. ],
  1040. "doc_aggs": [
  1041. {
  1042. "count": 1,
  1043. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1044. "doc_name": "1.txt"
  1045. }
  1046. ],
  1047. "total": 1
  1048. }
  1049. }
  1050. ```
  1051. Failure:
  1052. ```json
  1053. {
  1054. "code": 102,
  1055. "message": "`datasets` is required."
  1056. }
  1057. ```
  1058. ---
  1059. :::tip API GROUPING
  1060. Chat Assistant Management
  1061. :::
  1062. ---
  1063. ## Create chat assistant
  1064. **POST** `/api/v1/chats`
  1065. Creates a chat assistant.
  1066. ### Request
  1067. - Method: POST
  1068. - URL: `/api/v1/chats`
  1069. - Headers:
  1070. - `'content-Type: application/json'`
  1071. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1072. - Body:
  1073. - `"name"`: `string`
  1074. - `"avatar"`: `string`
  1075. - `"dataset_ids"`: `list[string]`
  1076. - `"llm"`: `object`
  1077. - `"prompt"`: `object`
  1078. #### Request example
  1079. ```shell
  1080. curl --request POST \
  1081. --url http://{address}/api/v1/chats \
  1082. --header 'Content-Type: application/json' \
  1083. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1084. --data '{
  1085. "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
  1086. "name":"new_chat_1"
  1087. }'
  1088. ```
  1089. #### Request parameters
  1090. - `"name"`: (*Body parameter*), `string`, *Required*
  1091. The name of the chat assistant.
  1092. - `"avatar"`: (*Body parameter*), `string`
  1093. Base64 encoding of the avatar.
  1094. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1095. The IDs of the associated datasets.
  1096. - `"llm"`: (*Body parameter*), `object`
  1097. 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:
  1098. - `"model_name"`, `string`
  1099. The chat model name. If not set, the user's default chat model will be used.
  1100. - `"temperature"`: `float`
  1101. 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`.
  1102. - `"top_p"`: `float`
  1103. 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`
  1104. - `"presence_penalty"`: `float`
  1105. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1106. - `"frequency penalty"`: `float`
  1107. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1108. - `"max_token"`: `integer`
  1109. The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
  1110. - `"prompt"`: (*Body parameter*), `object`
  1111. 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:
  1112. - `"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`.
  1113. - `"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`.
  1114. - `"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`.
  1115. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1116. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1117. - All the variables in 'System' should be curly bracketed.
  1118. - The default value is `[{"key": "knowledge", "optional": true}]`.
  1119. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1120. - `"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.
  1121. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1122. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1123. - `"prompt"`: `string` The prompt content.
  1124. ### Response
  1125. Success:
  1126. ```json
  1127. {
  1128. "code": 0,
  1129. "data": {
  1130. "avatar": "",
  1131. "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1132. "create_time": 1729768709023,
  1133. "dataset_ids": [
  1134. "527fa74891e811ef9c650242ac120006"
  1135. ],
  1136. "description": "A helpful Assistant",
  1137. "do_refer": "1",
  1138. "id": "b1f2f15691f911ef81180242ac120003",
  1139. "language": "English",
  1140. "llm": {
  1141. "frequency_penalty": 0.7,
  1142. "max_tokens": 512,
  1143. "model_name": "qwen-plus@Tongyi-Qianwen",
  1144. "presence_penalty": 0.4,
  1145. "temperature": 0.1,
  1146. "top_p": 0.3
  1147. },
  1148. "name": "12234",
  1149. "prompt": {
  1150. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1151. "keywords_similarity_weight": 0.3,
  1152. "opener": "Hi! I'm your assistant, what can I do for you?",
  1153. "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 ",
  1154. "rerank_model": "",
  1155. "similarity_threshold": 0.2,
  1156. "top_n": 6,
  1157. "variables": [
  1158. {
  1159. "key": "knowledge",
  1160. "optional": false
  1161. }
  1162. ]
  1163. },
  1164. "prompt_type": "simple",
  1165. "status": "1",
  1166. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1167. "top_k": 1024,
  1168. "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1169. "update_time": 1729768709023
  1170. }
  1171. }
  1172. ```
  1173. Failure:
  1174. ```json
  1175. {
  1176. "code": 102,
  1177. "message": "Duplicated chat name in creating dataset."
  1178. }
  1179. ```
  1180. ---
  1181. ## Update chat assistant
  1182. **PUT** `/api/v1/chats/{chat_id}`
  1183. Updates configurations for a specified chat assistant.
  1184. ### Request
  1185. - Method: PUT
  1186. - URL: `/api/v1/chats/{chat_id}`
  1187. - Headers:
  1188. - `'content-Type: application/json'`
  1189. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1190. - Body:
  1191. - `"name"`: `string`
  1192. - `"avatar"`: `string`
  1193. - `"dataset_ids"`: `list[string]`
  1194. - `"llm"`: `object`
  1195. - `"prompt"`: `object`
  1196. #### Request example
  1197. ```bash
  1198. curl --request PUT \
  1199. --url http://{address}/api/v1/chats/{chat_id} \
  1200. --header 'Content-Type: application/json' \
  1201. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1202. --data '
  1203. {
  1204. "name":"Test"
  1205. }'
  1206. ```
  1207. #### Parameters
  1208. - `chat_id`: (*Path parameter*)
  1209. The ID of the chat assistant to update.
  1210. - `"name"`: (*Body parameter*), `string`, *Required*
  1211. The revised name of the chat assistant.
  1212. - `"avatar"`: (*Body parameter*), `string`
  1213. Base64 encoding of the avatar.
  1214. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1215. The IDs of the associated datasets.
  1216. - `"llm"`: (*Body parameter*), `object`
  1217. 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:
  1218. - `"model_name"`, `string`
  1219. The chat model name. If not set, the user's default chat model will be used.
  1220. - `"temperature"`: `float`
  1221. 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`.
  1222. - `"top_p"`: `float`
  1223. 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`
  1224. - `"presence_penalty"`: `float`
  1225. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1226. - `"frequency penalty"`: `float`
  1227. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1228. - `"max_token"`: `integer`
  1229. The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
  1230. - `"prompt"`: (*Body parameter*), `object`
  1231. Instructions for the LLM to follow. A `prompt` object contains the following attributes:
  1232. - `"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`.
  1233. - `"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`.
  1234. - `"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`.
  1235. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1236. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1237. - All the variables in 'System' should be curly bracketed.
  1238. - The default value is `[{"key": "knowledge", "optional": true}]`
  1239. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1240. - `"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.
  1241. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1242. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1243. - `"prompt"`: `string` The prompt content.
  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",
  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 ",
  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 \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. ```