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

http_api_reference.md 57KB

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