You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  1. # HTTP API Reference
  2. ## Create dataset
  3. **POST** `/api/v1/dataset`
  4. Creates a dataset.
  5. ### Request
  6. - Method: POST
  7. - URL: `http://{address}/api/v1/dataset`
  8. - Headers:
  9. - `content-Type: application/json`
  10. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  11. - Body:
  12. - `"id"`: `string`
  13. - `"name"`: `string`
  14. - `"avatar"`: `string`
  15. - `"tenant_id"`: `string`
  16. - `"description"`: `string`
  17. - `"language"`: `string`
  18. - `"embedding_model"`: `string`
  19. - `"permission"`: `string`
  20. - `"document_count"`: `integer`
  21. - `"chunk_count"`: `integer`
  22. - `"parse_method"`: `string`
  23. - `"parser_config"`: `Dataset.ParserConfig`
  24. #### Request example
  25. ```bash
  26. # "id": id must not be provided.
  27. # "name": name is required and can't be duplicated.
  28. # "tenant_id": tenant_id must not be provided.
  29. # "embedding_model": embedding_model must not be provided.
  30. # "navie" means general.
  31. curl --request POST \
  32. --url http://{address}/api/v1/dataset \
  33. --header 'Content-Type: application/json' \
  34. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  35. --data '{
  36. "name": "test",
  37. "chunk_count": 0,
  38. "document_count": 0,
  39. "parse_method": "naive"
  40. }'
  41. ```
  42. #### Request parameters
  43. - `"id"`: (*Body parameter*)
  44. The ID of the created dataset used to uniquely identify different datasets.
  45. - If creating a dataset, `id` must not be provided.
  46. - `"name"`: (*Body parameter*)
  47. The name of the dataset, which must adhere to the following requirements:
  48. - Required when creating a dataset and must be unique.
  49. - If updating a dataset, `name` must still be unique.
  50. - `"avatar"`: (*Body parameter*)
  51. Base64 encoding of the avatar.
  52. - `"tenant_id"`: (*Body parameter*)
  53. The ID of the tenant associated with the dataset, used to link it with specific users.
  54. - If creating a dataset, `tenant_id` must not be provided.
  55. - If updating a dataset, `tenant_id` cannot be changed.
  56. - `"description"`: (*Body parameter*)
  57. The description of the dataset.
  58. - `"language"`: (*Body parameter*)
  59. The language setting for the dataset.
  60. - `"embedding_model"`: (*Body parameter*)
  61. Embedding model used in the dataset to generate vector embeddings.
  62. - If creating a dataset, `embedding_model` must not be provided.
  63. - If updating a dataset, `embedding_model` cannot be changed.
  64. - `"permission"`: (*Body parameter*)
  65. Specifies who can manipulate the dataset.
  66. - `"document_count"`: (*Body parameter*)
  67. Document count of the dataset.
  68. - If updating a dataset, `document_count` cannot be changed.
  69. - `"chunk_count"`: (*Body parameter*)
  70. Chunk count of the dataset.
  71. - If updating a dataset, `chunk_count` cannot be changed.
  72. - `"parse_method"`: (*Body parameter*)
  73. Parsing method of the dataset.
  74. - If updating `parse_method`, `chunk_count` must be greater than 0.
  75. - `"parser_config"`: (*Body parameter*)
  76. The configuration settings for the dataset parser.
  77. ### Response
  78. The successful response includes a JSON object like the following:
  79. ```json
  80. {
  81. "code": 0,
  82. "data": {
  83. "avatar": null,
  84. "chunk_count": 0,
  85. "create_date": "Thu, 10 Oct 2024 05:57:37 GMT",
  86. "create_time": 1728539857641,
  87. "created_by": "69736c5e723611efb51b0242ac120007",
  88. "description": null,
  89. "document_count": 0,
  90. "embedding_model": "BAAI/bge-large-zh-v1.5",
  91. "id": "8d73076886cc11ef8c270242ac120006",
  92. "language": "English",
  93. "name": "test_1",
  94. "parse_method": "naive",
  95. "parser_config": {
  96. "pages": [
  97. [
  98. 1,
  99. 1000000
  100. ]
  101. ]
  102. },
  103. "permission": "me",
  104. "similarity_threshold": 0.2,
  105. "status": "1",
  106. "tenant_id": "69736c5e723611efb51b0242ac120007",
  107. "token_num": 0,
  108. "update_date": "Thu, 10 Oct 2024 05:57:37 GMT",
  109. "update_time": 1728539857641,
  110. "vector_similarity_weight": 0.3
  111. }
  112. }
  113. ```
  114. - `"error_code"`: `integer`
  115. `0`: The operation succeeds.
  116. The error response includes a JSON object like the following:
  117. ```json
  118. {
  119. "code": 102,
  120. "message": "Duplicated knowledgebase name in creating dataset."
  121. }
  122. ```
  123. ## Delete datasets
  124. **DELETE** `/api/v1/dataset`
  125. Deletes datasets by ids.
  126. ### Request
  127. - Method: DELETE
  128. - URL: `http://{address}/api/v1/dataset`
  129. - Headers:
  130. - `content-Type: application/json`
  131. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  132. - Body:
  133. - `"ids"`: `List[string]`
  134. #### Request example
  135. ```bash
  136. # Either id or name must be provided, but not both.
  137. curl --request DELETE \
  138. --url http://{address}/api/v1/dataset \
  139. --header 'Content-Type: application/json' \
  140. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  141. --data '{
  142. "ids": ["test_1", "test_2"]
  143. }'
  144. ```
  145. #### Request parameters
  146. - `"ids"`: (*Body parameter*)
  147. Dataset IDs to delete.
  148. ### Response
  149. The successful response includes a JSON object like the following:
  150. ```json
  151. {
  152. "code": 0
  153. }
  154. ```
  155. - `"error_code"`: `integer`
  156. `0`: The operation succeeds.
  157. The error response includes a JSON object like the following:
  158. ```json
  159. {
  160. "code": 102,
  161. "message": "You don't own the dataset."
  162. }
  163. ```
  164. ## Update dataset
  165. **PUT** `/api/v1/dataset/{dataset_id}`
  166. Updates a dataset by its id.
  167. ### Request
  168. - Method: PUT
  169. - URL: `http://{address}/api/v1/dataset/{dataset_id}`
  170. - Headers:
  171. - `content-Type: application/json`
  172. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  173. - Body: (Refer to the "Create Dataset" for the complete structure of the request body.)
  174. #### Request example
  175. ```bash
  176. # "id": id is required.
  177. # "name": If you update name, it can't be duplicated.
  178. # "tenant_id": If you update tenant_id, it can't be changed
  179. # "embedding_model": If you update embedding_model, it can't be changed.
  180. # "chunk_count": If you update chunk_count, it can't be changed.
  181. # "document_count": If you update document_count, it can't be changed.
  182. # "parse_method": If you update parse_method, chunk_count must be 0.
  183. # "navie" means general.
  184. curl --request PUT \
  185. --url http://{address}/api/v1/dataset/{dataset_id} \
  186. --header 'Content-Type: application/json' \
  187. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  188. --data '{
  189. "name": "test",
  190. "tenant_id": "4fb0cd625f9311efba4a0242ac120006",
  191. "embedding_model": "BAAI/bge-zh-v1.5",
  192. "chunk_count": 0,
  193. "document_count": 0,
  194. "parse_method": "navie"
  195. }'
  196. ```
  197. #### Request parameters
  198. (Refer to the "Create Dataset" for the complete structure of the request parameters.)
  199. ### Response
  200. The successful response includes a JSON object like the following:
  201. ```json
  202. {
  203. "code": 0
  204. }
  205. ```
  206. - `"error_code"`: `integer`
  207. `0`: The operation succeeds.
  208. The error response includes a JSON object like the following:
  209. ```json
  210. {
  211. "code": 102,
  212. "message": "Can't change tenant_id."
  213. }
  214. ```
  215. ## List datasets
  216. **GET** `/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  217. List all datasets
  218. ### Request
  219. - Method: GET
  220. - URL: `http://{address}/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  221. - Headers:
  222. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  223. #### Request example
  224. ```bash
  225. # If no page parameter is passed, the default is 1
  226. # If no page_size parameter is passed, the default is 1024
  227. # If no order_by parameter is passed, the default is "create_time"
  228. # If no desc parameter is passed, the default is True
  229. curl --request GET \
  230. --url http://{address}/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  231. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  232. ```
  233. #### Request parameters
  234. - `path`: (*Path parameter*)
  235. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  236. - `path_size`: (*Path parameter*)
  237. The number of records to retrieve per page. This controls how many records will be included in each page.
  238. - `orderby`: (*Path parameter*)
  239. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  240. - `desc`: (*Path parameter*)
  241. A boolean flag indicating whether the sorting should be in descending order.
  242. - `name`: (*Path parameter*)
  243. Dataset name
  244. - `"id"`: (*Path parameter*)
  245. The ID of the dataset to be retrieved.
  246. - `"name"`: (*Path parameter*)
  247. The name of the dataset to be retrieved.
  248. ### Response
  249. The successful response includes a JSON object like the following:
  250. ```json
  251. {
  252. "code": 0,
  253. "data": [
  254. {
  255. "avatar": "",
  256. "chunk_count": 59,
  257. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  258. "create_time": 1726276357324,
  259. "created_by": "69736c5e723611efb51b0242ac120007",
  260. "description": null,
  261. "document_count": 1,
  262. "embedding_model": "BAAI/bge-large-zh-v1.5",
  263. "id": "6e211ee0723611efa10a0242ac120007",
  264. "language": "English",
  265. "name": "mysql",
  266. "parse_method": "knowledge_graph",
  267. "parser_config": {
  268. "chunk_token_num": 8192,
  269. "delimiter": "\\n!?;。;!?",
  270. "entity_types": [
  271. "organization",
  272. "person",
  273. "location",
  274. "event",
  275. "time"
  276. ]
  277. },
  278. "permission": "me",
  279. "similarity_threshold": 0.2,
  280. "status": "1",
  281. "tenant_id": "69736c5e723611efb51b0242ac120007",
  282. "token_num": 12744,
  283. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  284. "update_time": 1728533243536,
  285. "vector_similarity_weight": 0.3
  286. }
  287. ]
  288. }
  289. ```
  290. The error response includes a JSON object like the following:
  291. ```json
  292. {
  293. "code": 102,
  294. "message": "The dataset doesn't exist"
  295. }
  296. ```
  297. ## Upload files to a dataset
  298. **POST** `/api/v1/dataset/{dataset_id}/document`
  299. Uploads files to a dataset.
  300. ### Request
  301. - Method: POST
  302. - URL: `/api/v1/dataset/{dataset_id}/document`
  303. - Headers:
  304. - 'Content-Type: multipart/form-data'
  305. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  306. - Form:
  307. - 'file=@{FILE_PATH}'
  308. #### Request example
  309. ```shell
  310. curl --request POST \
  311. --url http://{address}/api/v1/dataset/{dataset_id}/document \
  312. --header 'Content-Type: multipart/form-data' \
  313. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  314. --form 'file=@test.txt'
  315. ```
  316. #### Request parameters
  317. - `"dataset_id"`: (*Path parameter*)
  318. The dataset id
  319. - `"file"`: (*Body parameter*)
  320. The file to upload
  321. ### Response
  322. The successful response includes a JSON object like the following:
  323. ```shell
  324. {
  325. "code": 0
  326. }
  327. ```
  328. - `"error_code"`: `integer`
  329. `0`: The operation succeeds.
  330. The error response includes a JSON object like the following:
  331. ```shell
  332. {
  333. "code": 3016,
  334. "message": "Can't connect database"
  335. }
  336. ```
  337. ## Download a file from a dataset
  338. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}`
  339. Downloads files from a dataset.
  340. ### Request
  341. - Method: GET
  342. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}`
  343. - Headers:
  344. - `content-Type: application/json`
  345. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  346. - Output:
  347. - '{FILE_NAME}'
  348. #### Request example
  349. ```shell
  350. curl --request GET \
  351. --url http://{address}/api/v1/dataset/{dataset_id}/document/{documents_id} \
  352. --header 'Content-Type: application/json' \
  353. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  354. --output '{FILE_NAME}'
  355. ```
  356. #### Request parameters
  357. - `"dataset_id"`: (*PATH parameter*)
  358. The dataset id
  359. - `"documents_id"`: (*PATH parameter*)
  360. The document id of the file.
  361. ### Response
  362. The successful response includes a JSON object like the following:
  363. ```shell
  364. {
  365. "code": 0
  366. }
  367. ```
  368. - `"error_code"`: `integer`
  369. `0`: The operation succeeds.
  370. The error response includes a JSON object like the following:
  371. ```shell
  372. {
  373. "code": 3016,
  374. "message": "Can't connect database"
  375. }
  376. ```
  377. ## List files of a dataset
  378. **GET** `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name}`
  379. List files to a dataset.
  380. ### Request
  381. - Method: GET
  382. - URL: `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name`
  383. - Headers:
  384. - `content-Type: application/json`
  385. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  386. #### Request example
  387. ```shell
  388. curl --request GET \
  389. --url http://{address}/api/v1/dataset/{dataset_id}/info?keywords=rag&page=0&page_size=10&orderby=create_time&desc=yes \
  390. --header 'Content-Type: application/json' \
  391. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  392. ```
  393. #### Request parameters
  394. - `"dataset_id"`: (*PATH parameter*)
  395. The dataset id
  396. - `keywords`: (*Filter parameter*)
  397. The keywords matches the search key workds;
  398. - `page`: (*Filter parameter*)
  399. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  400. - `page_size`: (*Filter parameter*)
  401. The number of records to retrieve per page. This controls how many records will be included in each page.
  402. - `orderby`: (*Filter parameter*)
  403. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  404. - `desc`: (*Filter parameter*)
  405. A boolean flag indicating whether the sorting should be in descending order.
  406. - `name`: (*Filter parameter*)
  407. File name.
  408. ### Response
  409. The successful response includes a JSON object like the following:
  410. ```shell
  411. {
  412. "code": 0,
  413. "data": {
  414. "docs": [
  415. {
  416. "chunk_count": 0,
  417. "create_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  418. "create_time": 1726647649379,
  419. "created_by": "134408906b6811efbcd20242ac120005",
  420. "id": "e970a94a759611efae5b0242ac120004",
  421. "knowledgebase_id": "e95f574e759611efbc850242ac120004",
  422. "location": "Test Document222.txt",
  423. "name": "Test Document222.txt",
  424. "parser_config": {
  425. "chunk_token_count": 128,
  426. "delimiter": "\n!?。;!?",
  427. "layout_recognize": true,
  428. "task_page_size": 12
  429. },
  430. "parser_method": "naive",
  431. "process_begin_at": null,
  432. "process_duation": 0.0,
  433. "progress": 0.0,
  434. "progress_msg": "",
  435. "run": "0",
  436. "size": 46,
  437. "source_type": "local",
  438. "status": "1",
  439. "thumbnail": null,
  440. "token_count": 0,
  441. "type": "doc",
  442. "update_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  443. "update_time": 1726647649379
  444. },
  445. {
  446. "chunk_count": 0,
  447. "create_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  448. "create_time": 1726647649340,
  449. "created_by": "134408906b6811efbcd20242ac120005",
  450. "id": "e96aad9c759611ef9ab60242ac120004",
  451. "knowledgebase_id": "e95f574e759611efbc850242ac120004",
  452. "location": "Test Document111.txt",
  453. "name": "Test Document111.txt",
  454. "parser_config": {
  455. "chunk_token_count": 128,
  456. "delimiter": "\n!?。;!?",
  457. "layout_recognize": true,
  458. "task_page_size": 12
  459. },
  460. "parser_method": "naive",
  461. "process_begin_at": null,
  462. "process_duation": 0.0,
  463. "progress": 0.0,
  464. "progress_msg": "",
  465. "run": "0",
  466. "size": 46,
  467. "source_type": "local",
  468. "status": "1",
  469. "thumbnail": null,
  470. "token_count": 0,
  471. "type": "doc",
  472. "update_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  473. "update_time": 1726647649340
  474. }
  475. ],
  476. "total": 2
  477. },
  478. }
  479. ```
  480. - `"error_code"`: `integer`
  481. `0`: The operation succeeds.
  482. The error response includes a JSON object like the following:
  483. ```shell
  484. {
  485. "code": 3016,
  486. "message": "Can't connect database"
  487. }
  488. ```
  489. ## Update a file information in dataset
  490. **PUT** `/api/v1/dataset/{dataset_id}/info/{document_id}`
  491. Update a file in a dataset
  492. ### Request
  493. - Method: PUT
  494. - URL: `/api/v1/dataset/{dataset_id}/document`
  495. - Headers:
  496. - `content-Type: application/json`
  497. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  498. #### Request example
  499. ```shell
  500. curl --request PUT \
  501. --url http://{address}/api/v1/dataset/{dataset_id}/info/{document_id} \
  502. --header 'Content-Type: application/json' \
  503. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  504. --raw '{
  505. "document_id": "f6b170ac758811efa0660242ac120004",
  506. "document_name": "manual.txt",
  507. "thumbnail": null,
  508. "knowledgebase_id": "779333c0758611ef910f0242ac120004",
  509. "parser_method": "manual",
  510. "parser_config": {"chunk_token_count": 128, "delimiter": "\n!?。;!?", "layout_recognize": true, "task_page_size": 12},
  511. "source_type": "local", "type": "doc",
  512. "created_by": "134408906b6811efbcd20242ac120005",
  513. "size": 0, "token_count": 0, "chunk_count": 0,
  514. "progress": 0.0,
  515. "progress_msg": "",
  516. "process_begin_at": null,
  517. "process_duration": 0.0
  518. }'
  519. ```
  520. #### Request parameters
  521. - `"document_id"`: (*Body parameter*)
  522. - `"document_name"`: (*Body parameter*)
  523. ### Response
  524. The successful response includes a JSON object like the following:
  525. ```shell
  526. {
  527. "code": 0
  528. }
  529. ```
  530. The error response includes a JSON object like the following:
  531. ```shell
  532. {
  533. "code": 3016,
  534. "message": "Can't connect database"
  535. }
  536. ```
  537. ## Parse files in dataset
  538. **POST** `/api/v1/dataset/{dataset_id}/chunk`
  539. Parse files into chunks in a dataset
  540. ### Request
  541. - Method: POST
  542. - URL: `/api/v1/dataset/{dataset_id}/chunk`
  543. - Headers:
  544. - `content-Type: application/json`
  545. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  546. #### Request example
  547. ```shell
  548. curl --request POST \
  549. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  550. --header 'Content-Type: application/json' \
  551. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  552. --raw '{
  553. "documents": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  554. }'
  555. ```
  556. #### Request parameters
  557. - `"dataset_id"`: (*Path parameter*)
  558. - `"documents"`: (*Body parameter*)
  559. - Documents to parse
  560. ### Response
  561. The successful response includes a JSON object like the following:
  562. ```shell
  563. {
  564. "code": 0
  565. }
  566. ```
  567. The error response includes a JSON object like the following:
  568. ```shell
  569. {
  570. "code": 3016,
  571. "message": "Can't connect database"
  572. }
  573. ```
  574. ## Stop file parsing
  575. **DELETE** `/api/v1/dataset/{dataset_id}/chunk`
  576. Stop file parsing
  577. ### Request
  578. - Method: POST
  579. - URL: `/api/v1/dataset/{dataset_id}/chunk`
  580. - Headers:
  581. - `content-Type: application/json`
  582. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  583. #### Request example
  584. ```shell
  585. curl --request DELETE \
  586. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  587. --header 'Content-Type: application/json' \
  588. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  589. --raw '{
  590. "documents": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  591. }'
  592. ```
  593. #### Request parameters
  594. - `"dataset_id"`: (*Path parameter*)
  595. - `"documents"`: (*Body parameter*)
  596. - Documents to stop parsing
  597. ### Response
  598. The successful response includes a JSON object like the following:
  599. ```shell
  600. {
  601. "code": 0
  602. }
  603. ```
  604. The error response includes a JSON object like the following:
  605. ```shell
  606. {
  607. "code": 3016,
  608. "message": "Can't connect database"
  609. }
  610. ```
  611. ## Get document chunk list
  612. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  613. Get document chunk list
  614. ### Request
  615. - Method: GET
  616. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  617. - Headers:
  618. - `content-Type: application/json`
  619. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  620. #### Request example
  621. ```shell
  622. curl --request GET \
  623. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  624. --header 'Content-Type: application/json' \
  625. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  626. ```
  627. #### Request parameters
  628. - `"dataset_id"`: (*Path parameter*)
  629. - `"document_id"`: (*Path parameter*)
  630. ### Response
  631. The successful response includes a JSON object like the following:
  632. ```shell
  633. {
  634. "code": 0
  635. "data": {
  636. "chunks": [
  637. {
  638. "available_int": 1,
  639. "content": "<em>advantag</em>of ragflow increas accuraci and relev:by incorpor retriev inform , ragflow can gener respons that are more accur",
  640. "document_keyword": "ragflow_test.txt",
  641. "document_id": "77df9ef4759a11ef8bdd0242ac120004",
  642. "id": "4ab8c77cfac1a829c8d5ed022a0808c0",
  643. "image_id": "",
  644. "important_keywords": [],
  645. "positions": [
  646. ""
  647. ]
  648. }
  649. ],
  650. "doc": {
  651. "chunk_count": 5,
  652. "create_date": "Wed, 18 Sep 2024 08:46:16 GMT",
  653. "create_time": 1726649176833,
  654. "created_by": "134408906b6811efbcd20242ac120005",
  655. "id": "77df9ef4759a11ef8bdd0242ac120004",
  656. "knowledgebase_id": "77d9d24e759a11ef880c0242ac120004",
  657. "location": "ragflow_test.txt",
  658. "name": "ragflow_test.txt",
  659. "parser_config": {
  660. "chunk_token_count": 128,
  661. "delimiter": "\n!?。;!?",
  662. "layout_recognize": true,
  663. "task_page_size": 12
  664. },
  665. "parser_method": "naive",
  666. "process_begin_at": "Wed, 18 Sep 2024 08:46:16 GMT",
  667. "process_duation": 7.3213,
  668. "progress": 1.0,
  669. "progress_msg": "\nTask has been received.\nStart to parse.\nFinish parsing.\nFinished slicing files(5). Start to embedding the content.\nFinished embedding(6.16)! Start to build index!\nDone!",
  670. "run": "3",
  671. "size": 4209,
  672. "source_type": "local",
  673. "status": "1",
  674. "thumbnail": null,
  675. "token_count": 746,
  676. "type": "doc",
  677. "update_date": "Wed, 18 Sep 2024 08:46:23 GMT",
  678. "update_time": 1726649183321
  679. },
  680. "total": 1
  681. },
  682. }
  683. ```
  684. The error response includes a JSON object like the following:
  685. ```shell
  686. {
  687. "code": 3016,
  688. "message": "Can't connect database"
  689. }
  690. ```
  691. ## Delete document chunks
  692. **DELETE** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  693. Delete document chunks
  694. ### Request
  695. - Method: DELETE
  696. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  697. - Headers:
  698. - `content-Type: application/json`
  699. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  700. #### Request example
  701. ```shell
  702. curl --request DELETE \
  703. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  704. --header 'Content-Type: application/json' \
  705. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  706. --raw '{
  707. "chunks": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  708. }'
  709. ```
  710. ## Update document chunk
  711. **PUT** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  712. Update document chunk
  713. ### Request
  714. - Method: PUT
  715. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  716. - Headers:
  717. - `content-Type: application/json`
  718. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  719. #### Request example
  720. ```shell
  721. curl --request PUT \
  722. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  723. --header 'Content-Type: application/json' \
  724. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  725. --raw '{
  726. "chunk_id": "d87fb0b7212c15c18d0831677552d7de",
  727. "knowledgebase_id": null,
  728. "name": "",
  729. "content": "ragflow123",
  730. "important_keywords": [],
  731. "document_id": "e6bbba92759511efaa900242ac120004",
  732. "status": "1"
  733. }'
  734. ```
  735. ## Insert document chunks
  736. **POST** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  737. Insert document chunks
  738. ### Request
  739. - Method: POST
  740. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  741. - Headers:
  742. - `content-Type: application/json`
  743. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  744. #### Request example
  745. ```shell
  746. curl --request POST \
  747. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  748. --header 'Content-Type: application/json' \
  749. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  750. --raw '{
  751. "document_id": "97ad64b6759811ef9fc30242ac120004",
  752. "content": ["ragflow content", "ragflow content"]
  753. }'
  754. ```
  755. ## Dataset retrieval test
  756. **GET** `/api/v1/dataset/{dataset_id}/retrieval`
  757. Retrieval test of a dataset
  758. ### Request
  759. - Method: GET
  760. - URL: `/api/v1/dataset/{dataset_id}/retrieval`
  761. - Headers:
  762. - `content-Type: application/json`
  763. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  764. #### Request example
  765. ```shell
  766. curl --request GET \
  767. --url http://{address}/api/v1/dataset/{dataset_id}/retrieval \
  768. --header 'Content-Type: application/json' \
  769. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  770. --raw '{
  771. "query_text": "This is a cat."
  772. }'
  773. ```
  774. ## Create chat
  775. **POST** `/api/v1/chat`
  776. Create a chat
  777. ### Request
  778. - Method: POST
  779. - URL: `http://{address}/api/v1/chat`
  780. - Headers:
  781. - `content-Type: application/json`
  782. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  783. - Body:
  784. - `"name"`: `string`
  785. - `"avatar"`: `string`
  786. - `"knowledgebases"`: `List[DataSet]`
  787. - `"id"`: `string`
  788. - `"llm"`: `LLM`
  789. - `"prompt"`: `Prompt`
  790. #### Request example
  791. ```shell
  792. curl --request POST \
  793. --url http://{address}/api/v1/chat \
  794. --header 'Content-Type: application/json' \
  795. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  796. --data-binary '{
  797. "knowledgebases": [
  798. {
  799. "avatar": null,
  800. "chunk_count": 0,
  801. "description": null,
  802. "document_count": 0,
  803. "embedding_model": "",
  804. "id": "0b2cbc8c877f11ef89070242ac120005",
  805. "language": "English",
  806. "name": "Test_assistant",
  807. "parse_method": "naive",
  808. "parser_config": {
  809. "pages": [
  810. [
  811. 1,
  812. 1000000
  813. ]
  814. ]
  815. },
  816. "permission": "me",
  817. "tenant_id": "4fb0cd625f9311efba4a0242ac120006"
  818. }
  819. ],
  820. "name":"new_chat_1"
  821. }'
  822. ```
  823. #### Request parameters
  824. - `"name"`: (*Body parameter*)
  825. The name of the created chat.
  826. - `"assistant"`
  827. - `"avatar"`: (*Body parameter*)
  828. The icon of the created chat.
  829. - `"path"`
  830. - `"knowledgebases"`: (*Body parameter*)
  831. Select knowledgebases associated.
  832. - `["kb1"]`
  833. - `"id"`: (*Body parameter*)
  834. The id of the created chat.
  835. - `""`
  836. - `"llm"`: (*Body parameter*)
  837. The LLM of the created chat.
  838. - If the value is `None`, a dictionary with default values will be generated.
  839. - `"prompt"`: (*Body parameter*)
  840. The prompt of the created chat.
  841. - If the value is `None`, a dictionary with default values will be generated.
  842. ---
  843. ##### Chat.LLM parameters:
  844. - `"model_name"`: (*Body parameter*)
  845. Large language chat model.
  846. - If it is `None`, it will return the user's default model.
  847. - `"temperature"`: (*Body parameter*)
  848. Controls the randomness of predictions by the model. A lower temperature makes the model more confident, while a higher temperature makes it more creative and diverse.
  849. - `0.1`
  850. - `"top_p"`: (*Body parameter*)
  851. Also known as "nucleus sampling," it focuses on the most likely words, cutting off the less probable ones.
  852. - `0.3`
  853. - `"presence_penalty"`: (*Body parameter*)
  854. Discourages the model from repeating the same information by penalizing repeated content.
  855. - `0.4`
  856. - `"frequency_penalty"`: (*Body parameter*)
  857. Reduces the model’s tendency to repeat words frequently.
  858. - `0.7`
  859. - `"max_tokens"`: (*Body parameter*)
  860. Sets the maximum length of the model’s output, measured in tokens (words or pieces of words).
  861. - `512`
  862. ---
  863. ##### Chat.Prompt parameters:
  864. - `"similarity_threshold"`: (*Body parameter*)
  865. Filters out chunks with similarity below this threshold.
  866. - `0.2`
  867. - `"keywords_similarity_weight"`: (*Body parameter*)
  868. Weighted keywords similarity and vector cosine similarity; the sum of weights is 1.0.
  869. - `0.7`
  870. - `"top_n"`: (*Body parameter*)
  871. Only the top N chunks above the similarity threshold will be fed to LLMs.
  872. - `8`
  873. - `"variables"`: (*Body parameter*)
  874. Variables help with different chat strategies by filling in the 'System' part of the prompt.
  875. - `[{"key": "knowledge", "optional": True}]`
  876. - `"rerank_model"`: (*Body parameter*)
  877. If empty, it uses vector cosine similarity; otherwise, it uses rerank score.
  878. - `""`
  879. - `"empty_response"`: (*Body parameter*)
  880. If nothing is retrieved, this will be used as the response. Leave blank if LLM should provide its own opinion.
  881. - `None`
  882. - `"opener"`: (*Body parameter*)
  883. The welcome message for clients.
  884. - `"Hi! I'm your assistant, what can I do for you?"`
  885. - `"show_quote"`: (*Body parameter*)
  886. Indicates whether the source of the original text should be displayed.
  887. - `True`
  888. - `"prompt"`: (*Body parameter*)
  889. Instructions for LLM to follow when answering questions, such as character design or answer length.
  890. - `"You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence 'The answer you are looking for is not found in the knowledge base!' Answers need to consider chat history. Here is the knowledge base: {knowledge} The above is the knowledge base."`
  891. ### Response
  892. Success:
  893. ```json
  894. {
  895. "code": 0,
  896. "data": {
  897. "avatar": "",
  898. "create_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  899. "create_time": 1728617004635,
  900. "description": "A helpful Assistant",
  901. "do_refer": "1",
  902. "id": "2ca4b22e878011ef88fe0242ac120005",
  903. "knowledgebases": [
  904. {
  905. "avatar": null,
  906. "chunk_count": 0,
  907. "description": null,
  908. "document_count": 0,
  909. "embedding_model": "",
  910. "id": "0b2cbc8c877f11ef89070242ac120005",
  911. "language": "English",
  912. "name": "Test_assistant",
  913. "parse_method": "naive",
  914. "parser_config": {
  915. "pages": [
  916. [
  917. 1,
  918. 1000000
  919. ]
  920. ]
  921. },
  922. "permission": "me",
  923. "tenant_id": "4fb0cd625f9311efba4a0242ac120006"
  924. }
  925. ],
  926. "language": "English",
  927. "llm": {
  928. "frequency_penalty": 0.7,
  929. "max_tokens": 512,
  930. "model_name": "deepseek-chat___OpenAI-API@OpenAI-API-Compatible",
  931. "presence_penalty": 0.4,
  932. "temperature": 0.1,
  933. "top_p": 0.3
  934. },
  935. "name": "new_chat_1",
  936. "prompt": {
  937. "empty_response": "Sorry! 知识库中未找到相关内容!",
  938. "keywords_similarity_weight": 0.3,
  939. "opener": "您好,我是您的助手小樱,长得可爱又善良,can I help you?",
  940. "prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。",
  941. "rerank_model": "",
  942. "similarity_threshold": 0.2,
  943. "top_n": 6,
  944. "variables": [
  945. {
  946. "key": "knowledge",
  947. "optional": false
  948. }
  949. ]
  950. },
  951. "prompt_type": "simple",
  952. "status": "1",
  953. "tenant_id": "69736c5e723611efb51b0242ac120007",
  954. "top_k": 1024,
  955. "update_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  956. "update_time": 1728617004635
  957. }
  958. }
  959. ```
  960. Error:
  961. ```json
  962. {
  963. "code": 102,
  964. "message": "Duplicated chat name in creating dataset."
  965. }
  966. ```
  967. ## Update chat
  968. **PUT** `/api/v1/chat/{chat_id}`
  969. Update a chat
  970. ### Request
  971. - Method: PUT
  972. - URL: `http://{address}/api/v1/chat/{chat_id}`
  973. - Headers:
  974. - `content-Type: application/json`
  975. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  976. - Body: (Refer to the "Create chat" for the complete structure of the request body.)
  977. #### Request example
  978. ```bash
  979. curl --request PUT \
  980. --url http://{address}/api/v1/chat/{chat_id} \
  981. --header 'Content-Type: application/json' \
  982. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  983. --data '{
  984. "name":"Test"
  985. }'
  986. ```
  987. #### Parameters
  988. (Refer to the "Create chat" for the complete structure of the request parameters.)
  989. ### Response
  990. Success
  991. ```json
  992. {
  993. "code": 0
  994. }
  995. ```
  996. Error
  997. ```json
  998. {
  999. "code": 102,
  1000. "message": "Duplicated chat name in updating dataset."
  1001. }
  1002. ```
  1003. ## Delete chats
  1004. **DELETE** `/api/v1/chat`
  1005. Delete chats
  1006. ### Request
  1007. - Method: DELETE
  1008. - URL: `http://{address}/api/v1/chat`
  1009. - Headers:
  1010. - `content-Type: application/json`
  1011. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1012. - Body:
  1013. - `ids`: List[string]
  1014. #### Request example
  1015. ```bash
  1016. # Either id or name must be provided, but not both.
  1017. curl --request DELETE \
  1018. --url http://{address}/api/v1/chat \
  1019. --header 'Content-Type: application/json' \
  1020. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1021. --data '{
  1022. "ids": ["test_1", "test_2"]
  1023. }'
  1024. }'
  1025. ```
  1026. #### Request parameters:
  1027. - `"ids"`: (*Body parameter*)
  1028. IDs of the chats to be deleted.
  1029. - `None`
  1030. ### Response
  1031. Success
  1032. ```json
  1033. {
  1034. "code": 0
  1035. }
  1036. ```
  1037. Error
  1038. ```json
  1039. {
  1040. "code": 102,
  1041. "message": "ids are required"
  1042. }
  1043. ```
  1044. ## List chats
  1045. **GET** `/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1046. List chats based on filter criteria.
  1047. ### Request
  1048. - Method: GET
  1049. - URL: `http://{address}/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1050. - Headers:
  1051. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1052. #### Request example
  1053. ```bash
  1054. curl --request GET \
  1055. --url http://{address}/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1056. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1057. ```
  1058. #### Request parameters
  1059. - `"page"`: (*Path parameter*)
  1060. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  1061. - `1`
  1062. - `"page_size"`: (*Path parameter*)
  1063. The number of records to retrieve per page. This controls how many records will be included in each page.
  1064. - `1024`
  1065. - `"orderby"`: (*Path parameter*)
  1066. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  1067. - `"create_time"`
  1068. - `"desc"`: (*Path parameter*)
  1069. A boolean flag indicating whether the sorting should be in descending order.
  1070. - `True`
  1071. - `"id"`: (*Path parameter*)
  1072. The ID of the chat to be retrieved.
  1073. - `None`
  1074. - `"name"`: (*Path parameter*)
  1075. The name of the chat to be retrieved.
  1076. - `None`
  1077. ### Response
  1078. Success
  1079. ```json
  1080. {
  1081. "code": 0,
  1082. "data": [
  1083. {
  1084. "avatar": "",
  1085. "create_date": "Fri, 11 Oct 2024 03:23:24 GMT",
  1086. "create_time": 1728617004635,
  1087. "description": "A helpful Assistant",
  1088. "do_refer": "1",
  1089. "id": "2ca4b22e878011ef88fe0242ac120005",
  1090. "knowledgebases": [
  1091. {
  1092. "avatar": "",
  1093. "chunk_num": 0,
  1094. "create_date": "Fri, 11 Oct 2024 03:15:18 GMT",
  1095. "create_time": 1728616518986,
  1096. "created_by": "69736c5e723611efb51b0242ac120007",
  1097. "description": "",
  1098. "doc_num": 0,
  1099. "embd_id": "BAAI/bge-large-zh-v1.5",
  1100. "id": "0b2cbc8c877f11ef89070242ac120005",
  1101. "language": "English",
  1102. "name": "test_delete_chat",
  1103. "parser_config": {
  1104. "chunk_token_count": 128,
  1105. "delimiter": "\n!?。;!?",
  1106. "layout_recognize": true,
  1107. "task_page_size": 12
  1108. },
  1109. "parser_id": "naive",
  1110. "permission": "me",
  1111. "similarity_threshold": 0.2,
  1112. "status": "1",
  1113. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1114. "token_num": 0,
  1115. "update_date": "Fri, 11 Oct 2024 04:01:31 GMT",
  1116. "update_time": 1728619291228,
  1117. "vector_similarity_weight": 0.3
  1118. }
  1119. ],
  1120. "language": "English",
  1121. "llm": {
  1122. "frequency_penalty": 0.7,
  1123. "max_tokens": 512,
  1124. "model_name": "deepseek-chat___OpenAI-API@OpenAI-API-Compatible",
  1125. "presence_penalty": 0.4,
  1126. "temperature": 0.1,
  1127. "top_p": 0.3
  1128. },
  1129. "name": "Test",
  1130. "prompt": {
  1131. "empty_response": "Sorry! 知识库中未找到相关内容!",
  1132. "keywords_similarity_weight": 0.3,
  1133. "opener": "您好,我是您的助手小樱,长得可爱又善良,can I help you?",
  1134. "prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。",
  1135. "rerank_model": "",
  1136. "similarity_threshold": 0.2,
  1137. "top_n": 6,
  1138. "variables": [
  1139. {
  1140. "key": "knowledge",
  1141. "optional": false
  1142. }
  1143. ]
  1144. },
  1145. "prompt_type": "simple",
  1146. "status": "1",
  1147. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1148. "top_k": 1024,
  1149. "update_date": "Fri, 11 Oct 2024 03:47:58 GMT",
  1150. "update_time": 1728618478392
  1151. }
  1152. ]
  1153. }
  1154. ```
  1155. Error
  1156. ```json
  1157. {
  1158. "code": 102,
  1159. "message": "The chat doesn't exist"
  1160. }
  1161. ```
  1162. ## Create a chat session
  1163. **POST** `/api/v1/chat/{chat_id}/session`
  1164. Create a chat session
  1165. ### Request
  1166. - Method: POST
  1167. - URL: `/api/v1/chat/{chat_id}/session`
  1168. - Headers:
  1169. - `content-Type: application/json`
  1170. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1171. #### Request example
  1172. curl --request POST \
  1173. --url http://{address}/api/v1/chat/{chat_id}/session \
  1174. --header 'Content-Type: application/json' \
  1175. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  1176. --data-binary '{
  1177. "name": "new session"
  1178. }'
  1179. ## List the sessions of a chat
  1180. **GET** `/api/v1/chat/{chat_id}/session`
  1181. List all the session of a chat
  1182. ### Request
  1183. - Method: GET
  1184. - URL: `/api/v1/chat/{chat_id}/session`
  1185. - Headers:
  1186. - `content-Type: application/json`
  1187. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1188. #### Request example
  1189. curl --request GET \
  1190. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session \
  1191. --header 'Content-Type: application/json' \
  1192. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1193. ## Delete a chat session
  1194. **DELETE** `/api/v1/chat/{chat_id}/session/{session_id}`
  1195. Delete a chat session
  1196. ### Request
  1197. - Method: DELETE
  1198. - URL: `/api/v1/chat/{chat_id}/session/{session_id}`
  1199. - Headers:
  1200. - `content-Type: application/json`
  1201. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1202. #### Request example
  1203. curl --request DELETE \
  1204. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007 \
  1205. --header 'Content-Type: application/json' \
  1206. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1207. ## Update a chat session
  1208. **PUT** `/api/v1/chat/{chat_id}/session/{session_id}`
  1209. Update a chat session
  1210. ### Request
  1211. - Method: PUT
  1212. - URL: `/api/v1/chat/{chat_id}/session/{session_id}`
  1213. - Headers:
  1214. - `content-Type: application/json`
  1215. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1216. #### Request example
  1217. curl --request PUT \
  1218. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007 \
  1219. --header 'Content-Type: application/json' \
  1220. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1221. --data-binary '{
  1222. "name": "Updated session"
  1223. }'
  1224. ## Chat with a chat session
  1225. **POST** `/api/v1/chat/{chat_id}/session/{session_id}/completion`
  1226. Chat with a chat session
  1227. ### Request
  1228. - Method: POST
  1229. - URL: `/api/v1/chat/{chat_id}/session/{session_id}/completion`
  1230. - Headers:
  1231. - `content-Type: application/json`
  1232. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1233. #### Request example
  1234. curl --request POST \
  1235. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007/completion \
  1236. --header 'Content-Type: application/json' \
  1237. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  1238. --data-binary '{
  1239. "question": "Hello!",
  1240. "stream": true,
  1241. }'