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 59KB

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