Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

http_api_reference.md 57KB

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