Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027
  1. # DRAFT! HTTP API Reference
  2. **THE API REFERENCES BELOW ARE STILL UNDER DEVELOPMENT.**
  3. ## Create dataset
  4. **POST** `/api/v1/dataset`
  5. Creates a dataset.
  6. ### Request
  7. - Method: POST
  8. - URL: `http://{address}/api/v1/dataset`
  9. - Headers:
  10. - `content-Type: application/json`
  11. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  12. - Body:
  13. - `"id"`: `string`
  14. - `"name"`: `string`
  15. - `"avatar"`: `string`
  16. - `"tenant_id"`: `string`
  17. - `"description"`: `string`
  18. - `"language"`: `string`
  19. - `"embedding_model"`: `string`
  20. - `"permission"`: `string`
  21. - `"document_count"`: `integer`
  22. - `"chunk_count"`: `integer`
  23. - `"parse_method"`: `string`
  24. - `"parser_config"`: `Dataset.ParserConfig`
  25. #### Request example
  26. ```bash
  27. # "id": id must not be provided.
  28. # "name": name is required and can't be duplicated.
  29. # "tenant_id": tenant_id must not be provided.
  30. # "embedding_model": embedding_model must not be provided.
  31. # "naive" means general.
  32. curl --request POST \
  33. --url http://{address}/api/v1/dataset \
  34. --header 'Content-Type: application/json' \
  35. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  36. --data '{
  37. "name": "test",
  38. "chunk_count": 0,
  39. "document_count": 0,
  40. "parse_method": "naive"
  41. }'
  42. ```
  43. #### Request parameters
  44. - `"id"`: (*Body parameter*)
  45. The ID of the created dataset used to uniquely identify different datasets.
  46. - If creating a dataset, `id` must not be provided.
  47. - `"name"`: (*Body parameter*)
  48. The name of the dataset, which must adhere to the following requirements:
  49. - Required when creating a dataset and must be unique.
  50. - If updating a dataset, `name` must still be unique.
  51. - `"avatar"`: (*Body parameter*)
  52. Base64 encoding of the avatar.
  53. - `"tenant_id"`: (*Body parameter*)
  54. The ID of the tenant associated with the dataset, used to link it with specific users.
  55. - If creating a dataset, `tenant_id` must not be provided.
  56. - If updating a dataset, `tenant_id` cannot be changed.
  57. - `"description"`: (*Body parameter*)
  58. The description of the dataset.
  59. - `"language"`: (*Body parameter*)
  60. The language setting for the dataset.
  61. - `"embedding_model"`: (*Body parameter*)
  62. Embedding model used in the dataset to generate vector embeddings.
  63. - If creating a dataset, `embedding_model` must not be provided.
  64. - If updating a dataset, `embedding_model` cannot be changed.
  65. - `"permission"`: (*Body parameter*)
  66. Specifies who can manipulate the dataset.
  67. - `"document_count"`: (*Body parameter*)
  68. Document count of the dataset.
  69. - If updating a dataset, `document_count` cannot be changed.
  70. - `"chunk_count"`: (*Body parameter*)
  71. Chunk count of the dataset.
  72. - If updating a dataset, `chunk_count` cannot be changed.
  73. - `"parse_method"`: (*Body parameter*)
  74. Parsing method of the dataset.
  75. - If updating `parse_method`, `chunk_count` must be greater than 0.
  76. - `"parser_config"`: (*Body parameter*)
  77. The configuration settings for the dataset parser.
  78. ### Response
  79. The successful response includes a JSON object like the following:
  80. ```json
  81. {
  82. "code": 0,
  83. "data": {
  84. "avatar": null,
  85. "chunk_count": 0,
  86. "create_date": "Thu, 10 Oct 2024 05:57:37 GMT",
  87. "create_time": 1728539857641,
  88. "created_by": "69736c5e723611efb51b0242ac120007",
  89. "description": null,
  90. "document_count": 0,
  91. "embedding_model": "BAAI/bge-large-zh-v1.5",
  92. "id": "8d73076886cc11ef8c270242ac120006",
  93. "language": "English",
  94. "name": "test_1",
  95. "parse_method": "naive",
  96. "parser_config": {
  97. "pages": [
  98. [
  99. 1,
  100. 1000000
  101. ]
  102. ]
  103. },
  104. "permission": "me",
  105. "similarity_threshold": 0.2,
  106. "status": "1",
  107. "tenant_id": "69736c5e723611efb51b0242ac120007",
  108. "token_num": 0,
  109. "update_date": "Thu, 10 Oct 2024 05:57:37 GMT",
  110. "update_time": 1728539857641,
  111. "vector_similarity_weight": 0.3
  112. }
  113. }
  114. ```
  115. - `"error_code"`: `integer`
  116. `0`: The operation succeeds.
  117. The error response includes a JSON object like the following:
  118. ```json
  119. {
  120. "code": 102,
  121. "message": "Duplicated knowledgebase name in creating dataset."
  122. }
  123. ```
  124. ## Delete datasets
  125. **DELETE** `/api/v1/dataset`
  126. Deletes datasets by ids.
  127. ### Request
  128. - Method: DELETE
  129. - URL: `http://{address}/api/v1/dataset`
  130. - Headers:
  131. - `content-Type: application/json`
  132. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  133. - Body:
  134. - `"ids"`: `List[string]`
  135. #### Request example
  136. ```bash
  137. # Either id or name must be provided, but not both.
  138. curl --request DELETE \
  139. --url http://{address}/api/v1/dataset \
  140. --header 'Content-Type: application/json' \
  141. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  142. --data '{
  143. "ids": ["test_1", "test_2"]
  144. }'
  145. ```
  146. #### Request parameters
  147. - `"ids"`: (*Body parameter*)
  148. Dataset IDs to delete.
  149. ### Response
  150. The successful response includes a JSON object like the following:
  151. ```json
  152. {
  153. "code": 0
  154. }
  155. ```
  156. - `"error_code"`: `integer`
  157. `0`: The operation succeeds.
  158. The error response includes a JSON object like the following:
  159. ```json
  160. {
  161. "code": 102,
  162. "message": "You don't own the dataset."
  163. }
  164. ```
  165. ## Update dataset
  166. **PUT** `/api/v1/dataset/{dataset_id}`
  167. Updates a dataset by its id.
  168. ### Request
  169. - Method: PUT
  170. - URL: `http://{address}/api/v1/dataset/{dataset_id}`
  171. - Headers:
  172. - `content-Type: application/json`
  173. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  174. - Body: (Refer to the "Create Dataset" for the complete structure of the request body.)
  175. #### Request example
  176. ```bash
  177. # "id": id is required.
  178. # "name": If you update name, it can't be duplicated.
  179. # "tenant_id": If you update tenant_id, it can't be changed
  180. # "embedding_model": If you update embedding_model, it can't be changed.
  181. # "chunk_count": If you update chunk_count, it can't be changed.
  182. # "document_count": If you update document_count, it can't be changed.
  183. # "parse_method": If you update parse_method, chunk_count must be 0.
  184. # "naive" means general.
  185. curl --request PUT \
  186. --url http://{address}/api/v1/dataset/{dataset_id} \
  187. --header 'Content-Type: application/json' \
  188. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  189. --data '{
  190. "name": "test",
  191. "tenant_id": "4fb0cd625f9311efba4a0242ac120006",
  192. "embedding_model": "BAAI/bge-zh-v1.5",
  193. "chunk_count": 0,
  194. "document_count": 0,
  195. "parse_method": "naive"
  196. }'
  197. ```
  198. #### Request parameters
  199. (Refer to the "Create Dataset" for the complete structure of the request parameters.)
  200. ### Response
  201. The successful response includes a JSON object like the following:
  202. ```json
  203. {
  204. "code": 0
  205. }
  206. ```
  207. - `"error_code"`: `integer`
  208. `0`: The operation succeeds.
  209. The error response includes a JSON object like the following:
  210. ```json
  211. {
  212. "code": 102,
  213. "message": "Can't change tenant_id."
  214. }
  215. ```
  216. ## List datasets
  217. **GET** `/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  218. List all datasets
  219. ### Request
  220. - Method: GET
  221. - URL: `http://{address}/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  222. - Headers:
  223. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  224. #### Request example
  225. ```bash
  226. # If no page parameter is passed, the default is 1
  227. # If no page_size parameter is passed, the default is 1024
  228. # If no order_by parameter is passed, the default is "create_time"
  229. # If no desc parameter is passed, the default is True
  230. curl --request GET \
  231. --url http://{address}/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  232. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  233. ```
  234. #### Request parameters
  235. - `path`: (*Path parameter*)
  236. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  237. - `path_size`: (*Path parameter*)
  238. The number of records to retrieve per page. This controls how many records will be included in each page.
  239. - `orderby`: (*Path parameter*)
  240. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  241. - `desc`: (*Path parameter*)
  242. A boolean flag indicating whether the sorting should be in descending order.
  243. - `name`: (*Path parameter*)
  244. Dataset name
  245. - `"id"`: (*Path parameter*)
  246. The ID of the dataset to be retrieved.
  247. - `"name"`: (*Path parameter*)
  248. The name of the dataset to be retrieved.
  249. ### Response
  250. The successful response includes a JSON object like the following:
  251. ```json
  252. {
  253. "code": 0,
  254. "data": [
  255. {
  256. "avatar": "",
  257. "chunk_count": 59,
  258. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  259. "create_time": 1726276357324,
  260. "created_by": "69736c5e723611efb51b0242ac120007",
  261. "description": null,
  262. "document_count": 1,
  263. "embedding_model": "BAAI/bge-large-zh-v1.5",
  264. "id": "6e211ee0723611efa10a0242ac120007",
  265. "language": "English",
  266. "name": "mysql",
  267. "parse_method": "knowledge_graph",
  268. "parser_config": {
  269. "chunk_token_num": 8192,
  270. "delimiter": "\\n!?;。;!?",
  271. "entity_types": [
  272. "organization",
  273. "person",
  274. "location",
  275. "event",
  276. "time"
  277. ]
  278. },
  279. "permission": "me",
  280. "similarity_threshold": 0.2,
  281. "status": "1",
  282. "tenant_id": "69736c5e723611efb51b0242ac120007",
  283. "token_num": 12744,
  284. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  285. "update_time": 1728533243536,
  286. "vector_similarity_weight": 0.3
  287. }
  288. ]
  289. }
  290. ```
  291. The error response includes a JSON object like the following:
  292. ```json
  293. {
  294. "code": 102,
  295. "message": "The dataset doesn't exist"
  296. }
  297. ```
  298. ## Upload files to a dataset
  299. **POST** `/api/v1/dataset/{dataset_id}/document`
  300. Uploads files to a dataset.
  301. ### Request
  302. - Method: POST
  303. - URL: `/api/v1/dataset/{dataset_id}/document`
  304. - Headers:
  305. - 'Content-Type: multipart/form-data'
  306. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  307. - Form:
  308. - 'file=@{FILE_PATH}'
  309. #### Request example
  310. ```bash
  311. curl --request POST \
  312. --url http://{address}/api/v1/dataset/{dataset_id}/document \
  313. --header 'Content-Type: multipart/form-data' \
  314. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  315. --form 'file=@./test.txt'
  316. ```
  317. #### Request parameters
  318. - `"dataset_id"`: (*Path parameter*)
  319. The dataset id
  320. - `"file"`: (*Body parameter*)
  321. The file to upload
  322. ### Response
  323. The successful response includes a JSON object like the following:
  324. ```json
  325. {
  326. "code": 0
  327. }
  328. ```
  329. - `"error_code"`: `integer`
  330. `0`: The operation succeeds.
  331. The error response includes a JSON object like the following:
  332. ```json
  333. {
  334. "code": 101,
  335. "message": "No file part!"
  336. }
  337. ```
  338. ## Delete files from a dataset
  339. **DELETE** `/api/v1/dataset/{dataset_id}/document `
  340. Delete files from a dataset
  341. ### Request
  342. - Method: DELETE
  343. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document`
  344. - Headers:
  345. - 'Content-Type: application/json'
  346. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  347. - Body:
  348. - `ids`:List[str]
  349. #### Request example
  350. ```bash
  351. curl --request DELETE \
  352. --url http://{address}/api/v1/dataset/{dataset_id}/document \
  353. --header 'Content-Type: application/json' \
  354. --header 'Authorization: {YOUR ACCESS TOKEN}' \
  355. --data '{
  356. "ids": ["id_1","id_2"]
  357. }'
  358. ```
  359. #### Request parameters
  360. - `"ids"`: (*Body parameter*)
  361. The ids of teh documents to be deleted
  362. ### Response
  363. The successful response includes a JSON object like the following:
  364. ```json
  365. {
  366. "code": 0
  367. }.
  368. ```
  369. - `"error_code"`: `integer`
  370. `0`: The operation succeeds.
  371. The error response includes a JSON object like the following:
  372. ```json
  373. {
  374. "code": 102,
  375. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  376. }
  377. ```
  378. ## Download a file from a dataset
  379. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}`
  380. Downloads a file from a dataset.
  381. ### Request
  382. - Method: GET
  383. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}`
  384. - Headers:
  385. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  386. - Output:
  387. - '{FILE_NAME}'
  388. #### Request example
  389. ```bash
  390. curl --request GET \
  391. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id} \
  392. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  393. --output ./ragflow.txt
  394. ```
  395. #### Request parameters
  396. - `"dataset_id"`: (*PATH parameter*)
  397. The dataset id
  398. - `"documents_id"`: (*PATH parameter*)
  399. The document id of the file.
  400. ### Response
  401. The successful response includes a text object like the following:
  402. ```text
  403. test_2.
  404. ```
  405. - `"error_code"`: `integer`
  406. `0`: The operation succeeds.
  407. The error response includes a JSON object like the following:
  408. ```json
  409. {
  410. "code": 102,
  411. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  412. }
  413. ```
  414. ## List files of a dataset
  415. **GET** `/api/v1/dataset/{dataset_id}/info?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}`
  416. List files to a dataset.
  417. ### Request
  418. - Method: GET
  419. - URL: `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name`
  420. - Headers:
  421. - `content-Type: application/json`
  422. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  423. #### Request example
  424. ```bash
  425. curl --request GET \
  426. --url http://{address}/api/v1/dataset/{dataset_id}/info?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id} \
  427. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  428. ```
  429. #### Request parameters
  430. - `"dataset_id"`: (*PATH parameter*)
  431. The dataset id
  432. - `offset`: (*Filter parameter*)
  433. The beginning number of records for paging.
  434. - `keywords`: (*Filter parameter*)
  435. The keywords matches the search key workds;
  436. - `limit`: (*Filter parameter*)
  437. Records number to return.
  438. - `orderby`: (*Filter parameter*)
  439. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  440. - `desc`: (*Filter parameter*)
  441. A boolean flag indicating whether the sorting should be in descending order.
  442. - `id`: (*Filter parameter*)
  443. The id of the document to be got.
  444. ### Response
  445. The successful response includes a JSON object like the following:
  446. ```json
  447. {
  448. "code": 0,
  449. "data": {
  450. "docs": [
  451. {
  452. "chunk_count": 0,
  453. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  454. "create_time": 1728897061948,
  455. "created_by": "69736c5e723611efb51b0242ac120007",
  456. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  457. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  458. "location": "Test_2.txt",
  459. "name": "Test_2.txt",
  460. "parser_config": {
  461. "chunk_token_count": 128,
  462. "delimiter": "\n!?。;!?",
  463. "layout_recognize": true,
  464. "task_page_size": 12
  465. },
  466. "parser_method": "naive",
  467. "process_begin_at": null,
  468. "process_duation": 0.0,
  469. "progress": 0.0,
  470. "progress_msg": "",
  471. "run": "0",
  472. "size": 7,
  473. "source_type": "local",
  474. "status": "1",
  475. "thumbnail": null,
  476. "token_count": 0,
  477. "type": "doc",
  478. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  479. "update_time": 1728897061948
  480. }
  481. ],
  482. "total": 1
  483. }
  484. }
  485. ```
  486. - `"error_code"`: `integer`
  487. `0`: The operation succeeds.
  488. The error response includes a JSON object like the following:
  489. ```json
  490. {
  491. "code": 102,
  492. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  493. }
  494. ```
  495. ## Update a file information in dataset
  496. **PUT** `/api/v1/dataset/{dataset_id}/info/{document_id}`
  497. Update a file in a dataset
  498. ### Request
  499. - Method: PUT
  500. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}`
  501. - Headers:
  502. - `content-Type: application/json`
  503. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  504. - Body:
  505. - `name`:`string`
  506. - `parser_method`:`string`
  507. - `parser_config`:`dict`
  508. #### Request example
  509. ```bash
  510. curl --request PUT \
  511. --url http://{address}/api/v1/dataset/{dataset_id}/info/{document_id} \
  512. --header 'Authorization: Bearer {YOUR_ACCESS TOKEN}' \
  513. --header 'Content-Type: application/json' \
  514. --data '{
  515. "name": "manual.txt",
  516. "parser_method": "manual",
  517. "parser_config": {"chunk_token_count": 128, "delimiter": "\n!?。;!?", "layout_recognize": true, "task_page_size": 12}
  518. }'
  519. ```
  520. #### Request parameters
  521. - `"parser_method"`: (*Body parameter*)
  522. Method used to parse the document.
  523. - `"parser_config"`: (*Body parameter*)
  524. Configuration object for the parser.
  525. - If the value is `None`, a dictionary with default values will be generated.
  526. - `"name"`: (*Body parameter*)
  527. Name or title of the document.
  528. ### Response
  529. The successful response includes a JSON object like the following:
  530. ```json
  531. {
  532. "code": 0
  533. }
  534. ```
  535. The error response includes a JSON object like the following:
  536. ```json
  537. {
  538. "code": 102,
  539. "message": "The dataset not own the document."
  540. }
  541. ```
  542. ## Parse files in dataset
  543. **POST** `/api/v1/dataset/{dataset_id}/chunk`
  544. Parse files into chunks in a dataset
  545. ### Request
  546. - Method: POST
  547. - URL: `http://{address}/api/v1/dataset/{dataset_id}/chunk `
  548. - Headers:
  549. - `content-Type: application/json`
  550. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  551. - Body:
  552. - `document_ids`:List[str]
  553. #### Request example
  554. ```bash
  555. curl --request POST \
  556. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  557. --header 'Content-Type: application/json' \
  558. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  559. --data '{"document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]}'
  560. ```
  561. #### Request parameters
  562. - `"dataset_id"`: (*Path parameter*)
  563. - `"document_ids"`:(*Body parameter*)
  564. The ids of the documents to be parsed
  565. ### Response
  566. The successful response includes a JSON object like the following:
  567. ```json
  568. {
  569. "code": 0
  570. }
  571. ```
  572. The error response includes a JSON object like the following:
  573. ```json
  574. {
  575. "code": 102,
  576. "message": "`document_ids` is required"
  577. }
  578. ```
  579. ## Stop file parsing
  580. **DELETE** `/api/v1/dataset/{dataset_id}/chunk`
  581. Stop file parsing
  582. ### Request
  583. - Method: DELETE
  584. - URL: `http://{address}/api/v1/dataset/{dataset_id}/chunk`
  585. - Headers:
  586. - `content-Type: application/json`
  587. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  588. - Body:
  589. - `document_ids`:List[str]
  590. #### Request example
  591. ```bash
  592. curl --request DELETE \
  593. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  594. --header 'Content-Type: application/json' \
  595. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  596. --data '{"document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]}'
  597. ```
  598. #### Request parameters
  599. - `"dataset_id"`: (*Path parameter*)
  600. - `"document_ids"`:(*Body parameter*)
  601. The ids of the documents to be parsed
  602. ### Response
  603. The successful response includes a JSON object like the following:
  604. ```json
  605. {
  606. "code": 0
  607. }
  608. ```
  609. The error response includes a JSON object like the following:
  610. ```json
  611. {
  612. "code": 102,
  613. "message": "`document_ids` is required"
  614. }
  615. ```
  616. ## Get document chunk list
  617. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk?keywords={keywords}&offset={offset}&limit={limit}&id={id}`
  618. Get document chunk list
  619. ### Request
  620. - Method: GET
  621. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk?keywords={keywords}&offset={offset}&limit={limit}&id={id}`
  622. - Headers:
  623. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  624. #### Request example
  625. ```bash
  626. curl --request GET \
  627. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk?keywords={keywords}&offset={offset}&limit={limit}&id={id} \
  628. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  629. ```
  630. #### Request parameters
  631. - `"dataset_id"`: (*Path parameter*)
  632. - `"document_id"`: (*Path parameter*)
  633. - `"offset"`(*Filter parameter*)
  634. The beginning number of records for paging.
  635. - `"keywords"`(*Filter parameter*)
  636. List chunks whose name has the given keywords
  637. - `"limit"`(*Filter parameter*)
  638. Records number to return
  639. - `"id"`(*Filter parameter*)
  640. The id of chunk to be got
  641. ### Response
  642. The successful response includes a JSON object like the following:
  643. ```json
  644. {
  645. "code": 0,
  646. "data": {
  647. "chunks": [],
  648. "doc": {
  649. "chunk_num": 0,
  650. "create_date": "Sun, 29 Sep 2024 03:47:29 GMT",
  651. "create_time": 1727581649216,
  652. "created_by": "69736c5e723611efb51b0242ac120007",
  653. "id": "8cb781ec7e1511ef98ac0242ac120006",
  654. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  655. "location": "明天的天气是晴天.txt",
  656. "name": "明天的天气是晴天.txt",
  657. "parser_config": {
  658. "pages": [
  659. [
  660. 1,
  661. 1000000
  662. ]
  663. ]
  664. },
  665. "parser_id": "naive",
  666. "process_begin_at": "Tue, 15 Oct 2024 10:23:51 GMT",
  667. "process_duation": 1435.37,
  668. "progress": 0.0370833,
  669. "progress_msg": "\nTask has been received.",
  670. "run": "1",
  671. "size": 24,
  672. "source_type": "local",
  673. "status": "1",
  674. "thumbnail": null,
  675. "token_num": 0,
  676. "type": "doc",
  677. "update_date": "Tue, 15 Oct 2024 10:47:46 GMT",
  678. "update_time": 1728989266371
  679. },
  680. "total": 0
  681. }
  682. }
  683. ```
  684. The error response includes a JSON object like the following:
  685. ```json
  686. {
  687. "code": 102,
  688. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  689. }
  690. ```
  691. ## Delete document chunks
  692. **DELETE** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  693. Delete document chunks
  694. ### Request
  695. - Method: DELETE
  696. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  697. - Headers:
  698. - `content-Type: application/json`
  699. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  700. - Body:
  701. - `chunk_ids`:List[str]
  702. #### Request example
  703. ```bash
  704. curl --request DELETE \
  705. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  706. --header 'Content-Type: application/json' \
  707. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  708. --data '{
  709. "chunk_ids": ["test_1", "test_2"]
  710. }'
  711. ```
  712. #### Request parameters
  713. - `"chunk_ids"`:(*Body parameter*)
  714. The chunks of the document to be deleted
  715. ### Response
  716. Success
  717. ```json
  718. {
  719. "code": 0
  720. }
  721. ```
  722. Error
  723. ```json
  724. {
  725. "code": 102,
  726. "message": "`chunk_ids` is required"
  727. }
  728. ```
  729. ## Update document chunk
  730. **PUT** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk/{chunk_id}`
  731. Update document chunk
  732. ### Request
  733. - Method: PUT
  734. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk/{chunk_id}`
  735. - Headers:
  736. - `content-Type: application/json`
  737. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  738. - Body:
  739. - `content`:str
  740. - `important_keywords`:str
  741. - `available`:int
  742. #### Request example
  743. ```bash
  744. curl --request PUT \
  745. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk/{chunk_id} \
  746. --header 'Content-Type: application/json' \
  747. --header 'Authorization: {YOUR_ACCESS_TOKEN}' \
  748. --data '{
  749. "content": "ragflow123",
  750. "important_keywords": [],
  751. }'
  752. ```
  753. #### Request parameters
  754. - `"content"`:(*Body parameter*)
  755. Contains the main text or information of the chunk.
  756. - `"important_keywords"`:(*Body parameter*)
  757. list the key terms or phrases that are significant or central to the chunk's content.
  758. - `"available"`:(*Body parameter*)
  759. Indicating the availability status, 0 means unavailable and 1 means available.
  760. ### Response
  761. Success
  762. ```json
  763. {
  764. "code": 0
  765. }
  766. ```
  767. Error
  768. ```json
  769. {
  770. "code": 102,
  771. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  772. }
  773. ```
  774. ## Insert document chunks
  775. **POST** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  776. Insert document chunks
  777. ### Request
  778. - Method: POST
  779. - URL: `http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  780. - Headers:
  781. - `content-Type: application/json`
  782. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  783. - Body:
  784. - `content`: str
  785. - `important_keywords`:List[str]
  786. #### Request example
  787. ```bash
  788. curl --request POST \
  789. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  790. --header 'Content-Type: application/json' \
  791. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  792. --data '{
  793. "content": "ragflow content"
  794. }'
  795. ```
  796. #### Request parameters
  797. - `content`:(*Body parameter*)
  798. Contains the main text or information of the chunk.
  799. - `important_keywords`(*Body parameter*)
  800. list the key terms or phrases that are significant or central to the chunk's content.
  801. ### Response
  802. Success
  803. ```json
  804. {
  805. "code": 0,
  806. "data": {
  807. "chunk": {
  808. "content": "ragflow content",
  809. "create_time": "2024-10-16 08:05:04",
  810. "create_timestamp": 1729065904.581025,
  811. "dataset_id": [
  812. "c7ee74067a2c11efb21c0242ac120006"
  813. ],
  814. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  815. "id": "d78435d142bd5cf6704da62c778795c5",
  816. "important_keywords": []
  817. }
  818. }
  819. }
  820. ```
  821. Error
  822. ```json
  823. {
  824. "code": 102,
  825. "message": "`content` is required"
  826. }
  827. ```
  828. ## Dataset retrieval test
  829. **GET** `/api/v1/retrieval`
  830. Retrieval test of a dataset
  831. ### Request
  832. - Method: POST
  833. - URL: `http://{address}/api/v1/retrieval`
  834. - Headers:
  835. - `content-Type: application/json`
  836. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  837. - Body:
  838. - `question`: str
  839. - `datasets`: List[str]
  840. - `documents`: List[str]
  841. - `offset`: int
  842. - `limit`: int
  843. - `similarity_threshold`: float
  844. - `vector_similarity_weight`: float
  845. - `top_k`: int
  846. - `rerank_id`: string
  847. - `keyword`: bool
  848. - `highlight`: bool
  849. #### Request example
  850. ```bash
  851. curl --request POST \
  852. --url http://{address}/api/v1/retrieval \
  853. --header 'Content-Type: application/json' \
  854. --header 'Authorization: {YOUR_ACCESS_TOKEN}' \
  855. --data '{
  856. "question": "What is advantage of ragflow?",
  857. "datasets": [
  858. "b2a62730759d11ef987d0242ac120004"
  859. ],
  860. "documents": [
  861. "77df9ef4759a11ef8bdd0242ac120004"
  862. ]
  863. }'
  864. ```
  865. #### Request parameter
  866. - `"question"`: (*Body parameter*)
  867. User's question, search keywords
  868. `""`
  869. - `"datasets"`: (*Body parameter*)
  870. The scope of datasets
  871. `None`
  872. - `"documents"`: (*Body parameter*)
  873. The scope of document. `None` means no limitation
  874. `None`
  875. - `"offset"`: (*Body parameter*)
  876. The beginning point of retrieved records
  877. `1`
  878. - `"limit"`: (*Body parameter*)
  879. The maximum number of records needed to return
  880. `30`
  881. - `"similarity_threshold"`: (*Body parameter*)
  882. The minimum similarity score
  883. `0.2`
  884. - `"vector_similarity_weight"`: (*Body parameter*)
  885. The weight of vector cosine similarity, `1 - x` is the term similarity weight
  886. `0.3`
  887. - `"top_k"`: (*Body parameter*)
  888. Number of records engaged in vector cosine computation
  889. `1024`
  890. - `"rerank_id"`: (*Body parameter*)
  891. ID of the rerank model
  892. `None`
  893. - `"keyword"`: (*Body parameter*)
  894. Whether keyword-based matching is enabled
  895. `False`
  896. - `"highlight"`: (*Body parameter*)
  897. Whether to enable highlighting of matched terms in the results
  898. `False`
  899. ### Response
  900. Success
  901. ```json
  902. {
  903. "code": 0,
  904. "data": {
  905. "chunks": [
  906. {
  907. "content": "ragflow content",
  908. "content_ltks": "ragflow content",
  909. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  910. "document_keyword": "1.txt",
  911. "highlight": "<em>ragflow</em> content",
  912. "id": "d78435d142bd5cf6704da62c778795c5",
  913. "img_id": "",
  914. "important_keywords": [
  915. ""
  916. ],
  917. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  918. "positions": [
  919. ""
  920. ],
  921. "similarity": 0.9669436601210759,
  922. "term_similarity": 1.0,
  923. "vector_similarity": 0.8898122004035864
  924. }
  925. ],
  926. "doc_aggs": [
  927. {
  928. "count": 1,
  929. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  930. "doc_name": "1.txt"
  931. }
  932. ],
  933. "total": 1
  934. }
  935. }
  936. ```
  937. Error
  938. ```json
  939. {
  940. "code": 102,
  941. "message": "`datasets` is required."
  942. }
  943. ```
  944. ## Create chat
  945. **POST** `/api/v1/chat`
  946. Create a chat
  947. ### Request
  948. - Method: POST
  949. - URL: `http://{address}/api/v1/chat`
  950. - Headers:
  951. - `content-Type: application/json`
  952. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  953. - Body:
  954. - `"name"`: `string`
  955. - `"avatar"`: `string`
  956. - `"knowledgebases"`: `List[DataSet]`
  957. - `"id"`: `string`
  958. - `"llm"`: `LLM`
  959. - `"prompt"`: `Prompt`
  960. #### Request example
  961. ```shell
  962. curl --request POST \
  963. --url http://{address}/api/v1/chat \
  964. --header 'Content-Type: application/json' \
  965. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  966. --data-binary '{
  967. "knowledgebases": [
  968. {
  969. "avatar": null,
  970. "chunk_count": 0,
  971. "description": null,
  972. "document_count": 0,
  973. "embedding_model": "",
  974. "id": "0b2cbc8c877f11ef89070242ac120005",
  975. "language": "English",
  976. "name": "Test_assistant",
  977. "parse_method": "naive",
  978. "parser_config": {
  979. "pages": [
  980. [
  981. 1,
  982. 1000000
  983. ]
  984. ]
  985. },
  986. "permission": "me",
  987. "tenant_id": "4fb0cd625f9311efba4a0242ac120006"
  988. }
  989. ],
  990. "name":"new_chat_1"
  991. }'
  992. ```
  993. #### Request parameters
  994. - `"name"`: (*Body parameter*)
  995. The name of the created chat.
  996. - `"assistant"`
  997. - `"avatar"`: (*Body parameter*)
  998. The icon of the created chat.
  999. - `"path"`
  1000. - `"knowledgebases"`: (*Body parameter*)
  1001. Select knowledgebases associated.
  1002. - `["kb1"]`
  1003. - `"id"`: (*Body parameter*)
  1004. The id of the created chat.
  1005. - `""`
  1006. - `"llm"`: (*Body parameter*)
  1007. The LLM of the created chat.
  1008. - If the value is `None`, a dictionary with default values will be generated.
  1009. - `"prompt"`: (*Body parameter*)
  1010. The prompt of the created chat.
  1011. - If the value is `None`, a dictionary with default values will be generated.
  1012. ---
  1013. ##### Chat.LLM parameters:
  1014. - `"model_name"`: (*Body parameter*)
  1015. Large language chat model.
  1016. - If it is `None`, it will return the user's default model.
  1017. - `"temperature"`: (*Body parameter*)
  1018. Controls the randomness of predictions by the model. A lower temperature makes the model more confident, while a higher temperature makes it more creative and diverse.
  1019. - `0.1`
  1020. - `"top_p"`: (*Body parameter*)
  1021. Also known as "nucleus sampling," it focuses on the most likely words, cutting off the less probable ones.
  1022. - `0.3`
  1023. - `"presence_penalty"`: (*Body parameter*)
  1024. Discourages the model from repeating the same information by penalizing repeated content.
  1025. - `0.4`
  1026. - `"frequency_penalty"`: (*Body parameter*)
  1027. Reduces the model’s tendency to repeat words frequently.
  1028. - `0.7`
  1029. - `"max_tokens"`: (*Body parameter*)
  1030. Sets the maximum length of the model’s output, measured in tokens (words or pieces of words).
  1031. - `512`
  1032. ---
  1033. ##### Chat.Prompt parameters:
  1034. - `"similarity_threshold"`: (*Body parameter*)
  1035. Filters out chunks with similarity below this threshold.
  1036. - `0.2`
  1037. - `"keywords_similarity_weight"`: (*Body parameter*)
  1038. Weighted keywords similarity and vector cosine similarity; the sum of weights is 1.0.
  1039. - `0.7`
  1040. - `"top_n"`: (*Body parameter*)
  1041. Only the top N chunks above the similarity threshold will be fed to LLMs.
  1042. - `8`
  1043. - `"variables"`: (*Body parameter*)
  1044. Variables help with different chat strategies by filling in the 'System' part of the prompt.
  1045. - `[{"key": "knowledge", "optional": True}]`
  1046. - `"rerank_model"`: (*Body parameter*)
  1047. If empty, it uses vector cosine similarity; otherwise, it uses rerank score.
  1048. - `""`
  1049. - `"empty_response"`: (*Body parameter*)
  1050. If nothing is retrieved, this will be used as the response. Leave blank if LLM should provide its own opinion.
  1051. - `None`
  1052. - `"opener"`: (*Body parameter*)
  1053. The welcome message for clients.
  1054. - `"Hi! I'm your assistant, what can I do for you?"`
  1055. - `"show_quote"`: (*Body parameter*)
  1056. Indicates whether the source of the original text should be displayed.
  1057. - `True`
  1058. - `"prompt"`: (*Body parameter*)
  1059. Instructions for LLM to follow when answering questions, such as character design or answer length.
  1060. - `"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. Here is the knowledge base: {knowledge} The above is the knowledge base."`
  1061. ### Response
  1062. Success:
  1063. ```json
  1064. {
  1065. "code": 0,
  1066. "data": {
  1067. "avatar": "",
  1068. "create_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  1069. "create_time": 1728617004635,
  1070. "description": "A helpful Assistant",
  1071. "do_refer": "1",
  1072. "id": "2ca4b22e878011ef88fe0242ac120005",
  1073. "knowledgebases": [
  1074. {
  1075. "avatar": null,
  1076. "chunk_count": 0,
  1077. "description": null,
  1078. "document_count": 0,
  1079. "embedding_model": "",
  1080. "id": "0b2cbc8c877f11ef89070242ac120005",
  1081. "language": "English",
  1082. "name": "Test_assistant",
  1083. "parse_method": "naive",
  1084. "parser_config": {
  1085. "pages": [
  1086. [
  1087. 1,
  1088. 1000000
  1089. ]
  1090. ]
  1091. },
  1092. "permission": "me",
  1093. "tenant_id": "4fb0cd625f9311efba4a0242ac120006"
  1094. }
  1095. ],
  1096. "language": "English",
  1097. "llm": {
  1098. "frequency_penalty": 0.7,
  1099. "max_tokens": 512,
  1100. "model_name": "deepseek-chat___OpenAI-API@OpenAI-API-Compatible",
  1101. "presence_penalty": 0.4,
  1102. "temperature": 0.1,
  1103. "top_p": 0.3
  1104. },
  1105. "name": "new_chat_1",
  1106. "prompt": {
  1107. "empty_response": "Sorry! 知识库中未找到相关内容!",
  1108. "keywords_similarity_weight": 0.3,
  1109. "opener": "您好,我是您的助手小樱,长得可爱又善良,can I help you?",
  1110. "prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。",
  1111. "rerank_model": "",
  1112. "similarity_threshold": 0.2,
  1113. "top_n": 6,
  1114. "variables": [
  1115. {
  1116. "key": "knowledge",
  1117. "optional": false
  1118. }
  1119. ]
  1120. },
  1121. "prompt_type": "simple",
  1122. "status": "1",
  1123. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1124. "top_k": 1024,
  1125. "update_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  1126. "update_time": 1728617004635
  1127. }
  1128. }
  1129. ```
  1130. Error:
  1131. ```json
  1132. {
  1133. "code": 102,
  1134. "message": "Duplicated chat name in creating dataset."
  1135. }
  1136. ```
  1137. ## Update chat
  1138. **PUT** `/api/v1/chat/{chat_id}`
  1139. Update a chat
  1140. ### Request
  1141. - Method: PUT
  1142. - URL: `http://{address}/api/v1/chat/{chat_id}`
  1143. - Headers:
  1144. - `content-Type: application/json`
  1145. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1146. - Body: (Refer to the "Create chat" for the complete structure of the request body.)
  1147. #### Request example
  1148. ```bash
  1149. curl --request PUT \
  1150. --url http://{address}/api/v1/chat/{chat_id} \
  1151. --header 'Content-Type: application/json' \
  1152. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1153. --data '{
  1154. "name":"Test"
  1155. }'
  1156. ```
  1157. #### Parameters
  1158. (Refer to the "Create chat" for the complete structure of the request parameters.)
  1159. ### Response
  1160. Success
  1161. ```json
  1162. {
  1163. "code": 0
  1164. }
  1165. ```
  1166. Error
  1167. ```json
  1168. {
  1169. "code": 102,
  1170. "message": "Duplicated chat name in updating dataset."
  1171. }
  1172. ```
  1173. ## Delete chats
  1174. **DELETE** `/api/v1/chat`
  1175. Delete chats
  1176. ### Request
  1177. - Method: DELETE
  1178. - URL: `http://{address}/api/v1/chat`
  1179. - Headers:
  1180. - `content-Type: application/json`
  1181. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1182. - Body:
  1183. - `ids`: List[string]
  1184. #### Request example
  1185. ```bash
  1186. # Either id or name must be provided, but not both.
  1187. curl --request DELETE \
  1188. --url http://{address}/api/v1/chat \
  1189. --header 'Content-Type: application/json' \
  1190. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1191. --data '{
  1192. "ids": ["test_1", "test_2"]
  1193. }'
  1194. }'
  1195. ```
  1196. #### Request parameters:
  1197. - `"ids"`: (*Body parameter*)
  1198. IDs of the chats to be deleted.
  1199. - `None`
  1200. ### Response
  1201. Success
  1202. ```json
  1203. {
  1204. "code": 0
  1205. }
  1206. ```
  1207. Error
  1208. ```json
  1209. {
  1210. "code": 102,
  1211. "message": "ids are required"
  1212. }
  1213. ```
  1214. ## List chats
  1215. **GET** `/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1216. List chats based on filter criteria.
  1217. ### Request
  1218. - Method: GET
  1219. - URL: `http://{address}/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1220. - Headers:
  1221. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1222. #### Request example
  1223. ```bash
  1224. curl --request GET \
  1225. --url http://{address}/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1226. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1227. ```
  1228. #### Request parameters
  1229. - `"page"`: (*Path parameter*)
  1230. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  1231. - `1`
  1232. - `"page_size"`: (*Path parameter*)
  1233. The number of records to retrieve per page. This controls how many records will be included in each page.
  1234. - `1024`
  1235. - `"orderby"`: (*Path parameter*)
  1236. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  1237. - `"create_time"`
  1238. - `"desc"`: (*Path parameter*)
  1239. A boolean flag indicating whether the sorting should be in descending order.
  1240. - `True`
  1241. - `"id"`: (*Path parameter*)
  1242. The ID of the chat to be retrieved.
  1243. - `None`
  1244. - `"name"`: (*Path parameter*)
  1245. The name of the chat to be retrieved.
  1246. - `None`
  1247. ### Response
  1248. Success
  1249. ```json
  1250. {
  1251. "code": 0,
  1252. "data": [
  1253. {
  1254. "avatar": "",
  1255. "create_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  1256. "create_time": 1728617004635,
  1257. "description": "A helpful Assistant",
  1258. "do_refer": "1",
  1259. "id": "2ca4b22e878011ef88fe0242ac120005",
  1260. "knowledgebases": [
  1261. {
  1262. "avatar": "",
  1263. "chunk_num": 0,
  1264. "create_date": "Fri, 11 Oct 2024 03:15:18 GMT",
  1265. "create_time": 1728616518986,
  1266. "created_by": "69736c5e723611efb51b0242ac120007",
  1267. "description": "",
  1268. "doc_num": 0,
  1269. "embd_id": "BAAI/bge-large-zh-v1.5",
  1270. "id": "0b2cbc8c877f11ef89070242ac120005",
  1271. "language": "English",
  1272. "name": "test_delete_chat",
  1273. "parser_config": {
  1274. "chunk_token_count": 128,
  1275. "delimiter": "\n!?。;!?",
  1276. "layout_recognize": true,
  1277. "task_page_size": 12
  1278. },
  1279. "parser_id": "naive",
  1280. "permission": "me",
  1281. "similarity_threshold": 0.2,
  1282. "status": "1",
  1283. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1284. "token_num": 0,
  1285. "update_date": "Fri, 11 Oct 2024 04:01:31 GMT",
  1286. "update_time": 1728619291228,
  1287. "vector_similarity_weight": 0.3
  1288. }
  1289. ],
  1290. "language": "English",
  1291. "llm": {
  1292. "frequency_penalty": 0.7,
  1293. "max_tokens": 512,
  1294. "model_name": "deepseek-chat___OpenAI-API@OpenAI-API-Compatible",
  1295. "presence_penalty": 0.4,
  1296. "temperature": 0.1,
  1297. "top_p": 0.3
  1298. },
  1299. "name": "Test",
  1300. "prompt": {
  1301. "empty_response": "Sorry! 知识库中未找到相关内容!",
  1302. "keywords_similarity_weight": 0.3,
  1303. "opener": "您好,我是您的助手小樱,长得可爱又善良,can I help you?",
  1304. "prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。",
  1305. "rerank_model": "",
  1306. "similarity_threshold": 0.2,
  1307. "top_n": 6,
  1308. "variables": [
  1309. {
  1310. "key": "knowledge",
  1311. "optional": false
  1312. }
  1313. ]
  1314. },
  1315. "prompt_type": "simple",
  1316. "status": "1",
  1317. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1318. "top_k": 1024,
  1319. "update_date": "Fri, 11 Oct 2024 03:47:58 GMT",
  1320. "update_time": 1728618478392
  1321. }
  1322. ]
  1323. }
  1324. ```
  1325. Error
  1326. ```json
  1327. {
  1328. "code": 102,
  1329. "message": "The chat doesn't exist"
  1330. }
  1331. ```
  1332. ## Create a chat session
  1333. **POST** `/api/v1/chat/{chat_id}/session`
  1334. Create a chat session
  1335. ### Request
  1336. - Method: POST
  1337. - URL: `http://{address}/api/v1/chat/{chat_id}/session`
  1338. - Headers:
  1339. - `content-Type: application/json`
  1340. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1341. - Body:
  1342. - name: `string`
  1343. #### Request example
  1344. ```bash
  1345. curl --request POST \
  1346. --url http://{address}/api/v1/chat/{chat_id}/session \
  1347. --header 'Content-Type: application/json' \
  1348. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1349. --data '{
  1350. "name": "new session"
  1351. }'
  1352. ```
  1353. #### Request parameters
  1354. - `"id"`: (*Body parameter*)
  1355. The ID of the created session used to identify different sessions.
  1356. - `None`
  1357. - `id` cannot be provided when creating.
  1358. - `"name"`: (*Body parameter*)
  1359. The name of the created session.
  1360. - `"New session"`
  1361. - `"messages"`: (*Body parameter*)
  1362. The messages of the created session.
  1363. - `[{"role": "assistant", "content": "Hi! I am your assistant, can I help you?"}]`
  1364. - `messages` cannot be provided when creating.
  1365. - `"chat_id"`: (*Path parameter*)
  1366. The ID of the associated chat.
  1367. - `""`
  1368. - `chat_id` cannot be changed.
  1369. ### Response
  1370. Success
  1371. ```json
  1372. {
  1373. "code": 0,
  1374. "data": {
  1375. "chat_id": "2ca4b22e878011ef88fe0242ac120005",
  1376. "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1377. "create_time": 1728636374571,
  1378. "id": "4606b4ec87ad11efbc4f0242ac120006",
  1379. "messages": [
  1380. {
  1381. "content": "Hi! I am your assistant,can I help you?",
  1382. "role": "assistant"
  1383. }
  1384. ],
  1385. "name": "new session",
  1386. "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1387. "update_time": 1728636374571
  1388. }
  1389. }
  1390. ```
  1391. Error
  1392. ```json
  1393. {
  1394. "code": 102,
  1395. "message": "Name can not be empty."
  1396. }
  1397. ```
  1398. ## List the sessions of a chat
  1399. **GET** `/api/v1/chat/{chat_id}/session?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1400. List all sessions under the chat based on the filtering criteria.
  1401. ### Request
  1402. - Method: GET
  1403. - URL: `http://{address}/api/v1/chat/{chat_id}/session?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1404. - Headers:
  1405. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1406. #### Request example
  1407. ```bash
  1408. curl --request GET \
  1409. --url http://{address}/api/v1/chat/{chat_id}/session?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1410. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1411. ```
  1412. #### Request Parameters
  1413. - `"page"`: (*Path parameter*)
  1414. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  1415. - `1`
  1416. - `"page_size"`: (*Path parameter*)
  1417. The number of records to retrieve per page. This controls how many records will be included in each page.
  1418. - `1024`
  1419. - `"orderby"`: (*Path parameter*)
  1420. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  1421. - `"create_time"`
  1422. - `"desc"`: (*Path parameter*)
  1423. A boolean flag indicating whether the sorting should be in descending order.
  1424. - `True`
  1425. - `"id"`: (*Path parameter*)
  1426. The ID of the session to be retrieved.
  1427. - `None`
  1428. - `"name"`: (*Path parameter*)
  1429. The name of the session to be retrieved.
  1430. - `None`
  1431. ### Response
  1432. Success
  1433. ```json
  1434. {
  1435. "code": 0,
  1436. "data": [
  1437. {
  1438. "chat": "2ca4b22e878011ef88fe0242ac120005",
  1439. "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1440. "create_time": 1728636403974,
  1441. "id": "578d541e87ad11ef96b90242ac120006",
  1442. "messages": [
  1443. {
  1444. "content": "Hi! I am your assistant,can I help you?",
  1445. "role": "assistant"
  1446. }
  1447. ],
  1448. "name": "new session",
  1449. "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1450. "update_time": 1728636403974
  1451. }
  1452. ]
  1453. }
  1454. ```
  1455. Error
  1456. ```json
  1457. {
  1458. "code": 102,
  1459. "message": "The session doesn't exist"
  1460. }
  1461. ```
  1462. ## Delete chat sessions
  1463. **DELETE** `/api/v1/chat/{chat_id}/session`
  1464. Delete chat sessions
  1465. ### Request
  1466. - Method: DELETE
  1467. - URL: `http://{address}/api/v1/chat/{chat_id}/session`
  1468. - Headers:
  1469. - `content-Type: application/json`
  1470. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1471. - Body:
  1472. - `ids`: List[string]
  1473. #### Request example
  1474. ```bash
  1475. # Either id or name must be provided, but not both.
  1476. curl --request DELETE \
  1477. --url http://{address}/api/v1/chat/{chat_id}/session \
  1478. --header 'Content-Type: application/json' \
  1479. --header 'Authorization: Bear {YOUR_ACCESS_TOKEN}' \
  1480. --data '{
  1481. "ids": ["test_1", "test_2"]
  1482. }'
  1483. ```
  1484. #### Request Parameters
  1485. - `ids`: (*Body Parameter*)
  1486. IDs of the sessions to be deleted.
  1487. - `None`
  1488. ### Response
  1489. Success
  1490. ```json
  1491. {
  1492. "code": 0
  1493. }
  1494. ```
  1495. Error
  1496. ```json
  1497. {
  1498. "code": 102,
  1499. "message": "The chat doesn't own the session"
  1500. }
  1501. ```
  1502. ## Update a chat session
  1503. **PUT** `/api/v1/chat/{chat_id}/session/{session_id}`
  1504. Update a chat session
  1505. ### Request
  1506. - Method: PUT
  1507. - URL: `http://{address}/api/v1/chat/{chat_id}/session/{session_id}`
  1508. - Headers:
  1509. - `content-Type: application/json`
  1510. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1511. - Body:
  1512. - `name`: string
  1513. #### Request example
  1514. ```bash
  1515. curl --request PUT \
  1516. --url http://{address}/api/v1/chat/{chat_id}/session/{session_id} \
  1517. --header 'Content-Type: application/json' \
  1518. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1519. --data '{
  1520. "name": "Updated session"
  1521. }'
  1522. ```
  1523. #### Request Parameter
  1524. - `name`:(*Body Parameter)
  1525. The name of the created session.
  1526. - `None`
  1527. ### Response
  1528. Success
  1529. ```json
  1530. {
  1531. "code": 0
  1532. }
  1533. ```
  1534. Error
  1535. ```json
  1536. {
  1537. "code": 102,
  1538. "message": "Name can not be empty."
  1539. }
  1540. ```
  1541. ## Chat with a chat session
  1542. **POST** `/api/v1/chat/{chat_id}/completion`
  1543. Chat with a chat session
  1544. ### Request
  1545. - Method: POST
  1546. - URL: `http://{address} /api/v1/chat/{chat_id}/completion`
  1547. - Headers:
  1548. - `content-Type: application/json`
  1549. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1550. - Body:
  1551. - `question`: string
  1552. - `stream`: bool
  1553. - `session_id`: str
  1554. #### Request example
  1555. ```bash
  1556. curl --request POST \
  1557. --url http://{address} /api/v1/chat/{chat_id}/completion \
  1558. --header 'Content-Type: application/json' \
  1559. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1560. --data-binary '{
  1561. "question": "你好!",
  1562. "stream": true
  1563. }'
  1564. ```
  1565. #### Request Parameters
  1566. - `question`:(*Body Parameter*)
  1567. The question you want to ask.
  1568. - question is required.
  1569. `None`
  1570. - `stream`: (*Body Parameter*)
  1571. The approach of streaming text generation.
  1572. `False`
  1573. - `session_id`: (*Body Parameter*)
  1574. The id of session.If not provided, a new session will be generated.
  1575. ### Response
  1576. Success
  1577. ```json
  1578. data: {
  1579. "code": 0,
  1580. "data": {
  1581. "answer": "您好!有什么具体的问题或者需要的帮助",
  1582. "reference": {},
  1583. "audio_binary": null,
  1584. "id": "31153052-7bac-4741-a513-ed07d853f29e"
  1585. }
  1586. }
  1587. data: {
  1588. "code": 0,
  1589. "data": {
  1590. "answer": "您好!有什么具体的问题或者需要的帮助可以告诉我吗?我在这里是为了帮助",
  1591. "reference": {},
  1592. "audio_binary": null,
  1593. "id": "31153052-7bac-4741-a513-ed07d853f29e"
  1594. }
  1595. }
  1596. data: {
  1597. "code": 0,
  1598. "data": {
  1599. "answer": "您好!有什么具体的问题或者需要的帮助可以告诉我吗?我在这里是为了帮助您的。如果您有任何疑问或是需要获取",
  1600. "reference": {},
  1601. "audio_binary": null,
  1602. "id": "31153052-7bac-4741-a513-ed07d853f29e"
  1603. }
  1604. }
  1605. data: {
  1606. "code": 0,
  1607. "data": {
  1608. "answer": "您好!有什么具体的问题或者需要的帮助可以告诉我吗?我在这里是为了帮助您的。如果您有任何疑问或是需要获取某些信息,请随时提出。",
  1609. "reference": {},
  1610. "audio_binary": null,
  1611. "id": "31153052-7bac-4741-a513-ed07d853f29e"
  1612. }
  1613. }
  1614. data: {
  1615. "code": 0,
  1616. "data": {
  1617. "answer": "您好!有什么具体的问题或者需要的帮助可以告诉我吗 ##0$$?我在这里是为了帮助您的。如果您有任何疑问或是需要获取某些信息,请随时提出。",
  1618. "reference": {
  1619. "total": 19,
  1620. "chunks": [
  1621. {
  1622. "chunk_id": "9d87f9d70a0d8a7565694a81fd4c5d5f",
  1623. "content_ltks": "当所有知识库内容都与问题无关时 ,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\r\n以下是知识库:\r\n{knowledg}\r\n以上是知识库\r\n\"\"\"\r\n 1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\n总结\r\n通过上面的介绍,可以对开源的 ragflow有了一个大致的了解,与前面的有道qanyth整体流程还是比较类似的。 ",
  1624. "content_with_weight": "当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\r\n 以下是知识库:\r\n {knowledge}\r\n 以上是知识库\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n总结\r\n通过上面的介绍,可以对开源的 RagFlow 有了一个大致的了解,与前面的 有道 QAnything 整体流程还是比较类似的。",
  1625. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1626. "docnm_kwd": "1.txt",
  1627. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1628. "important_kwd": [],
  1629. "img_id": "",
  1630. "similarity": 0.38337178633282265,
  1631. "vector_similarity": 0.3321336754679629,
  1632. "term_similarity": 0.4053309767034769,
  1633. "positions": [
  1634. ""
  1635. ]
  1636. },
  1637. {
  1638. "chunk_id": "895d34de762e674b43e8613c6fb54c6d",
  1639. "content_ltks": "\r\n\r\n实际内容可能会超过大模型的输入token数量,因此在调用大模型前会调用api/db/servic/dialog_service.py文件中 messag_fit_in ()根据大模型可用的 token数量进行过滤。这部分与有道的 qanyth的实现大同小异,就不额外展开了。\r\n\r\n将检索的内容,历史聊天记录以及问题构造为 prompt ,即可作为大模型的输入了 ,默认的英文prompt如下所示:\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\n对应的中文prompt如下所示:\r\n\r\n\"\"\"\r\n你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。 ",
  1640. "content_with_weight": "\r\n\r\n实际内容可能会超过大模型的输入 token 数量,因此在调用大模型前会调用 api/db/services/dialog_service.py 文件中 message_fit_in() 根据大模型可用的 token 数量进行过滤。这部分与有道的 QAnything 的实现大同小异,就不额外展开了。\r\n\r\n将检索的内容,历史聊天记录以及问题构造为 prompt,即可作为大模型的输入了,默认的英文 prompt 如下所示:\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\n对应的中文 prompt 如下所示:\r\n\r\n\"\"\"\r\n你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。",
  1641. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1642. "docnm_kwd": "1.txt",
  1643. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1644. "important_kwd": [],
  1645. "img_id": "",
  1646. "similarity": 0.2788204323926715,
  1647. "vector_similarity": 0.35489427679953667,
  1648. "term_similarity": 0.2462173562183008,
  1649. "positions": [
  1650. ""
  1651. ]
  1652. }
  1653. ],
  1654. "doc_aggs": [
  1655. {
  1656. "doc_name": "1.txt",
  1657. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1658. "count": 2
  1659. }
  1660. ]
  1661. },
  1662. "prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n 当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\r\n 以下是知识库:\r\n {knowledge}\r\n 以上是知识库\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n总结\r\n通过上面的介绍,可以对开源的 RagFlow 有了一个大致的了解,与前面的 有道 QAnything 整体流程还是比较类似的。\n\n------\n\n\r\n\r\n实际内容可能会超过大模型的输入 token 数量,因此在调用大模型前会调用 api/db/services/dialog_service.py 文件中 message_fit_in() 根据大模型可用的 token 数量进行过滤。这部分与有道的 QAnything 的实现大同小异,就不额外展开了。\r\n\r\n将检索的内容,历史聊天记录以及问题构造为 prompt,即可作为大模型的输入了,默认的英文 prompt 如下所示:\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\n对应的中文 prompt 如下所示:\r\n\r\n\"\"\"\r\n你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。\n 以上是知识库。\n\n### Query:\n你好,请问有什么问题需要我帮忙解答吗?\n\n### Elapsed\n - Retrieval: 9131.1 ms\n - LLM: 12802.6 ms",
  1663. "id": "31153052-7bac-4741-a513-ed07d853f29e"
  1664. }
  1665. }
  1666. data:{
  1667. "code": 0,
  1668. "data": true
  1669. }
  1670. ```
  1671. Error
  1672. ```json
  1673. {
  1674. "code": 102,
  1675. "message": "Please input your question."
  1676. }
  1677. ```