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.

http_api.md 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. # HTTP API Reference
  2. ## Create dataset
  3. **POST** `/api/v1/dataset`
  4. Creates a dataset with a name. If dataset of the same name already exists, the new dataset will be renamed by RAGFlow automatically.
  5. ### Request
  6. - Method: POST
  7. - URL: `/api/v1/dataset`
  8. - Headers:
  9. - `content-Type: application/json`
  10. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  11. - Body:
  12. - `"dataset_name"`: `string`
  13. - `"tenant_id"`: `string`
  14. - `"embedding_model"`: `string`
  15. - `"chunk_count"`: `integer`
  16. - `"document_count"`: `integer`
  17. - `"parse_method"`: `string`
  18. #### Request example
  19. ```shell
  20. curl --request POST \
  21. --url http://{address}/api/v1/dataset \
  22. --header 'Content-Type: application/json' \
  23. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  24. --data-binary '{
  25. "dataset_name": "test",
  26. "tenant_id": "4fb0cd625f9311efba4a0242ac120006",
  27. "embedding_model": "BAAI/bge--zh-v1.5",
  28. "chunk_count": 0,
  29. "document_count": 0,
  30. "parse_method": "general"
  31. }'
  32. ```
  33. #### Request parameters
  34. - `"dataset_name"`: (*Body parameter*)
  35. The name of the dataset, which must adhere to the following requirements:
  36. - Maximum 65,535 characters.
  37. - `"tenant_id"`: (*Body parameter*)
  38. The ID of the tenant.
  39. - `"embedding_model"`: (*Body parameter*)
  40. Embedding model used in the dataset.
  41. - `"chunk_count"`: (*Body parameter*)
  42. Chunk count of the dataset.
  43. - `"document_count"`: (*Body parameter*)
  44. Document count of the dataset.
  45. - `"parse_mehtod"`: (*Body parameter*)
  46. Parsing method of the dataset.
  47. ### Response
  48. The successful response includes a JSON object like the following:
  49. ```shell
  50. {
  51. "code": 0
  52. }
  53. ```
  54. - `"error_code"`: `integer`
  55. `0`: The operation succeeds.
  56. The error response includes a JSON object like the following:
  57. ```shell
  58. {
  59. "code": 3016,
  60. "message": "Can't connect database"
  61. }
  62. ```
  63. ## Delete dataset
  64. **DELETE** `/api/v1/dataset`
  65. Deletes a dataset by its id or name.
  66. ### Request
  67. - Method: DELETE
  68. - URL: `/api/v1/dataset/{dataset_id}`
  69. - Headers:
  70. - `content-Type: application/json`
  71. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  72. #### Request example
  73. ```shell
  74. curl --request DELETE \
  75. --url http://{address}/api/v1/dataset/0 \
  76. --header 'Content-Type: application/json' \
  77. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  78. --data ' {
  79. "names": ["ds1", "ds2"]
  80. }'
  81. ```
  82. #### Request parameters
  83. - `"names"`: (*Body parameter*)
  84. Dataset names to delete.
  85. - `"ids"`: (*Body parameter*)
  86. Dataset IDs to delete.
  87. `"names"` and `"ids"` are exclusive.
  88. ### Response
  89. The successful response includes a JSON object like the following:
  90. ```shell
  91. {
  92. "code": 0
  93. }
  94. ```
  95. - `"error_code"`: `integer`
  96. `0`: The operation succeeds.
  97. The error response includes a JSON object like the following:
  98. ```shell
  99. {
  100. "code": 3016,
  101. "message": "Try to delete non-existent dataset."
  102. }
  103. ```
  104. ## Update dataset
  105. **PUT** `/api/v1/dataset/{dataset_id}`
  106. Updates a dataset by its id.
  107. ### Request
  108. - Method: PUT
  109. - URL: `/api/v1/dataset/{dataset_id}`
  110. - Headers:
  111. - `content-Type: application/json`
  112. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  113. #### Request example
  114. ```shell
  115. curl --request PUT \
  116. --url http://{address}/api/v1/dataset/0 \
  117. --header 'Content-Type: application/json' \
  118. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  119. --data-binary '{
  120. "dataset_name": "test",
  121. "tenant_id": "4fb0cd625f9311efba4a0242ac120006",
  122. "embedding_model": "BAAI/bge--zh-v1.5",
  123. "chunk_count": 0,
  124. "document_count": 0,
  125. "parse_method": "general"
  126. }'
  127. ```
  128. #### Request parameters
  129. - `"dataset_name"`: (*Body parameter*)
  130. The name of the dataset, which must adhere to the following requirements:
  131. - Maximum 65,535 characters.
  132. - `"tenant_id"`: (*Body parameter*)
  133. The ID of the tenant.
  134. - `"embedding_model"`: (*Body parameter*)
  135. Embedding model used in the dataset.
  136. - `"chunk_count"`: (*Body parameter*)
  137. Chunk count of the dataset.
  138. - `"document_count"`: (*Body parameter*)
  139. Document count of the dataset.
  140. - `"parse_mehtod"`: (*Body parameter*)
  141. Parsing method of the dataset.
  142. ### Response
  143. The successful response includes a JSON object like the following:
  144. ```shell
  145. {
  146. "code": 0
  147. }
  148. ```
  149. - `"error_code"`: `integer`
  150. `0`: The operation succeeds.
  151. The error response includes a JSON object like the following:
  152. ```shell
  153. {
  154. "code": 3016,
  155. "message": "Can't change embedding model since some files already use it."
  156. }
  157. ```
  158. ## List datasets
  159. **GET** `/api/v1/dataset?name={name}&page={page}&page_size={page_size}&orderby={orderby}&desc={desc}`
  160. List all datasets
  161. ### Request
  162. - Method: GET
  163. - URL: `/api/v1/dataset?name={name}&page={page}&page_size={page_size}&orderby={orderby}&desc={desc}`
  164. - Headers:
  165. - `content-Type: application/json`
  166. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  167. #### Request example
  168. ```shell
  169. curl --request GET \
  170. --url http://{address}/api/v1/dataset?page=0&page_size=50&orderby=create_time&desc=false \
  171. --header 'Content-Type: application/json' \
  172. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  173. ```
  174. #### Request parameters
  175. - `path`: (*Path parameter*)
  176. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  177. - `path_size`: (*Path parameter*)
  178. The number of records to retrieve per page. This controls how many records will be included in each page.
  179. - `orderby`: (*Path parameter*)
  180. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  181. - `desc`: (*Path parameter*)
  182. A boolean flag indicating whether the sorting should be in descending order.
  183. - `name`: (*Path parameter*)
  184. Dataset name
  185. ### Response
  186. The successful response includes a JSON object like the following:
  187. ```shell
  188. {
  189. "code": 0,
  190. "data": [
  191. {
  192. "avatar": "",
  193. "chunk_count": 0,
  194. "create_date": "Thu, 29 Aug 2024 03:13:07 GMT",
  195. "create_time": 1724901187843,
  196. "created_by": "4fb0cd625f9311efba4a0242ac120006",
  197. "description": "",
  198. "document_count": 0,
  199. "embedding_model": "BAAI/bge-large-zh-v1.5",
  200. "id": "9d3d906665b411ef87d10242ac120006",
  201. "language": "English",
  202. "name": "Test",
  203. "parser_config": {
  204. "chunk_token_count": 128,
  205. "delimiter": "\n!?。;!?",
  206. "layout_recognize": true,
  207. "task_page_size": 12
  208. },
  209. "parse_method": "naive",
  210. "permission": "me",
  211. "similarity_threshold": 0.2,
  212. "status": "1",
  213. "tenant_id": "4fb0cd625f9311efba4a0242ac120006",
  214. "token_count": 0,
  215. "update_date": "Thu, 29 Aug 2024 03:13:07 GMT",
  216. "update_time": 1724901187843,
  217. "vector_similarity_weight": 0.3
  218. }
  219. ],
  220. }
  221. ```
  222. The error response includes a JSON object like the following:
  223. ```shell
  224. {
  225. "code": 3016,
  226. "message": "Can't access database to get the dataset list."
  227. }
  228. ```
  229. ## Upload files to a dataset
  230. **POST** `/api/v1/dataset/{dataset_id}/document`
  231. Uploads files to a dataset.
  232. ### Request
  233. - Method: POST
  234. - URL: `/api/v1/dataset/{dataset_id}/document`
  235. - Headers:
  236. - 'Content-Type: multipart/form-data'
  237. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  238. - Form:
  239. - 'file=@{FILE_PATH}'
  240. #### Request example
  241. ```shell
  242. curl --request POST \
  243. --url http://{address}/api/v1/dataset/{dataset_id}/document \
  244. --header 'Content-Type: multipart/form-data' \
  245. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  246. --form 'file=@test.txt'
  247. ```
  248. #### Request parameters
  249. - `"dataset_id"`: (*Path parameter*)
  250. The dataset id
  251. - `"file"`: (*Body parameter*)
  252. The file to upload
  253. ### Response
  254. The successful response includes a JSON object like the following:
  255. ```shell
  256. {
  257. "code": 0
  258. }
  259. ```
  260. - `"error_code"`: `integer`
  261. `0`: The operation succeeds.
  262. The error response includes a JSON object like the following:
  263. ```shell
  264. {
  265. "code": 3016,
  266. "message": "Can't connect database"
  267. }
  268. ```
  269. ## Download a file from a dataset
  270. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}`
  271. Downloads files from a dataset.
  272. ### Request
  273. - Method: GET
  274. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}`
  275. - Headers:
  276. - `content-Type: application/json`
  277. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  278. - Output:
  279. - '{FILE_NAME}'
  280. #### Request example
  281. ```shell
  282. curl --request GET \
  283. --url http://{address}/api/v1/dataset/{dataset_id}/document/{documents_id} \
  284. --header 'Content-Type: application/json' \
  285. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  286. --output '{FILE_NAME}'
  287. ```
  288. #### Request parameters
  289. - `"dataset_id"`: (*PATH parameter*)
  290. The dataset id
  291. - `"documents_id"`: (*PATH parameter*)
  292. The document id of the file.
  293. ### Response
  294. The successful response includes a JSON object like the following:
  295. ```shell
  296. {
  297. "code": 0
  298. }
  299. ```
  300. - `"error_code"`: `integer`
  301. `0`: The operation succeeds.
  302. The error response includes a JSON object like the following:
  303. ```shell
  304. {
  305. "code": 3016,
  306. "message": "Can't connect database"
  307. }
  308. ```
  309. ## List files of a dataset
  310. **GET** `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name}`
  311. List files to a dataset.
  312. ### Request
  313. - Method: GET
  314. - URL: `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name`
  315. - Headers:
  316. - `content-Type: application/json`
  317. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  318. #### Request example
  319. ```shell
  320. curl --request GET \
  321. --url http://{address}/api/v1/dataset/{dataset_id}/info?keywords=rag&page=0&page_size=10&orderby=create_time&desc=yes \
  322. --header 'Content-Type: application/json' \
  323. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  324. ```
  325. #### Request parameters
  326. - `"dataset_id"`: (*PATH parameter*)
  327. The dataset id
  328. - `keywords`: (*Filter parameter*)
  329. The keywords matches the search key workds;
  330. - `page`: (*Filter parameter*)
  331. The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched.
  332. - `page_size`: (*Filter parameter*)
  333. The number of records to retrieve per page. This controls how many records will be included in each page.
  334. - `orderby`: (*Filter parameter*)
  335. The field by which the records should be sorted. This specifies the attribute or column used to order the results.
  336. - `desc`: (*Filter parameter*)
  337. A boolean flag indicating whether the sorting should be in descending order.
  338. - `name`: (*Filter parameter*)
  339. File name.
  340. ### Response
  341. The successful response includes a JSON object like the following:
  342. ```shell
  343. {
  344. "code": 0,
  345. "data": {
  346. "docs": [
  347. {
  348. "chunk_count": 0,
  349. "create_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  350. "create_time": 1726647649379,
  351. "created_by": "134408906b6811efbcd20242ac120005",
  352. "id": "e970a94a759611efae5b0242ac120004",
  353. "knowledgebase_id": "e95f574e759611efbc850242ac120004",
  354. "location": "Test Document222.txt",
  355. "name": "Test Document222.txt",
  356. "parser_config": {
  357. "chunk_token_count": 128,
  358. "delimiter": "\n!?。;!?",
  359. "layout_recognize": true,
  360. "task_page_size": 12
  361. },
  362. "parser_method": "naive",
  363. "process_begin_at": null,
  364. "process_duation": 0.0,
  365. "progress": 0.0,
  366. "progress_msg": "",
  367. "run": "0",
  368. "size": 46,
  369. "source_type": "local",
  370. "status": "1",
  371. "thumbnail": null,
  372. "token_count": 0,
  373. "type": "doc",
  374. "update_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  375. "update_time": 1726647649379
  376. },
  377. {
  378. "chunk_count": 0,
  379. "create_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  380. "create_time": 1726647649340,
  381. "created_by": "134408906b6811efbcd20242ac120005",
  382. "id": "e96aad9c759611ef9ab60242ac120004",
  383. "knowledgebase_id": "e95f574e759611efbc850242ac120004",
  384. "location": "Test Document111.txt",
  385. "name": "Test Document111.txt",
  386. "parser_config": {
  387. "chunk_token_count": 128,
  388. "delimiter": "\n!?。;!?",
  389. "layout_recognize": true,
  390. "task_page_size": 12
  391. },
  392. "parser_method": "naive",
  393. "process_begin_at": null,
  394. "process_duation": 0.0,
  395. "progress": 0.0,
  396. "progress_msg": "",
  397. "run": "0",
  398. "size": 46,
  399. "source_type": "local",
  400. "status": "1",
  401. "thumbnail": null,
  402. "token_count": 0,
  403. "type": "doc",
  404. "update_date": "Wed, 18 Sep 2024 08:20:49 GMT",
  405. "update_time": 1726647649340
  406. }
  407. ],
  408. "total": 2
  409. },
  410. }
  411. ```
  412. - `"error_code"`: `integer`
  413. `0`: The operation succeeds.
  414. The error response includes a JSON object like the following:
  415. ```shell
  416. {
  417. "code": 3016,
  418. "message": "Can't connect database"
  419. }
  420. ```
  421. ## Update a file information in dataset
  422. **PUT** `/api/v1/dataset/{dataset_id}/info/{document_id}`
  423. Update a file in a dataset
  424. ### Request
  425. - Method: PUT
  426. - URL: `/api/v1/dataset/{dataset_id}/document`
  427. - Headers:
  428. - `content-Type: application/json`
  429. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  430. #### Request example
  431. ```shell
  432. curl --request PUT \
  433. --url http://{address}/api/v1/dataset/{dataset_id}/info/{document_id} \
  434. --header 'Content-Type: application/json' \
  435. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  436. --raw '{
  437. "document_id": "f6b170ac758811efa0660242ac120004",
  438. "document_name": "manual.txt",
  439. "thumbnail": null,
  440. "knowledgebase_id": "779333c0758611ef910f0242ac120004",
  441. "parser_method": "manual",
  442. "parser_config": {"chunk_token_count": 128, "delimiter": "\n!?。;!?", "layout_recognize": true, "task_page_size": 12},
  443. "source_type": "local", "type": "doc",
  444. "created_by": "134408906b6811efbcd20242ac120005",
  445. "size": 0, "token_count": 0, "chunk_count": 0,
  446. "progress": 0.0,
  447. "progress_msg": "",
  448. "process_begin_at": null,
  449. "process_duration": 0.0
  450. }'
  451. ```
  452. #### Request parameters
  453. - `"document_id"`: (*Body parameter*)
  454. - `"document_name"`: (*Body parameter*)
  455. ### Response
  456. The successful response includes a JSON object like the following:
  457. ```shell
  458. {
  459. "code": 0
  460. }
  461. ```
  462. The error response includes a JSON object like the following:
  463. ```shell
  464. {
  465. "code": 3016,
  466. "message": "Can't connect database"
  467. }
  468. ```
  469. ## Parse files in dataset
  470. **POST** `/api/v1/dataset/{dataset_id}/chunk`
  471. Parse files into chunks in a dataset
  472. ### Request
  473. - Method: POST
  474. - URL: `/api/v1/dataset/{dataset_id}/chunk`
  475. - Headers:
  476. - `content-Type: application/json`
  477. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  478. #### Request example
  479. ```shell
  480. curl --request POST \
  481. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  482. --header 'Content-Type: application/json' \
  483. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  484. --raw '{
  485. "documents": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  486. }'
  487. ```
  488. #### Request parameters
  489. - `"dataset_id"`: (*Path parameter*)
  490. - `"documents"`: (*Body parameter*)
  491. - Documents to parse
  492. ### Response
  493. The successful response includes a JSON object like the following:
  494. ```shell
  495. {
  496. "code": 0
  497. }
  498. ```
  499. The error response includes a JSON object like the following:
  500. ```shell
  501. {
  502. "code": 3016,
  503. "message": "Can't connect database"
  504. }
  505. ```
  506. ## Stop file parsing
  507. **DELETE** `/api/v1/dataset/{dataset_id}/chunk`
  508. Stop file parsing
  509. ### Request
  510. - Method: POST
  511. - URL: `/api/v1/dataset/{dataset_id}/chunk`
  512. - Headers:
  513. - `content-Type: application/json`
  514. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  515. #### Request example
  516. ```shell
  517. curl --request DELETE \
  518. --url http://{address}/api/v1/dataset/{dataset_id}/chunk \
  519. --header 'Content-Type: application/json' \
  520. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  521. --raw '{
  522. "documents": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  523. }'
  524. ```
  525. #### Request parameters
  526. - `"dataset_id"`: (*Path parameter*)
  527. - `"documents"`: (*Body parameter*)
  528. - Documents to stop parsing
  529. ### Response
  530. The successful response includes a JSON object like the following:
  531. ```shell
  532. {
  533. "code": 0
  534. }
  535. ```
  536. The error response includes a JSON object like the following:
  537. ```shell
  538. {
  539. "code": 3016,
  540. "message": "Can't connect database"
  541. }
  542. ```
  543. ## Get document chunk list
  544. **GET** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  545. Get document chunk list
  546. ### Request
  547. - Method: GET
  548. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  549. - Headers:
  550. - `content-Type: application/json`
  551. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  552. #### Request example
  553. ```shell
  554. curl --request GET \
  555. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  556. --header 'Content-Type: application/json' \
  557. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  558. ```
  559. #### Request parameters
  560. - `"dataset_id"`: (*Path parameter*)
  561. - `"document_id"`: (*Path parameter*)
  562. ### Response
  563. The successful response includes a JSON object like the following:
  564. ```shell
  565. {
  566. "code": 0
  567. "data": {
  568. "chunks": [
  569. {
  570. "available_int": 1,
  571. "content": "<em>advantag</em>of ragflow increas accuraci and relev:by incorpor retriev inform , ragflow can gener respons that are more accur",
  572. "document_keyword": "ragflow_test.txt",
  573. "document_id": "77df9ef4759a11ef8bdd0242ac120004",
  574. "id": "4ab8c77cfac1a829c8d5ed022a0808c0",
  575. "image_id": "",
  576. "important_keywords": [],
  577. "positions": [
  578. ""
  579. ]
  580. }
  581. ],
  582. "doc": {
  583. "chunk_count": 5,
  584. "create_date": "Wed, 18 Sep 2024 08:46:16 GMT",
  585. "create_time": 1726649176833,
  586. "created_by": "134408906b6811efbcd20242ac120005",
  587. "id": "77df9ef4759a11ef8bdd0242ac120004",
  588. "knowledgebase_id": "77d9d24e759a11ef880c0242ac120004",
  589. "location": "ragflow_test.txt",
  590. "name": "ragflow_test.txt",
  591. "parser_config": {
  592. "chunk_token_count": 128,
  593. "delimiter": "\n!?。;!?",
  594. "layout_recognize": true,
  595. "task_page_size": 12
  596. },
  597. "parser_method": "naive",
  598. "process_begin_at": "Wed, 18 Sep 2024 08:46:16 GMT",
  599. "process_duation": 7.3213,
  600. "progress": 1.0,
  601. "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!",
  602. "run": "3",
  603. "size": 4209,
  604. "source_type": "local",
  605. "status": "1",
  606. "thumbnail": null,
  607. "token_count": 746,
  608. "type": "doc",
  609. "update_date": "Wed, 18 Sep 2024 08:46:23 GMT",
  610. "update_time": 1726649183321
  611. },
  612. "total": 1
  613. },
  614. }
  615. ```
  616. The error response includes a JSON object like the following:
  617. ```shell
  618. {
  619. "code": 3016,
  620. "message": "Can't connect database"
  621. }
  622. ```
  623. ## Delete document chunks
  624. **DELETE** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  625. Delete document chunks
  626. ### Request
  627. - Method: DELETE
  628. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  629. - Headers:
  630. - `content-Type: application/json`
  631. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  632. #### Request example
  633. ```shell
  634. curl --request DELETE \
  635. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  636. --header 'Content-Type: application/json' \
  637. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  638. --raw '{
  639. "chunks": ["f6b170ac758811efa0660242ac120004", "97ad64b6759811ef9fc30242ac120004"]
  640. }'
  641. ```
  642. ## Update document chunk
  643. **PUT** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  644. Update document chunk
  645. ### Request
  646. - Method: PUT
  647. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  648. - Headers:
  649. - `content-Type: application/json`
  650. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  651. #### Request example
  652. ```shell
  653. curl --request PUT \
  654. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  655. --header 'Content-Type: application/json' \
  656. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  657. --raw '{
  658. "chunk_id": "d87fb0b7212c15c18d0831677552d7de",
  659. "knowledgebase_id": null,
  660. "name": "",
  661. "content": "ragflow123",
  662. "important_keywords": [],
  663. "document_id": "e6bbba92759511efaa900242ac120004",
  664. "status": "1"
  665. }'
  666. ```
  667. ## Insert document chunks
  668. **POST** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  669. Insert document chunks
  670. ### Request
  671. - Method: POST
  672. - URL: `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
  673. - Headers:
  674. - `content-Type: application/json`
  675. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  676. #### Request example
  677. ```shell
  678. curl --request POST \
  679. --url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
  680. --header 'Content-Type: application/json' \
  681. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  682. --raw '{
  683. "document_id": "97ad64b6759811ef9fc30242ac120004",
  684. "content": ["ragflow content", "ragflow content"]
  685. }'
  686. ```
  687. ## Dataset retrieval test
  688. **GET** `/api/v1/dataset/{dataset_id}/retrieval`
  689. Retrieval test of a dataset
  690. ### Request
  691. - Method: GET
  692. - URL: `/api/v1/dataset/{dataset_id}/retrieval`
  693. - Headers:
  694. - `content-Type: application/json`
  695. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  696. #### Request example
  697. ```shell
  698. curl --request GET \
  699. --url http://{address}/api/v1/dataset/{dataset_id}/retrieval \
  700. --header 'Content-Type: application/json' \
  701. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  702. --raw '{
  703. "query_text": "This is a cat."
  704. }'
  705. ```
  706. ## Create chat
  707. **POST** `/api/v1/chat`
  708. Create a chat
  709. ### Request
  710. - Method: POST
  711. - URL: `/api/v1/chat`
  712. - Headers:
  713. - `content-Type: application/json`
  714. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  715. #### Request example
  716. ```shell
  717. curl --request POST \
  718. --url http://{address}/api/v1/chat \
  719. --header 'Content-Type: application/json' \
  720. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  721. --data-binary '{
  722. "avatar": "path",
  723. "create_date": "Wed, 04 Sep 2024 10:08:01 GMT",
  724. "create_time": 1725444481128,
  725. "description": "A helpful Assistant",
  726. "do_refer": "",
  727. "knowledgebases": [
  728. {
  729. "avatar": null,
  730. "chunk_count": 0,
  731. "description": null,
  732. "document_count": 0,
  733. "embedding_model": "",
  734. "id": "d6d0e8e868cd11ef92250242ac120006",
  735. "language": "English",
  736. "name": "Test_assistant",
  737. "parse_method": "naive",
  738. "parser_config": {
  739. "pages": [
  740. [
  741. 1,
  742. 1000000
  743. ]
  744. ]
  745. },
  746. "permission": "me",
  747. "tenant_id": "4fb0cd625f9311efba4a0242ac120006"
  748. }
  749. ],
  750. "language": "English",
  751. "llm": {
  752. "frequency_penalty": 0.7,
  753. "max_tokens": 512,
  754. "model_name": "deepseek-chat",
  755. "presence_penalty": 0.4,
  756. "temperature": 0.1,
  757. "top_p": 0.3
  758. },
  759. "name": "Miss R",
  760. "prompt": {
  761. "empty_response": "Sorry! Can't find the context!",
  762. "keywords_similarity_weight": 0.7,
  763. "opener": "Hi! I am your assistant, what can I do for you?",
  764. "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.\nHere is the knowledge base:\n{knowledge}\nThe above is the knowledge base.",
  765. "rerank_model": "",
  766. "show_quote": true,
  767. "similarity_threshold": 0.2,
  768. "top_n": 8,
  769. "variables": [
  770. {
  771. "key": "knowledge",
  772. "optional": true
  773. }
  774. ]
  775. },
  776. "prompt_type": "simple",
  777. "status": "1",
  778. "top_k": 1024,
  779. "update_date": "Wed, 04 Sep 2024 10:08:01 GMT",
  780. "update_time": 1725444481128
  781. }'
  782. ```
  783. ## Update chat
  784. **PUT** `/api/v1/chat`
  785. Update a chat
  786. ### Request
  787. - Method: PUT
  788. - URL: `/api/v1/chat`
  789. - Headers:
  790. - `content-Type: application/json`
  791. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  792. #### Request example
  793. curl --request PUT \
  794. --url http://{address}/api/v1/chat \
  795. --header 'Content-Type: application/json' \
  796. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  797. --data-binary '{
  798. "id":"554e96746aaa11efb06b0242ac120005",
  799. "name":"Test"
  800. }'
  801. ## Delete chat
  802. **DELETE** `/api/v1/chat/{chat_id}`
  803. Delete a chat
  804. ### Request
  805. - Method: PUT
  806. - URL: `/api/v1/chat/{chat_id}`
  807. - Headers:
  808. - `content-Type: application/json`
  809. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  810. #### Request example
  811. curl --request PUT \
  812. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005 \
  813. --header 'Content-Type: application/json' \
  814. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  815. }'
  816. ## List chat
  817. **GET** `/api/v1/chat`
  818. List all chat assistants
  819. ### Request
  820. - Method: GET
  821. - URL: `/api/v1/chat`
  822. - Headers:
  823. - `content-Type: application/json`
  824. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  825. #### Request example
  826. curl --request GET \
  827. --url http://{address}/api/v1/chat \
  828. --header 'Content-Type: application/json' \
  829. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  830. ## Create a chat session
  831. **POST** `/api/v1/chat/{chat_id}/session`
  832. Create a chat session
  833. ### Request
  834. - Method: POST
  835. - URL: `/api/v1/chat/{chat_id}/session`
  836. - Headers:
  837. - `content-Type: application/json`
  838. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  839. #### Request example
  840. curl --request POST \
  841. --url http://{address}/api/v1/chat/{chat_id}/session \
  842. --header 'Content-Type: application/json' \
  843. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
  844. --data-binary '{
  845. "name": "new session"
  846. }'
  847. ## List the sessions of a chat
  848. **GET** `/api/v1/chat/{chat_id}/session`
  849. List all the session of a chat
  850. ### Request
  851. - Method: GET
  852. - URL: `/api/v1/chat/{chat_id}/session`
  853. - Headers:
  854. - `content-Type: application/json`
  855. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  856. #### Request example
  857. curl --request GET \
  858. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session \
  859. --header 'Content-Type: application/json' \
  860. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  861. ## Delete a chat session
  862. **DELETE** `/api/v1/chat/{chat_id}/session/{session_id}`
  863. Delete a chat session
  864. ### Request
  865. - Method: DELETE
  866. - URL: `/api/v1/chat/{chat_id}/session/{session_id}`
  867. - Headers:
  868. - `content-Type: application/json`
  869. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  870. #### Request example
  871. curl --request DELETE \
  872. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007 \
  873. --header 'Content-Type: application/json' \
  874. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  875. ## Update a chat session
  876. **PUT** `/api/v1/chat/{chat_id}/session/{session_id}`
  877. Update a chat session
  878. ### Request
  879. - Method: PUT
  880. - URL: `/api/v1/chat/{chat_id}/session/{session_id}`
  881. - Headers:
  882. - `content-Type: application/json`
  883. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  884. #### Request example
  885. curl --request PUT \
  886. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007 \
  887. --header 'Content-Type: application/json' \
  888. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  889. --data-binary '{
  890. "name": "Updated session"
  891. }'
  892. ## Chat with a chat session
  893. **POST** `/api/v1/chat/{chat_id}/session/{session_id}/completion`
  894. Chat with a chat session
  895. ### Request
  896. - Method: POST
  897. - URL: `/api/v1/chat/{chat_id}/session/{session_id}/completion`
  898. - Headers:
  899. - `content-Type: application/json`
  900. - 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  901. #### Request example
  902. curl --request POST \
  903. --url http://{address}/api/v1/chat/554e96746aaa11efb06b0242ac120005/session/791aed9670ea11efbb7e0242ac120007/completion \
  904. --header 'Content-Type: application/json' \
  905. --header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
  906. --data-binary '{
  907. "question": "Hello!",
  908. "stream": true,
  909. }'