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.

ragflow_api.md 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. ---
  2. sidebar_class_name: hidden
  3. ---
  4. # API reference
  5. RAGFlow offers RESTful APIs for you to integrate its capabilities into third-party applications.
  6. ## Base URL
  7. ```
  8. http://<host_address>/api/v1/
  9. ```
  10. ## Dataset URL
  11. ```
  12. http://<host_address>/api/v1/dataset
  13. ```
  14. ## Authorization
  15. All of RAGFlow's RESTFul APIs use API key for authorization, so keep it safe and do not expose it to the front end.
  16. Put your API key in the request header.
  17. ```buildoutcfg
  18. Authorization: Bearer {API_KEY}
  19. ```
  20. To get your API key:
  21. 1. In RAGFlow, click **Chat** tab in the middle top of the page.
  22. 2. Hover over the corresponding dialogue **>** **Chat Bot API** to show the chatbot API configuration page.
  23. 3. Click **Api Key** **>** **Create new key** to create your API key.
  24. 4. Copy and keep your API key safe.
  25. ## Create dataset
  26. This method creates (news) a dataset for a specific user.
  27. ### Request
  28. #### Request URI
  29. | Method | Request URI |
  30. |--------|-------------|
  31. | POST | `/dataset` |
  32. :::note
  33. You are *required* to save the `data.dataset_id` value returned in the response data, which is the session ID for all upcoming conversations.
  34. :::
  35. #### Request parameter
  36. | Name | Type | Required | Description |
  37. |----------------|--------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  38. | `dataset_name` | string | Yes | The unique identifier assigned to each newly created dataset. `dataset_name` must be less than 2 ** 10 characters and cannot be empty. The following character sets are supported: <br />- 26 lowercase English letters (a-z)<br />- 26 uppercase English letters (A-Z)<br />- 10 digits (0-9)<br />- "_", "-", "." |
  39. ### Response
  40. ```json
  41. {
  42. "code": 0,
  43. "data": {
  44. "dataset_name": "kb1",
  45. "dataset_id": "375e8ada2d3c11ef98f93043d7ee537e"
  46. },
  47. "message": "success"
  48. }
  49. ```
  50. ## Get dataset list
  51. This method lists the created datasets for a specific user.
  52. ### Request
  53. #### Request URI
  54. | Method | Request URI |
  55. |----------|-------------|
  56. | GET | `/dataset` |
  57. ### Response
  58. #### Response parameter
  59. ```json
  60. {
  61. "code": 0,
  62. "data": [
  63. {
  64. "avatar": null,
  65. "chunk_num": 0,
  66. "create_date": "Mon, 17 Jun 2024 16:00:05 GMT",
  67. "create_time": 1718611205876,
  68. "created_by": "b48110a0286411ef994a3043d7ee537e",
  69. "description": null,
  70. "doc_num": 0,
  71. "embd_id": "BAAI/bge-large-zh-v1.5",
  72. "id": "9bd6424a2c7f11ef81b83043d7ee537e",
  73. "language": "Chinese",
  74. "name": "dataset3(23)",
  75. "parser_config": {
  76. "pages": [
  77. [
  78. 1,
  79. 1000000
  80. ]
  81. ]
  82. },
  83. "parser_id": "naive",
  84. "permission": "me",
  85. "similarity_threshold": 0.2,
  86. "status": "1",
  87. "tenant_id": "b48110a0286411ef994a3043d7ee537e",
  88. "token_num": 0,
  89. "update_date": "Mon, 17 Jun 2024 16:00:05 GMT",
  90. "update_time": 1718611205876,
  91. "vector_similarity_weight": 0.3
  92. }
  93. ],
  94. "message": "List datasets successfully!"
  95. }
  96. ```
  97. ## Delete dataset
  98. This method deletes a dataset for a specific user.
  99. ### Request
  100. #### Request URI
  101. | Method | Request URI |
  102. |--------|-------------------------|
  103. | DELETE | `/dataset/{dataset_id}` |
  104. #### Request parameter
  105. | Name | Type | Required | Description |
  106. |--------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  107. | `dataset_id` | string | Yes | The ID of the dataset. Call ['GET' /dataset](#create-dataset) to retrieve the ID. |
  108. ### Response
  109. ```json
  110. {
  111. "code": 0,
  112. "message": "Remove dataset: 9cefaefc2e2611ef916b3043d7ee537e successfully"
  113. }
  114. ```
  115. ### Get the details of the specific dataset
  116. This method gets the details of the specific dataset.
  117. ### Request
  118. #### Request URI
  119. | Method | Request URI |
  120. |----------|-------------------------|
  121. | GET | `/dataset/{dataset_id}` |
  122. #### Request parameter
  123. | Name | Type | Required | Description |
  124. |--------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  125. | `dataset_id` | string | Yes | The ID of the dataset. Call ['GET' /dataset](#create-dataset) to retrieve the ID. |
  126. ### Response
  127. ```json
  128. {
  129. "code": 0,
  130. "data": {
  131. "avatar": null,
  132. "chunk_num": 0,
  133. "description": null,
  134. "doc_num": 0,
  135. "embd_id": "BAAI/bge-large-zh-v1.5",
  136. "id": "060323022e3511efa8263043d7ee537e",
  137. "language": "Chinese",
  138. "name": "test(1)",
  139. "parser_config":
  140. {
  141. "pages": [[1, 1000000]]
  142. },
  143. "parser_id": "naive",
  144. "permission": "me",
  145. "token_num": 0
  146. },
  147. "message": "success"
  148. }
  149. ```
  150. ### Update the details of the specific dataset
  151. This method updates the details of the specific dataset.
  152. ### Request
  153. #### Request URI
  154. | Method | Request URI |
  155. |--------|-------------------------|
  156. | PUT | `/dataset/{dataset_id}` |
  157. #### Request parameter
  158. You are required to input at least one parameter.
  159. | Name | Type | Required | Description |
  160. |----------------------|--------|----------|-----------------------------------------------------------------------|
  161. | `name` | string | No | The name of the knowledge base, from which you get the document list. |
  162. | `description` | string | No | The description of the knowledge base. |
  163. | `permission` | string | No | The permission for the knowledge base, default:me. |
  164. | `language` | string | No | The language of the knowledge base. |
  165. | `chunk_method` | string | No | The chunk method of the knowledge base. |
  166. | `embedding_model_id` | string | No | The embedding model id of the knowledge base. |
  167. | `photo` | string | No | The photo of the knowledge base. |
  168. | `layout_recognize` | bool | No | The layout recognize of the knowledge base. |
  169. | `token_num` | int | No | The token number of the knowledge base. |
  170. | `id` | string | No | The id of the knowledge base. |
  171. ### Response
  172. ### Successful response
  173. ```json
  174. {
  175. "code": 0,
  176. "data": {
  177. "avatar": null,
  178. "chunk_num": 0,
  179. "create_date": "Wed, 19 Jun 2024 20:33:34 GMT",
  180. "create_time": 1718800414518,
  181. "created_by": "b48110a0286411ef994a3043d7ee537e",
  182. "description": "new_description1",
  183. "doc_num": 0,
  184. "embd_id": "BAAI/bge-large-zh-v1.5",
  185. "id": "24f9f17a2e3811ef820e3043d7ee537e",
  186. "language": "English",
  187. "name": "new_name",
  188. "parser_config":
  189. {
  190. "pages": [[1, 1000000]]
  191. },
  192. "parser_id": "naive",
  193. "permission": "me",
  194. "similarity_threshold": 0.2,
  195. "status": "1",
  196. "tenant_id": "b48110a0286411ef994a3043d7ee537e",
  197. "token_num": 0,
  198. "update_date": "Wed, 19 Jun 2024 20:33:34 GMT",
  199. "update_time": 1718800414529,
  200. "vector_similarity_weight": 0.3
  201. },
  202. "message": "success"
  203. }
  204. ```
  205. ### Response for the operating error
  206. ```json
  207. {
  208. "code": 103,
  209. "message": "Only the owner of knowledgebase is authorized for this operation!"
  210. }
  211. ```
  212. ### Response for no parameter
  213. ```json
  214. {
  215. "code": 102,
  216. "message": "Please input at least one parameter that you want to update!"
  217. }
  218. ```