writinwaters
commited on
Commit
·
2885106
1
Parent(s):
c22c7b5
Miscellaneous updates to HTTP and PYthon APIs (#3000)
Browse files### What problem does this PR solve?
### Type of change
- [x] Documentation Update
- api/http_api_reference.md +216 -203
- api/python_api_reference.md +17 -16
api/http_api_reference.md
CHANGED
@@ -37,17 +37,15 @@ Creates a dataset.
|
|
37 |
#### Request example
|
38 |
|
39 |
```bash
|
40 |
-
# "name": name is required and can't be duplicated.
|
41 |
-
# "embedding_model": embedding_model must not be provided.
|
42 |
-
# "naive" means general.
|
43 |
curl --request POST \
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
```
|
52 |
|
53 |
#### Request parameters
|
@@ -97,7 +95,7 @@ curl --request POST \
|
|
97 |
- `"parser_config"`: (*Body parameter*)
|
98 |
The configuration settings for the dataset parser. A `ParserConfig` object contains the following attributes:
|
99 |
- `"chunk_token_count"`: Defaults to `128`.
|
100 |
-
- `"layout_recognize"`: Defaults to `
|
101 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
102 |
- `"task_page_size"`: Defaults to `12`.
|
103 |
|
@@ -168,24 +166,20 @@ Deletes datasets by ID.
|
|
168 |
- Body:
|
169 |
- `"ids"`: `list[string]`
|
170 |
|
171 |
-
|
172 |
#### Request example
|
173 |
|
174 |
```bash
|
175 |
-
# Either id or name must be provided, but not both.
|
176 |
curl --request DELETE \
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
"ids": ["test_1", "test_2"]
|
182 |
-
}'
|
183 |
```
|
184 |
|
185 |
#### Request parameters
|
186 |
|
187 |
-
- `"ids"`: (*Body parameter*)
|
188 |
-
The IDs of the datasets to delete.
|
189 |
|
190 |
### Response
|
191 |
|
@@ -221,34 +215,33 @@ Updates configurations for a specified dataset.
|
|
221 |
- Headers:
|
222 |
- `'content-Type: application/json'`
|
223 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
|
229 |
#### Request example
|
230 |
|
231 |
```bash
|
232 |
-
# "id": id is required.
|
233 |
-
# "name": If you update name, it can't be duplicated.
|
234 |
-
# "embedding_model": If you update embedding_model, it can't be changed.
|
235 |
-
# "parse_method": If you update parse_method, chunk_count must be 0.
|
236 |
-
# "naive" means general.
|
237 |
curl --request PUT \
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
246 |
```
|
247 |
|
248 |
#### Request parameters
|
249 |
|
250 |
-
- `
|
251 |
-
|
|
|
|
|
|
|
252 |
- Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
|
253 |
- `"chunk_method"`: `enum<string>` The chunking method for the dataset. Available options:
|
254 |
- `"naive"`: General
|
@@ -298,35 +291,30 @@ Lists datasets.
|
|
298 |
- Headers:
|
299 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
300 |
|
301 |
-
|
302 |
#### Request example
|
303 |
|
304 |
```bash
|
305 |
-
# If no page parameter is passed, the default is 1
|
306 |
-
# If no page_size parameter is passed, the default is 1024
|
307 |
-
# If no order_by parameter is passed, the default is "create_time"
|
308 |
-
# If no desc parameter is passed, the default is True
|
309 |
curl --request GET \
|
310 |
-
|
311 |
-
|
312 |
```
|
313 |
|
314 |
#### Request parameters
|
315 |
|
316 |
-
- `
|
317 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
318 |
-
- `
|
319 |
The number of datasets on each page. Defaults to `1024`.
|
320 |
-
- `
|
321 |
The field by which datasets should be sorted. Available options:
|
322 |
-
- `
|
323 |
-
- `
|
324 |
-
- `
|
325 |
-
Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `
|
326 |
-
- `
|
327 |
-
The ID of the dataset to retrieve.
|
328 |
-
- `"name"`: (*Path parameter*)
|
329 |
The name of the dataset to retrieve.
|
|
|
|
|
330 |
|
331 |
### Response
|
332 |
|
@@ -467,14 +455,15 @@ Updates configurations for a specified document.
|
|
467 |
|
468 |
```bash
|
469 |
curl --request PUT \
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
|
|
478 |
|
479 |
```
|
480 |
|
@@ -498,7 +487,7 @@ curl --request PUT \
|
|
498 |
- `"parser_config"`: (*Body parameter*), `object`
|
499 |
The parsing configuration for the document:
|
500 |
- `"chunk_token_count"`: Defaults to `128`.
|
501 |
-
- `"layout_recognize"`: Defaults to `
|
502 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
503 |
- `"task_page_size"`: Defaults to `12`.
|
504 |
|
@@ -542,14 +531,14 @@ Downloads a document from a specified dataset.
|
|
542 |
|
543 |
```bash
|
544 |
curl --request GET \
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
```
|
549 |
|
550 |
#### Request parameters
|
551 |
|
552 |
-
- `"dataset_id"`: (*Path parameter*)
|
553 |
The dataset ID.
|
554 |
- `"documents_id"`: (*Path parameter*)
|
555 |
The ID of the document to download.
|
@@ -582,7 +571,7 @@ Lists documents in a specified dataset.
|
|
582 |
### Request
|
583 |
|
584 |
- Method: GET
|
585 |
-
- URL: `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name`
|
586 |
- Headers:
|
587 |
- `'content-Type: application/json'`
|
588 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
@@ -591,8 +580,8 @@ Lists documents in a specified dataset.
|
|
591 |
|
592 |
```bash
|
593 |
curl --request GET \
|
594 |
-
|
595 |
-
|
596 |
```
|
597 |
|
598 |
#### Request parameters
|
@@ -610,8 +599,8 @@ curl --request GET \
|
|
610 |
- `"create_time"` (default)
|
611 |
- `"update_time"`
|
612 |
- `"desc"`: (*Filter parameter*), `boolean`
|
613 |
-
Indicates whether the retrieved documents should be sorted in descending order. Defaults to `
|
614 |
-
- `"
|
615 |
The ID of the document to retrieve.
|
616 |
|
617 |
### Response
|
@@ -690,16 +679,19 @@ Deletes documents by ID.
|
|
690 |
|
691 |
```bash
|
692 |
curl --request DELETE \
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
|
|
699 |
```
|
700 |
|
701 |
#### Request parameters
|
702 |
|
|
|
|
|
703 |
- `"ids"`: (*Body parameter*), `list[string]`
|
704 |
The IDs of the documents to delete. If not specified, all documents in the dataset will be deleted.
|
705 |
|
@@ -744,17 +736,20 @@ Parses documents in a specified dataset.
|
|
744 |
|
745 |
```bash
|
746 |
curl --request POST \
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
|
|
|
|
|
|
751 |
```
|
752 |
|
753 |
#### Request parameters
|
754 |
|
755 |
- `"dataset_id"`: (*Path parameter*)
|
756 |
The dataset ID.
|
757 |
-
- `"document_ids"`: (*Body parameter*), `list[string]
|
758 |
The IDs of the documents to parse.
|
759 |
|
760 |
### Response
|
@@ -798,10 +793,13 @@ Stops parsing specified documents.
|
|
798 |
|
799 |
```bash
|
800 |
curl --request DELETE \
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
|
|
|
|
|
|
805 |
```
|
806 |
|
807 |
#### Request parameters
|
@@ -832,7 +830,6 @@ Failure:
|
|
832 |
|
833 |
---
|
834 |
|
835 |
-
|
836 |
## Add chunks
|
837 |
|
838 |
**POST** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
|
@@ -854,12 +851,13 @@ Adds a chunk to a specified document in a specified dataset.
|
|
854 |
|
855 |
```bash
|
856 |
curl --request POST \
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
|
|
863 |
```
|
864 |
|
865 |
#### Request parameters
|
@@ -920,8 +918,8 @@ Lists chunks in a specified document.
|
|
920 |
|
921 |
```bash
|
922 |
curl --request GET \
|
923 |
-
|
924 |
-
|
925 |
```
|
926 |
|
927 |
#### Request parameters
|
@@ -1016,12 +1014,13 @@ Deletes chunks by ID.
|
|
1016 |
|
1017 |
```bash
|
1018 |
curl --request DELETE \
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
|
|
1025 |
```
|
1026 |
|
1027 |
#### Request parameters
|
@@ -1072,13 +1071,14 @@ Updates content or configurations for a specified chunk.
|
|
1072 |
|
1073 |
```bash
|
1074 |
curl --request PUT \
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
|
|
1082 |
```
|
1083 |
|
1084 |
#### Request parameters
|
@@ -1089,8 +1089,8 @@ curl --request PUT \
|
|
1089 |
A list of key terms or phrases to tag with the chunk.
|
1090 |
- `"available"`: (*Body parameter*) `boolean`
|
1091 |
The chunk's availability status in the dataset. Value options:
|
1092 |
-
- `
|
1093 |
-
- `
|
1094 |
|
1095 |
### Response
|
1096 |
|
@@ -1128,8 +1128,8 @@ Retrieves chunks from specified datasets.
|
|
1128 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
1129 |
- Body:
|
1130 |
- `"question"`: `string`
|
1131 |
-
- `"
|
1132 |
-
- `"
|
1133 |
- `"offset"`: `integer`
|
1134 |
- `"limit"`: `integer`
|
1135 |
- `"similarity_threshold"`: `float`
|
@@ -1143,27 +1143,24 @@ Retrieves chunks from specified datasets.
|
|
1143 |
|
1144 |
```bash
|
1145 |
curl --request POST \
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
"77df9ef4759a11ef8bdd0242ac120004"
|
1156 |
-
]
|
1157 |
-
}'
|
1158 |
```
|
1159 |
|
1160 |
#### Request parameter
|
1161 |
|
1162 |
- `"question"`: (*Body parameter*), `string`, *Required*
|
1163 |
The user query or query keywords. Defaults to `""`.
|
1164 |
-
- `"
|
1165 |
The IDs of the datasets to search from.
|
1166 |
-
- `"
|
1167 |
The IDs of the documents to search from.
|
1168 |
- `"offset"`: (*Body parameter*), `integer`
|
1169 |
The starting index for the documents to retrieve. Defaults to `1`.
|
@@ -1179,12 +1176,12 @@ curl --request POST \
|
|
1179 |
The ID of the rerank model.
|
1180 |
- `"keyword"`: (*Body parameter*), `boolean`
|
1181 |
Indicates whether to enable keyword-based matching:
|
1182 |
-
- `
|
1183 |
-
- `
|
1184 |
- `"highlight"`: (*Body parameter*), `boolean`
|
1185 |
Specifies whether to enable highlighting of matched terms in the results:
|
1186 |
-
- `
|
1187 |
-
- `
|
1188 |
|
1189 |
### Response
|
1190 |
|
@@ -1260,7 +1257,7 @@ Creates a chat assistant.
|
|
1260 |
- Body:
|
1261 |
- `"name"`: `string`
|
1262 |
- `"avatar"`: `string`
|
1263 |
-
- `"
|
1264 |
- `"llm"`: `object`
|
1265 |
- `"prompt"`: `object`
|
1266 |
|
@@ -1271,8 +1268,8 @@ curl --request POST \
|
|
1271 |
--url http://{address}/api/v1/chat \
|
1272 |
--header 'Content-Type: application/json' \
|
1273 |
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
1274 |
-
--data
|
1275 |
-
"
|
1276 |
{
|
1277 |
"avatar": null,
|
1278 |
"chunk_count": 0,
|
@@ -1305,7 +1302,7 @@ curl --request POST \
|
|
1305 |
The name of the chat assistant.
|
1306 |
- `"avatar"`: (*Body parameter*)
|
1307 |
Base64 encoding of the avatar. Defaults to `""`.
|
1308 |
-
- `"
|
1309 |
The IDs of the associated datasets. Defaults to `[""]`.
|
1310 |
- `"llm"`: (*Body parameter*), `object`
|
1311 |
The LLM settings for the chat assistant to create. When the value is `None`, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
|
@@ -1329,11 +1326,11 @@ curl --request POST \
|
|
1329 |
- `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
|
1330 |
- `"knowledge"` is a reserved variable, which will be replaced with the retrieved chunks.
|
1331 |
- All the variables in 'System' should be curly bracketed.
|
1332 |
-
- The default value is `[{"key": "knowledge", "optional":
|
1333 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
1334 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1335 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1336 |
-
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `
|
1337 |
- `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.
|
1338 |
Here is the knowledge base:
|
1339 |
{knowledge}
|
@@ -1438,7 +1435,7 @@ Updates configurations for a specified chat assistant.
|
|
1438 |
- Body:
|
1439 |
- `"name"`: `string`
|
1440 |
- `"avatar"`: `string`
|
1441 |
-
- `"
|
1442 |
- `"llm"`: `object`
|
1443 |
- `"prompt"`: `object`
|
1444 |
|
@@ -1446,21 +1443,24 @@ Updates configurations for a specified chat assistant.
|
|
1446 |
|
1447 |
```bash
|
1448 |
curl --request PUT \
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
|
|
1455 |
```
|
1456 |
|
1457 |
#### Parameters
|
1458 |
|
|
|
|
|
1459 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
1460 |
The name of the chat assistant.
|
1461 |
- `"avatar"`: (*Body parameter*)
|
1462 |
Base64 encoding of the avatar. Defaults to `""`.
|
1463 |
-
- `"
|
1464 |
The IDs of the associated datasets. Defaults to `[""]`.
|
1465 |
- `"llm"`: (*Body parameter*), `object`
|
1466 |
The LLM settings for the chat assistant to create. When the value is `None`, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
|
@@ -1484,11 +1484,11 @@ curl --request PUT \
|
|
1484 |
- `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
|
1485 |
- `"knowledge"` is a reserved variable, which will be replaced with the retrieved chunks.
|
1486 |
- All the variables in 'System' should be curly bracketed.
|
1487 |
-
- The default value is `[{"key": "knowledge", "optional":
|
1488 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
1489 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1490 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1491 |
-
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `
|
1492 |
- `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.
|
1493 |
Here is the knowledge base:
|
1494 |
{knowledge}
|
@@ -1534,15 +1534,14 @@ Deletes chat assistants by ID.
|
|
1534 |
#### Request example
|
1535 |
|
1536 |
```bash
|
1537 |
-
# Either id or name must be provided, but not both.
|
1538 |
curl --request DELETE \
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
}'
|
1546 |
```
|
1547 |
|
1548 |
#### Request parameters
|
@@ -1588,25 +1587,25 @@ Lists chat assistants.
|
|
1588 |
|
1589 |
```bash
|
1590 |
curl --request GET \
|
1591 |
-
|
1592 |
-
|
1593 |
```
|
1594 |
|
1595 |
#### Request parameters
|
1596 |
|
1597 |
-
- `
|
1598 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
1599 |
-
- `
|
1600 |
The number of chat assistants on each page. Defaults to `1024`.
|
1601 |
-
- `
|
1602 |
The attribute by which the results are sorted. Available options:
|
1603 |
- `"create_time"` (default)
|
1604 |
- `"update_time"`
|
1605 |
- `"desc"`: (*Path parameter*), `boolean`
|
1606 |
-
Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `
|
1607 |
-
- `
|
1608 |
The ID of the chat assistant to retrieve.
|
1609 |
-
- `
|
1610 |
The name of the chat assistant to retrieve.
|
1611 |
|
1612 |
### Response
|
@@ -1719,20 +1718,22 @@ Creates a chat session.
|
|
1719 |
|
1720 |
```bash
|
1721 |
curl --request POST \
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
|
|
1728 |
```
|
1729 |
|
1730 |
#### Request parameters
|
1731 |
|
|
|
|
|
1732 |
- `"name"`: (*Body parameter*), `string`
|
1733 |
The name of the chat session to create.
|
1734 |
|
1735 |
-
|
1736 |
### Response
|
1737 |
|
1738 |
Success:
|
@@ -1773,7 +1774,7 @@ Failure:
|
|
1773 |
|
1774 |
**PUT** `/api/v1/chat/{chat_id}/session/{session_id}`
|
1775 |
|
1776 |
-
|
1777 |
|
1778 |
### Request
|
1779 |
|
@@ -1788,17 +1789,21 @@ Update a chat session
|
|
1788 |
#### Request example
|
1789 |
```bash
|
1790 |
curl --request PUT \
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
```
|
1799 |
|
1800 |
#### Request Parameter
|
1801 |
|
|
|
|
|
|
|
|
|
1802 |
- `"name`: (*Body Parameter), `string`
|
1803 |
The name of the session to update.
|
1804 |
|
@@ -1840,12 +1845,14 @@ Lists sessions associated with a specified chat assistant.
|
|
1840 |
|
1841 |
```bash
|
1842 |
curl --request GET \
|
1843 |
-
|
1844 |
-
|
1845 |
```
|
1846 |
|
1847 |
#### Request Parameters
|
1848 |
|
|
|
|
|
1849 |
- `"page"`: (*Path parameter*), `integer`
|
1850 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1851 |
- `"page_size"`: (*Path parameter*), `integer`
|
@@ -1855,11 +1862,11 @@ curl --request GET \
|
|
1855 |
- `"create_time"` (default)
|
1856 |
- `"update_time"`
|
1857 |
- `"desc"`: (*Path parameter*), `boolean`
|
1858 |
-
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `
|
1859 |
-
- `"id"`: (*Path parameter*), `string`
|
1860 |
-
The ID of the chat session to retrieve.
|
1861 |
- `"name"`: (*Path parameter*) `string`
|
1862 |
The name of the chat session to retrieve.
|
|
|
|
|
1863 |
|
1864 |
### Response
|
1865 |
|
@@ -1920,16 +1927,19 @@ Deletes sessions by ID.
|
|
1920 |
```bash
|
1921 |
# Either id or name must be provided, but not both.
|
1922 |
curl --request DELETE \
|
1923 |
-
--url http://{address}/api/v1/chat/{chat_id}/session \
|
1924 |
-
--header 'Content-Type: application/json' \
|
1925 |
-
--header 'Authorization: Bear {YOUR_API_KEY}' \
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
|
|
1929 |
```
|
1930 |
|
1931 |
#### Request Parameters
|
1932 |
|
|
|
|
|
1933 |
- `"ids"`: (*Body Parameter*), `list[string]`
|
1934 |
The IDs of the sessions to delete. If not specified, all sessions associated with the current chat assistant will be deleted.
|
1935 |
|
@@ -1976,25 +1986,28 @@ Asks a question to start a conversation.
|
|
1976 |
|
1977 |
```bash
|
1978 |
curl --request POST \
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
|
|
1986 |
```
|
1987 |
|
1988 |
#### Request Parameters
|
1989 |
|
|
|
|
|
1990 |
- `"question"`: (*Body Parameter*), `string` *Required*
|
1991 |
The question to start an AI chat.
|
1992 |
- `"stream"`: (*Body Parameter*), `string`
|
1993 |
Indicates whether to output responses in a streaming way:
|
1994 |
-
- `
|
1995 |
-
- `
|
1996 |
- `"session_id"`: (*Body Parameter*)
|
1997 |
-
The ID of session. If not provided, a new session will be generated
|
1998 |
|
1999 |
### Response
|
2000 |
|
@@ -2107,4 +2120,4 @@ Failure:
|
|
2107 |
"code": 102,
|
2108 |
"message": "Please input your question."
|
2109 |
}
|
2110 |
-
```
|
|
|
37 |
#### Request example
|
38 |
|
39 |
```bash
|
|
|
|
|
|
|
40 |
curl --request POST \
|
41 |
+
--url http://{address}/api/v1/dataset \
|
42 |
+
--header 'Content-Type: application/json' \
|
43 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
44 |
+
--data '
|
45 |
+
{
|
46 |
+
"name": "test",
|
47 |
+
"chunk_method": "naive"
|
48 |
+
}'
|
49 |
```
|
50 |
|
51 |
#### Request parameters
|
|
|
95 |
- `"parser_config"`: (*Body parameter*)
|
96 |
The configuration settings for the dataset parser. A `ParserConfig` object contains the following attributes:
|
97 |
- `"chunk_token_count"`: Defaults to `128`.
|
98 |
+
- `"layout_recognize"`: Defaults to `true`.
|
99 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
100 |
- `"task_page_size"`: Defaults to `12`.
|
101 |
|
|
|
166 |
- Body:
|
167 |
- `"ids"`: `list[string]`
|
168 |
|
|
|
169 |
#### Request example
|
170 |
|
171 |
```bash
|
|
|
172 |
curl --request DELETE \
|
173 |
+
--url http://{address}/api/v1/dataset \
|
174 |
+
--header 'Content-Type: application/json' \
|
175 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
176 |
+
--data '{"ids": ["test_1", "test_2"]}'
|
|
|
|
|
177 |
```
|
178 |
|
179 |
#### Request parameters
|
180 |
|
181 |
+
- `"ids"`: (*Body parameter*), `list[string]`, *Required*
|
182 |
+
The IDs of the datasets to delete.
|
183 |
|
184 |
### Response
|
185 |
|
|
|
215 |
- Headers:
|
216 |
- `'content-Type: application/json'`
|
217 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
218 |
+
- Body:
|
219 |
+
- `"name"`: `string`
|
220 |
+
- `"embedding_model"`: `string`
|
221 |
+
- `"chunk_method"`: `enum<string>`
|
222 |
|
223 |
#### Request example
|
224 |
|
225 |
```bash
|
|
|
|
|
|
|
|
|
|
|
226 |
curl --request PUT \
|
227 |
+
--url http://{address}/api/v1/dataset/{dataset_id} \
|
228 |
+
--header 'Content-Type: application/json' \
|
229 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
230 |
+
--data '
|
231 |
+
{
|
232 |
+
"name": "test",
|
233 |
+
"embedding_model": "BAAI/bge-zh-v1.5",
|
234 |
+
"chunk_method": "naive"
|
235 |
+
}'
|
236 |
```
|
237 |
|
238 |
#### Request parameters
|
239 |
|
240 |
+
- `dataset_id`: (*Path parameter*)
|
241 |
+
The ID of the dataset to update.
|
242 |
+
- `"name"`: `string`
|
243 |
+
The name of the dataset to update.
|
244 |
+
- `"embedding_model"`: `string` The embedding model name to update.
|
245 |
- Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
|
246 |
- `"chunk_method"`: `enum<string>` The chunking method for the dataset. Available options:
|
247 |
- `"naive"`: General
|
|
|
291 |
- Headers:
|
292 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
293 |
|
|
|
294 |
#### Request example
|
295 |
|
296 |
```bash
|
|
|
|
|
|
|
|
|
297 |
curl --request GET \
|
298 |
+
--url http://{address}/api/v1/dataset?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
|
299 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
300 |
```
|
301 |
|
302 |
#### Request parameters
|
303 |
|
304 |
+
- `page`: (*Path parameter*)
|
305 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
306 |
+
- `page_size`: (*Path parameter*)
|
307 |
The number of datasets on each page. Defaults to `1024`.
|
308 |
+
- `orderby`: (*Path parameter*)
|
309 |
The field by which datasets should be sorted. Available options:
|
310 |
+
- `create_time` (default)
|
311 |
+
- `update_time`
|
312 |
+
- `desc`: (*Path parameter*)
|
313 |
+
Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
|
314 |
+
- `name`: (*Path parameter*)
|
|
|
|
|
315 |
The name of the dataset to retrieve.
|
316 |
+
- `id`: (*Path parameter*)
|
317 |
+
The ID of the dataset to retrieve.
|
318 |
|
319 |
### Response
|
320 |
|
|
|
455 |
|
456 |
```bash
|
457 |
curl --request PUT \
|
458 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/info/{document_id} \
|
459 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
460 |
+
--header 'Content-Type: application/json' \
|
461 |
+
--data '
|
462 |
+
{
|
463 |
+
"name": "manual.txt",
|
464 |
+
"chunk_method": "manual",
|
465 |
+
"parser_config": {"chunk_token_count": 128}
|
466 |
+
}'
|
467 |
|
468 |
```
|
469 |
|
|
|
487 |
- `"parser_config"`: (*Body parameter*), `object`
|
488 |
The parsing configuration for the document:
|
489 |
- `"chunk_token_count"`: Defaults to `128`.
|
490 |
+
- `"layout_recognize"`: Defaults to `true`.
|
491 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
492 |
- `"task_page_size"`: Defaults to `12`.
|
493 |
|
|
|
531 |
|
532 |
```bash
|
533 |
curl --request GET \
|
534 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id} \
|
535 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
536 |
+
--output ./ragflow.txt
|
537 |
```
|
538 |
|
539 |
#### Request parameters
|
540 |
|
541 |
+
- `"dataset_id"`: (*Path parameter*)
|
542 |
The dataset ID.
|
543 |
- `"documents_id"`: (*Path parameter*)
|
544 |
The ID of the document to download.
|
|
|
571 |
### Request
|
572 |
|
573 |
- Method: GET
|
574 |
+
- URL: `/api/v1/dataset/{dataset_id}/info?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name}`
|
575 |
- Headers:
|
576 |
- `'content-Type: application/json'`
|
577 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
|
|
580 |
|
581 |
```bash
|
582 |
curl --request GET \
|
583 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/info?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id} \
|
584 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
585 |
```
|
586 |
|
587 |
#### Request parameters
|
|
|
599 |
- `"create_time"` (default)
|
600 |
- `"update_time"`
|
601 |
- `"desc"`: (*Filter parameter*), `boolean`
|
602 |
+
Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
|
603 |
+
- `"id"`: (*Filter parameter*), `string`
|
604 |
The ID of the document to retrieve.
|
605 |
|
606 |
### Response
|
|
|
679 |
|
680 |
```bash
|
681 |
curl --request DELETE \
|
682 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document \
|
683 |
+
--header 'Content-Type: application/json' \
|
684 |
+
--header 'Authorization: {YOUR_API_KEY}' \
|
685 |
+
--data '
|
686 |
+
{
|
687 |
+
"ids": ["id_1","id_2"]
|
688 |
+
}'
|
689 |
```
|
690 |
|
691 |
#### Request parameters
|
692 |
|
693 |
+
- `"dataset_id"`: (*Path parameter*)
|
694 |
+
The dataset ID.
|
695 |
- `"ids"`: (*Body parameter*), `list[string]`
|
696 |
The IDs of the documents to delete. If not specified, all documents in the dataset will be deleted.
|
697 |
|
|
|
736 |
|
737 |
```bash
|
738 |
curl --request POST \
|
739 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/chunk \
|
740 |
+
--header 'Content-Type: application/json' \
|
741 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
742 |
+
--data '
|
743 |
+
{
|
744 |
+
"document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
|
745 |
+
}'
|
746 |
```
|
747 |
|
748 |
#### Request parameters
|
749 |
|
750 |
- `"dataset_id"`: (*Path parameter*)
|
751 |
The dataset ID.
|
752 |
+
- `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
|
753 |
The IDs of the documents to parse.
|
754 |
|
755 |
### Response
|
|
|
793 |
|
794 |
```bash
|
795 |
curl --request DELETE \
|
796 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/chunk \
|
797 |
+
--header 'Content-Type: application/json' \
|
798 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
799 |
+
--data '
|
800 |
+
{
|
801 |
+
"document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
|
802 |
+
}'
|
803 |
```
|
804 |
|
805 |
#### Request parameters
|
|
|
830 |
|
831 |
---
|
832 |
|
|
|
833 |
## Add chunks
|
834 |
|
835 |
**POST** `/api/v1/dataset/{dataset_id}/document/{document_id}/chunk`
|
|
|
851 |
|
852 |
```bash
|
853 |
curl --request POST \
|
854 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
|
855 |
+
--header 'Content-Type: application/json' \
|
856 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
857 |
+
--data '
|
858 |
+
{
|
859 |
+
"content": "<SOME_CHUNK_CONTENT_HERE>"
|
860 |
+
}'
|
861 |
```
|
862 |
|
863 |
#### Request parameters
|
|
|
918 |
|
919 |
```bash
|
920 |
curl --request GET \
|
921 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk?keywords={keywords}&offset={offset}&limit={limit}&id={id} \
|
922 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
923 |
```
|
924 |
|
925 |
#### Request parameters
|
|
|
1014 |
|
1015 |
```bash
|
1016 |
curl --request DELETE \
|
1017 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk \
|
1018 |
+
--header 'Content-Type: application/json' \
|
1019 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1020 |
+
--data '
|
1021 |
+
{
|
1022 |
+
"chunk_ids": ["test_1", "test_2"]
|
1023 |
+
}'
|
1024 |
```
|
1025 |
|
1026 |
#### Request parameters
|
|
|
1071 |
|
1072 |
```bash
|
1073 |
curl --request PUT \
|
1074 |
+
--url http://{address}/api/v1/dataset/{dataset_id}/document/{document_id}/chunk/{chunk_id} \
|
1075 |
+
--header 'Content-Type: application/json' \
|
1076 |
+
--header 'Authorization: {YOUR_API_KEY}' \
|
1077 |
+
--data '
|
1078 |
+
{
|
1079 |
+
"content": "ragflow123",
|
1080 |
+
"important_keywords": [],
|
1081 |
+
}'
|
1082 |
```
|
1083 |
|
1084 |
#### Request parameters
|
|
|
1089 |
A list of key terms or phrases to tag with the chunk.
|
1090 |
- `"available"`: (*Body parameter*) `boolean`
|
1091 |
The chunk's availability status in the dataset. Value options:
|
1092 |
+
- `true`: Available
|
1093 |
+
- `false`: Unavailable
|
1094 |
|
1095 |
### Response
|
1096 |
|
|
|
1128 |
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
1129 |
- Body:
|
1130 |
- `"question"`: `string`
|
1131 |
+
- `"dataset_ids"`: `list[string]`
|
1132 |
+
- `"document_ids"`: `list[string]`
|
1133 |
- `"offset"`: `integer`
|
1134 |
- `"limit"`: `integer`
|
1135 |
- `"similarity_threshold"`: `float`
|
|
|
1143 |
|
1144 |
```bash
|
1145 |
curl --request POST \
|
1146 |
+
--url http://{address}/api/v1/retrieval \
|
1147 |
+
--header 'Content-Type: application/json' \
|
1148 |
+
--header 'Authorization: {YOUR_API_KEY}' \
|
1149 |
+
--data '
|
1150 |
+
{
|
1151 |
+
"question": "What is advantage of ragflow?",
|
1152 |
+
"dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
|
1153 |
+
"document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
|
1154 |
+
}'
|
|
|
|
|
|
|
1155 |
```
|
1156 |
|
1157 |
#### Request parameter
|
1158 |
|
1159 |
- `"question"`: (*Body parameter*), `string`, *Required*
|
1160 |
The user query or query keywords. Defaults to `""`.
|
1161 |
+
- `"dataset_ids"`: (*Body parameter*) `list[string]`, *Required*
|
1162 |
The IDs of the datasets to search from.
|
1163 |
+
- `"document_ids"`: (*Body parameter*), `list[string]`
|
1164 |
The IDs of the documents to search from.
|
1165 |
- `"offset"`: (*Body parameter*), `integer`
|
1166 |
The starting index for the documents to retrieve. Defaults to `1`.
|
|
|
1176 |
The ID of the rerank model.
|
1177 |
- `"keyword"`: (*Body parameter*), `boolean`
|
1178 |
Indicates whether to enable keyword-based matching:
|
1179 |
+
- `true`: Enable keyword-based matching.
|
1180 |
+
- `false`: Disable keyword-based matching (default).
|
1181 |
- `"highlight"`: (*Body parameter*), `boolean`
|
1182 |
Specifies whether to enable highlighting of matched terms in the results:
|
1183 |
+
- `true`: Enable highlighting of matched terms.
|
1184 |
+
- `false`: Disable highlighting of matched terms (default).
|
1185 |
|
1186 |
### Response
|
1187 |
|
|
|
1257 |
- Body:
|
1258 |
- `"name"`: `string`
|
1259 |
- `"avatar"`: `string`
|
1260 |
+
- `"dataset_ids"`: `list[string]`
|
1261 |
- `"llm"`: `object`
|
1262 |
- `"prompt"`: `object`
|
1263 |
|
|
|
1268 |
--url http://{address}/api/v1/chat \
|
1269 |
--header 'Content-Type: application/json' \
|
1270 |
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
1271 |
+
--data '{
|
1272 |
+
"dataset_ids": [
|
1273 |
{
|
1274 |
"avatar": null,
|
1275 |
"chunk_count": 0,
|
|
|
1302 |
The name of the chat assistant.
|
1303 |
- `"avatar"`: (*Body parameter*)
|
1304 |
Base64 encoding of the avatar. Defaults to `""`.
|
1305 |
+
- `"dataset_ids"`: (*Body parameter*)
|
1306 |
The IDs of the associated datasets. Defaults to `[""]`.
|
1307 |
- `"llm"`: (*Body parameter*), `object`
|
1308 |
The LLM settings for the chat assistant to create. When the value is `None`, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
|
|
|
1326 |
- `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
|
1327 |
- `"knowledge"` is a reserved variable, which will be replaced with the retrieved chunks.
|
1328 |
- All the variables in 'System' should be curly bracketed.
|
1329 |
+
- The default value is `[{"key": "knowledge", "optional": true}]`
|
1330 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
1331 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1332 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1333 |
+
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1334 |
- `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.
|
1335 |
Here is the knowledge base:
|
1336 |
{knowledge}
|
|
|
1435 |
- Body:
|
1436 |
- `"name"`: `string`
|
1437 |
- `"avatar"`: `string`
|
1438 |
+
- `"dataset_ids"`: `list[string]`
|
1439 |
- `"llm"`: `object`
|
1440 |
- `"prompt"`: `object`
|
1441 |
|
|
|
1443 |
|
1444 |
```bash
|
1445 |
curl --request PUT \
|
1446 |
+
--url http://{address}/api/v1/chat/{chat_id} \
|
1447 |
+
--header 'Content-Type: application/json' \
|
1448 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1449 |
+
--data '
|
1450 |
+
{
|
1451 |
+
"name":"Test"
|
1452 |
+
}'
|
1453 |
```
|
1454 |
|
1455 |
#### Parameters
|
1456 |
|
1457 |
+
- `chat_id`: (*Path parameter*)
|
1458 |
+
The ID of the chat assistant to update.
|
1459 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
1460 |
The name of the chat assistant.
|
1461 |
- `"avatar"`: (*Body parameter*)
|
1462 |
Base64 encoding of the avatar. Defaults to `""`.
|
1463 |
+
- `"dataset_ids"`: (*Body parameter*)
|
1464 |
The IDs of the associated datasets. Defaults to `[""]`.
|
1465 |
- `"llm"`: (*Body parameter*), `object`
|
1466 |
The LLM settings for the chat assistant to create. When the value is `None`, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
|
|
|
1484 |
- `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
|
1485 |
- `"knowledge"` is a reserved variable, which will be replaced with the retrieved chunks.
|
1486 |
- All the variables in 'System' should be curly bracketed.
|
1487 |
+
- The default value is `[{"key": "knowledge", "optional": true}]`
|
1488 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
1489 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1490 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1491 |
+
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1492 |
- `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.
|
1493 |
Here is the knowledge base:
|
1494 |
{knowledge}
|
|
|
1534 |
#### Request example
|
1535 |
|
1536 |
```bash
|
|
|
1537 |
curl --request DELETE \
|
1538 |
+
--url http://{address}/api/v1/chat \
|
1539 |
+
--header 'Content-Type: application/json' \
|
1540 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1541 |
+
--data '
|
1542 |
+
{
|
1543 |
+
"ids": ["test_1", "test_2"]
|
1544 |
+
}'
|
1545 |
```
|
1546 |
|
1547 |
#### Request parameters
|
|
|
1587 |
|
1588 |
```bash
|
1589 |
curl --request GET \
|
1590 |
+
--url http://{address}/api/v1/chat?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
|
1591 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
1592 |
```
|
1593 |
|
1594 |
#### Request parameters
|
1595 |
|
1596 |
+
- `page`: (*Path parameter*), `integer`
|
1597 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
1598 |
+
- `page_size`: (*Path parameter*), `integer`
|
1599 |
The number of chat assistants on each page. Defaults to `1024`.
|
1600 |
+
- `orderby`: (*Path parameter*), `string`
|
1601 |
The attribute by which the results are sorted. Available options:
|
1602 |
- `"create_time"` (default)
|
1603 |
- `"update_time"`
|
1604 |
- `"desc"`: (*Path parameter*), `boolean`
|
1605 |
+
Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `true`.
|
1606 |
+
- `id`: (*Path parameter*), `string`
|
1607 |
The ID of the chat assistant to retrieve.
|
1608 |
+
- `name`: (*Path parameter*), `string`
|
1609 |
The name of the chat assistant to retrieve.
|
1610 |
|
1611 |
### Response
|
|
|
1718 |
|
1719 |
```bash
|
1720 |
curl --request POST \
|
1721 |
+
--url http://{address}/api/v1/chat/{chat_id}/session \
|
1722 |
+
--header 'Content-Type: application/json' \
|
1723 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1724 |
+
--data '
|
1725 |
+
{
|
1726 |
+
"name": "new session"
|
1727 |
+
}'
|
1728 |
```
|
1729 |
|
1730 |
#### Request parameters
|
1731 |
|
1732 |
+
- `chat_id`: (*Path parameter*)
|
1733 |
+
The ID of the associated chat assistant.
|
1734 |
- `"name"`: (*Body parameter*), `string`
|
1735 |
The name of the chat session to create.
|
1736 |
|
|
|
1737 |
### Response
|
1738 |
|
1739 |
Success:
|
|
|
1774 |
|
1775 |
**PUT** `/api/v1/chat/{chat_id}/session/{session_id}`
|
1776 |
|
1777 |
+
Updates a chat session.
|
1778 |
|
1779 |
### Request
|
1780 |
|
|
|
1789 |
#### Request example
|
1790 |
```bash
|
1791 |
curl --request PUT \
|
1792 |
+
--url http://{address}/api/v1/chat/{chat_id}/session/{session_id} \
|
1793 |
+
--header 'Content-Type: application/json' \
|
1794 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1795 |
+
--data '
|
1796 |
+
{
|
1797 |
+
"name": "Updated session"
|
1798 |
+
}'
|
1799 |
```
|
1800 |
|
1801 |
#### Request Parameter
|
1802 |
|
1803 |
+
- `chat_id`: (*Path parameter*)
|
1804 |
+
The ID of the associated chat assistant.
|
1805 |
+
- `session_id`: (*Path parameter*)
|
1806 |
+
The ID of the session to update.
|
1807 |
- `"name`: (*Body Parameter), `string`
|
1808 |
The name of the session to update.
|
1809 |
|
|
|
1845 |
|
1846 |
```bash
|
1847 |
curl --request GET \
|
1848 |
+
--url http://{address}/api/v1/chat/{chat_id}/session?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id} \
|
1849 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}'
|
1850 |
```
|
1851 |
|
1852 |
#### Request Parameters
|
1853 |
|
1854 |
+
- `chat_id`: (*Path parameter*)
|
1855 |
+
The ID of the associated chat assistant.
|
1856 |
- `"page"`: (*Path parameter*), `integer`
|
1857 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1858 |
- `"page_size"`: (*Path parameter*), `integer`
|
|
|
1862 |
- `"create_time"` (default)
|
1863 |
- `"update_time"`
|
1864 |
- `"desc"`: (*Path parameter*), `boolean`
|
1865 |
+
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
|
|
|
|
|
1866 |
- `"name"`: (*Path parameter*) `string`
|
1867 |
The name of the chat session to retrieve.
|
1868 |
+
- `"id"`: (*Path parameter*), `string`
|
1869 |
+
The ID of the chat session to retrieve.
|
1870 |
|
1871 |
### Response
|
1872 |
|
|
|
1927 |
```bash
|
1928 |
# Either id or name must be provided, but not both.
|
1929 |
curl --request DELETE \
|
1930 |
+
--url http://{address}/api/v1/chat/{chat_id}/session \
|
1931 |
+
--header 'Content-Type: application/json' \
|
1932 |
+
--header 'Authorization: Bear {YOUR_API_KEY}' \
|
1933 |
+
--data '
|
1934 |
+
{
|
1935 |
+
"ids": ["test_1", "test_2"]
|
1936 |
+
}'
|
1937 |
```
|
1938 |
|
1939 |
#### Request Parameters
|
1940 |
|
1941 |
+
- `chat_id`: (*Path parameter*)
|
1942 |
+
The ID of the associated chat assistant.
|
1943 |
- `"ids"`: (*Body Parameter*), `list[string]`
|
1944 |
The IDs of the sessions to delete. If not specified, all sessions associated with the current chat assistant will be deleted.
|
1945 |
|
|
|
1986 |
|
1987 |
```bash
|
1988 |
curl --request POST \
|
1989 |
+
--url http://{address} /api/v1/chat/{chat_id}/completion \
|
1990 |
+
--header 'Content-Type: application/json' \
|
1991 |
+
--header 'Authorization: Bearer {YOUR_API_KEY}' \
|
1992 |
+
--data-binary '
|
1993 |
+
{
|
1994 |
+
"question": "Hello!",
|
1995 |
+
"stream": true
|
1996 |
+
}'
|
1997 |
```
|
1998 |
|
1999 |
#### Request Parameters
|
2000 |
|
2001 |
+
- `chat_id`: (*Path parameter*)
|
2002 |
+
The ID of the associated chat assistant.
|
2003 |
- `"question"`: (*Body Parameter*), `string` *Required*
|
2004 |
The question to start an AI chat.
|
2005 |
- `"stream"`: (*Body Parameter*), `string`
|
2006 |
Indicates whether to output responses in a streaming way:
|
2007 |
+
- `true`: Enable streaming.
|
2008 |
+
- `false`: (Default) Disable streaming.
|
2009 |
- `"session_id"`: (*Body Parameter*)
|
2010 |
+
The ID of session. If not provided, a new session will be generated.
|
2011 |
|
2012 |
### Response
|
2013 |
|
|
|
2120 |
"code": 102,
|
2121 |
"message": "Please input your question."
|
2122 |
}
|
2123 |
+
```
|
api/python_api_reference.md
CHANGED
@@ -105,16 +105,16 @@ dataset = rag_object.create_dataset(name="kb_1")
|
|
105 |
## Delete datasets
|
106 |
|
107 |
```python
|
108 |
-
RAGFlow.delete_datasets(ids: list[str]
|
109 |
```
|
110 |
|
111 |
Deletes specified datasets or all datasets in the system.
|
112 |
|
113 |
### Parameters
|
114 |
|
115 |
-
#### ids: `list[str]
|
116 |
|
117 |
-
The IDs of the datasets to delete.
|
118 |
|
119 |
### Returns
|
120 |
|
@@ -410,7 +410,7 @@ A `Document` object contains the following attributes:
|
|
410 |
- `id`: The document ID. Defaults to `""`.
|
411 |
- `name`: The document name. Defaults to `""`.
|
412 |
- `thumbnail`: The thumbnail image of the document. Defaults to `None`.
|
413 |
-
- `
|
414 |
- `chunk_method` The chunk method name. Defaults to `"naive"`.
|
415 |
- `parser_config`: `ParserConfig` Configuration object for the parser. Defaults to `{"pages": [[1, 1000000]]}`.
|
416 |
- `source_type`: The source type of the document. Defaults to `"local"`.
|
@@ -592,7 +592,7 @@ A `Chunk` object contains the following attributes:
|
|
592 |
- `important_keywords`: `list[str]` A list of key terms or phrases tagged with the chunk.
|
593 |
- `create_time`: `str` The time when the chunk was created (added to the document).
|
594 |
- `create_timestamp`: `float` The timestamp representing the creation time of the chunk, expressed in seconds since January 1, 1970.
|
595 |
-
- `
|
596 |
- `document_name`: `str` The name of the associated document.
|
597 |
- `document_id`: `str` The ID of the associated document.
|
598 |
- `available`: `bool` The chunk's availability status in the dataset. Value options:
|
@@ -740,7 +740,7 @@ chunk.update({"content":"sdfx..."})
|
|
740 |
## Retrieve chunks
|
741 |
|
742 |
```python
|
743 |
-
RAGFlow.retrieve(question:str="",
|
744 |
```
|
745 |
|
746 |
Retrieves chunks from specified datasets.
|
@@ -751,11 +751,11 @@ Retrieves chunks from specified datasets.
|
|
751 |
|
752 |
The user query or query keywords. Defaults to `""`.
|
753 |
|
754 |
-
####
|
755 |
|
756 |
The IDs of the datasets to search from.
|
757 |
|
758 |
-
####
|
759 |
|
760 |
The IDs of the documents to search from. Defaults to `None`.
|
761 |
|
@@ -817,7 +817,7 @@ doc = dataset.list_documents(name=name)
|
|
817 |
doc = doc[0]
|
818 |
dataset.async_parse_documents([doc.id])
|
819 |
for c in rag_object.retrieve(question="What's ragflow?",
|
820 |
-
|
821 |
offset=1, limit=30, similarity_threshold=0.2,
|
822 |
vector_similarity_weight=0.3,
|
823 |
top_k=1024
|
@@ -839,7 +839,7 @@ Chat Assistant Management
|
|
839 |
RAGFlow.create_chat(
|
840 |
name: str,
|
841 |
avatar: str = "",
|
842 |
-
|
843 |
llm: Chat.LLM = None,
|
844 |
prompt: Chat.Prompt = None
|
845 |
) -> Chat
|
@@ -857,7 +857,7 @@ The name of the chat assistant.
|
|
857 |
|
858 |
Base64 encoding of the avatar. Defaults to `""`.
|
859 |
|
860 |
-
####
|
861 |
|
862 |
The IDs of the associated datasets. Defaults to `[""]`.
|
863 |
|
@@ -914,7 +914,7 @@ datasets = rag_object.list_datasets(name="kb_1")
|
|
914 |
dataset_ids = []
|
915 |
for dataset in datasets:
|
916 |
dataset_ids.append(dataset.id)
|
917 |
-
assistant = rag_object.create_chat("Miss R",
|
918 |
```
|
919 |
|
920 |
---
|
@@ -935,7 +935,7 @@ A dictionary representing the attributes to update, with the following keys:
|
|
935 |
|
936 |
- `"name"`: `str` The name of the chat assistant to update.
|
937 |
- `"avatar"`: `str` Base64 encoding of the avatar. Defaults to `""`
|
938 |
-
- `"
|
939 |
- `"llm"`: `dict` The LLM settings:
|
940 |
- `"model_name"`, `str` The chat model name.
|
941 |
- `"temperature"`, `float` Controls the randomness of the model's predictions.
|
@@ -969,7 +969,8 @@ from ragflow import RAGFlow
|
|
969 |
|
970 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
971 |
datasets = rag_object.list_datasets(name="kb_1")
|
972 |
-
|
|
|
973 |
assistant.update({"name": "Stefan", "llm": {"temperature": 0.8}, "prompt": {"top_n": 8}})
|
974 |
```
|
975 |
|
@@ -1238,7 +1239,7 @@ assistant.delete_sessions(ids=["id_1","id_2"])
|
|
1238 |
|
1239 |
---
|
1240 |
|
1241 |
-
##
|
1242 |
|
1243 |
```python
|
1244 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
@@ -1290,7 +1291,7 @@ A list of `Chunk` objects representing references to the message, each containin
|
|
1290 |
The name of the referenced document.
|
1291 |
- `position` `list[str]`
|
1292 |
The location information of the chunk within the referenced document.
|
1293 |
-
- `
|
1294 |
The ID of the dataset to which the referenced document belongs.
|
1295 |
- `similarity` `float`
|
1296 |
A composite similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity.
|
|
|
105 |
## Delete datasets
|
106 |
|
107 |
```python
|
108 |
+
RAGFlow.delete_datasets(ids: list[str])
|
109 |
```
|
110 |
|
111 |
Deletes specified datasets or all datasets in the system.
|
112 |
|
113 |
### Parameters
|
114 |
|
115 |
+
#### ids: `list[str]`, *Required*
|
116 |
|
117 |
+
The IDs of the datasets to delete.
|
118 |
|
119 |
### Returns
|
120 |
|
|
|
410 |
- `id`: The document ID. Defaults to `""`.
|
411 |
- `name`: The document name. Defaults to `""`.
|
412 |
- `thumbnail`: The thumbnail image of the document. Defaults to `None`.
|
413 |
+
- `dataset_id`: The dataset ID associated with the document. Defaults to `None`.
|
414 |
- `chunk_method` The chunk method name. Defaults to `"naive"`.
|
415 |
- `parser_config`: `ParserConfig` Configuration object for the parser. Defaults to `{"pages": [[1, 1000000]]}`.
|
416 |
- `source_type`: The source type of the document. Defaults to `"local"`.
|
|
|
592 |
- `important_keywords`: `list[str]` A list of key terms or phrases tagged with the chunk.
|
593 |
- `create_time`: `str` The time when the chunk was created (added to the document).
|
594 |
- `create_timestamp`: `float` The timestamp representing the creation time of the chunk, expressed in seconds since January 1, 1970.
|
595 |
+
- `dataset_id`: `str` The ID of the associated dataset.
|
596 |
- `document_name`: `str` The name of the associated document.
|
597 |
- `document_id`: `str` The ID of the associated document.
|
598 |
- `available`: `bool` The chunk's availability status in the dataset. Value options:
|
|
|
740 |
## Retrieve chunks
|
741 |
|
742 |
```python
|
743 |
+
RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, offset:int=1, limit:int=1024, similarity_threshold:float=0.2, vector_similarity_weight:float=0.3, top_k:int=1024,rerank_id:str=None,keyword:bool=False,higlight:bool=False) -> list[Chunk]
|
744 |
```
|
745 |
|
746 |
Retrieves chunks from specified datasets.
|
|
|
751 |
|
752 |
The user query or query keywords. Defaults to `""`.
|
753 |
|
754 |
+
#### dataset_ids: `list[str]`, *Required*
|
755 |
|
756 |
The IDs of the datasets to search from.
|
757 |
|
758 |
+
#### document_ids: `list[str]`
|
759 |
|
760 |
The IDs of the documents to search from. Defaults to `None`.
|
761 |
|
|
|
817 |
doc = doc[0]
|
818 |
dataset.async_parse_documents([doc.id])
|
819 |
for c in rag_object.retrieve(question="What's ragflow?",
|
820 |
+
dataset_ids=[dataset.id], document_ids=[doc.id],
|
821 |
offset=1, limit=30, similarity_threshold=0.2,
|
822 |
vector_similarity_weight=0.3,
|
823 |
top_k=1024
|
|
|
839 |
RAGFlow.create_chat(
|
840 |
name: str,
|
841 |
avatar: str = "",
|
842 |
+
dataset_ids: list[str] = [],
|
843 |
llm: Chat.LLM = None,
|
844 |
prompt: Chat.Prompt = None
|
845 |
) -> Chat
|
|
|
857 |
|
858 |
Base64 encoding of the avatar. Defaults to `""`.
|
859 |
|
860 |
+
#### dataset_ids: `list[str]`
|
861 |
|
862 |
The IDs of the associated datasets. Defaults to `[""]`.
|
863 |
|
|
|
914 |
dataset_ids = []
|
915 |
for dataset in datasets:
|
916 |
dataset_ids.append(dataset.id)
|
917 |
+
assistant = rag_object.create_chat("Miss R", dataset_ids=dataset_ids)
|
918 |
```
|
919 |
|
920 |
---
|
|
|
935 |
|
936 |
- `"name"`: `str` The name of the chat assistant to update.
|
937 |
- `"avatar"`: `str` Base64 encoding of the avatar. Defaults to `""`
|
938 |
+
- `"dataset_ids"`: `list[str]` The datasets to update.
|
939 |
- `"llm"`: `dict` The LLM settings:
|
940 |
- `"model_name"`, `str` The chat model name.
|
941 |
- `"temperature"`, `float` Controls the randomness of the model's predictions.
|
|
|
969 |
|
970 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
971 |
datasets = rag_object.list_datasets(name="kb_1")
|
972 |
+
dataset_id = datasets[0].id
|
973 |
+
assistant = rag_object.create_chat("Miss R", dataset_ids=[dataset_id])
|
974 |
assistant.update({"name": "Stefan", "llm": {"temperature": 0.8}, "prompt": {"top_n": 8}})
|
975 |
```
|
976 |
|
|
|
1239 |
|
1240 |
---
|
1241 |
|
1242 |
+
## Converse
|
1243 |
|
1244 |
```python
|
1245 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
|
|
1291 |
The name of the referenced document.
|
1292 |
- `position` `list[str]`
|
1293 |
The location information of the chunk within the referenced document.
|
1294 |
+
- `dataset_id` `str`
|
1295 |
The ID of the dataset to which the referenced document belongs.
|
1296 |
- `similarity` `float`
|
1297 |
A composite similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity.
|