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

http_api_reference.md 60KB

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