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.

http_api_reference.md 58KB

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