Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

http_api_reference.md 59KB

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