writinwaters
Kevin Hu
commited on
Commit
·
0815f2d
1
Parent(s):
9cad3b1
Miscellaneous updates to session APIs (#4097)
Browse files### What problem does this PR solve?
### Type of change
- [x] Documentation Update
---------
Co-authored-by: Kevin Hu <[email protected]>
- docs/references/http_api_reference.md +160 -157
- docs/references/python_api_reference.md +223 -228
docs/references/http_api_reference.md
CHANGED
@@ -9,19 +9,17 @@ A complete reference for RAGFlow's RESTful API. Before proceeding, please ensure
|
|
9 |
|
10 |
---
|
11 |
|
12 |
-
|
13 |
-
Dataset Management
|
14 |
-
:::
|
15 |
|
16 |
---
|
17 |
|
18 |
-
|
19 |
|
20 |
**POST** `/api/v1/datasets`
|
21 |
|
22 |
Creates a dataset.
|
23 |
|
24 |
-
|
25 |
|
26 |
- Method: POST
|
27 |
- URL: `/api/v1/datasets`
|
@@ -38,7 +36,7 @@ Creates a dataset.
|
|
38 |
- `"chunk_method"`: `string`
|
39 |
- `"parser_config"`: `object`
|
40 |
|
41 |
-
|
42 |
|
43 |
```bash
|
44 |
curl --request POST \
|
@@ -50,7 +48,7 @@ curl --request POST \
|
|
50 |
}'
|
51 |
```
|
52 |
|
53 |
-
|
54 |
|
55 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
56 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
@@ -114,7 +112,7 @@ curl --request POST \
|
|
114 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
115 |
- `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
|
116 |
|
117 |
-
|
118 |
|
119 |
Success:
|
120 |
|
@@ -166,13 +164,13 @@ Failure:
|
|
166 |
|
167 |
---
|
168 |
|
169 |
-
|
170 |
|
171 |
**DELETE** `/api/v1/datasets`
|
172 |
|
173 |
Deletes datasets by ID.
|
174 |
|
175 |
-
|
176 |
|
177 |
- Method: DELETE
|
178 |
- URL: `/api/v1/datasets`
|
@@ -182,7 +180,7 @@ Deletes datasets by ID.
|
|
182 |
- Body:
|
183 |
- `"ids"`: `list[string]`
|
184 |
|
185 |
-
|
186 |
|
187 |
```bash
|
188 |
curl --request DELETE \
|
@@ -194,12 +192,12 @@ curl --request DELETE \
|
|
194 |
}'
|
195 |
```
|
196 |
|
197 |
-
|
198 |
|
199 |
- `"ids"`: (*Body parameter*), `list[string]`
|
200 |
The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
|
201 |
|
202 |
-
|
203 |
|
204 |
Success:
|
205 |
|
@@ -220,13 +218,13 @@ Failure:
|
|
220 |
|
221 |
---
|
222 |
|
223 |
-
|
224 |
|
225 |
**PUT** `/api/v1/datasets/{dataset_id}`
|
226 |
|
227 |
Updates configurations for a specified dataset.
|
228 |
|
229 |
-
|
230 |
|
231 |
- Method: PUT
|
232 |
- URL: `/api/v1/datasets/{dataset_id}`
|
@@ -238,7 +236,7 @@ Updates configurations for a specified dataset.
|
|
238 |
- `"embedding_model"`: `string`
|
239 |
- `"chunk_method"`: `enum<string>`
|
240 |
|
241 |
-
|
242 |
|
243 |
```bash
|
244 |
curl --request PUT \
|
@@ -251,7 +249,7 @@ curl --request PUT \
|
|
251 |
}'
|
252 |
```
|
253 |
|
254 |
-
|
255 |
|
256 |
- `dataset_id`: (*Path parameter*)
|
257 |
The ID of the dataset to update.
|
@@ -276,7 +274,7 @@ curl --request PUT \
|
|
276 |
- `"knowledge_graph"`: Knowledge Graph
|
277 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
278 |
|
279 |
-
|
280 |
|
281 |
Success:
|
282 |
|
@@ -297,20 +295,20 @@ Failure:
|
|
297 |
|
298 |
---
|
299 |
|
300 |
-
|
301 |
|
302 |
**GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
303 |
|
304 |
Lists datasets.
|
305 |
|
306 |
-
|
307 |
|
308 |
- Method: GET
|
309 |
- URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
310 |
- Headers:
|
311 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
312 |
|
313 |
-
|
314 |
|
315 |
```bash
|
316 |
curl --request GET \
|
@@ -318,7 +316,7 @@ curl --request GET \
|
|
318 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
319 |
```
|
320 |
|
321 |
-
|
322 |
|
323 |
- `page`: (*Filter parameter*)
|
324 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
@@ -335,7 +333,7 @@ curl --request GET \
|
|
335 |
- `id`: (*Filter parameter*)
|
336 |
The ID of the dataset to retrieve.
|
337 |
|
338 |
-
|
339 |
|
340 |
Success:
|
341 |
|
@@ -391,19 +389,17 @@ Failure:
|
|
391 |
|
392 |
---
|
393 |
|
394 |
-
|
395 |
-
File Management within Dataset
|
396 |
-
:::
|
397 |
|
398 |
---
|
399 |
|
400 |
-
|
401 |
|
402 |
**POST** `/api/v1/datasets/{dataset_id}/documents`
|
403 |
|
404 |
Uploads documents to a specified dataset.
|
405 |
|
406 |
-
|
407 |
|
408 |
- Method: POST
|
409 |
- URL: `/api/v1/datasets/{dataset_id}/documents`
|
@@ -413,7 +409,7 @@ Uploads documents to a specified dataset.
|
|
413 |
- Form:
|
414 |
- `'file=@{FILE_PATH}'`
|
415 |
|
416 |
-
|
417 |
|
418 |
```bash
|
419 |
curl --request POST \
|
@@ -424,14 +420,14 @@ curl --request POST \
|
|
424 |
--form 'file=@./test2.pdf'
|
425 |
```
|
426 |
|
427 |
-
|
428 |
|
429 |
- `dataset_id`: (*Path parameter*)
|
430 |
The ID of the dataset to which the documents will be uploaded.
|
431 |
- `'file'`: (*Body parameter*)
|
432 |
A document to upload.
|
433 |
|
434 |
-
|
435 |
|
436 |
Success:
|
437 |
|
@@ -475,13 +471,13 @@ Failure:
|
|
475 |
|
476 |
---
|
477 |
|
478 |
-
|
479 |
|
480 |
**PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
481 |
|
482 |
Updates configurations for a specified document.
|
483 |
|
484 |
-
|
485 |
|
486 |
- Method: PUT
|
487 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
@@ -493,7 +489,7 @@ Updates configurations for a specified document.
|
|
493 |
- `"chunk_method"`:`string`
|
494 |
- `"parser_config"`:`object`
|
495 |
|
496 |
-
|
497 |
|
498 |
```bash
|
499 |
curl --request PUT \
|
@@ -509,7 +505,7 @@ curl --request PUT \
|
|
509 |
|
510 |
```
|
511 |
|
512 |
-
|
513 |
|
514 |
- `dataset_id`: (*Path parameter*)
|
515 |
The ID of the associated dataset.
|
@@ -548,7 +544,7 @@ curl --request PUT \
|
|
548 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
549 |
- `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
|
550 |
|
551 |
-
|
552 |
|
553 |
Success:
|
554 |
|
@@ -569,13 +565,13 @@ Failure:
|
|
569 |
|
570 |
---
|
571 |
|
572 |
-
|
573 |
|
574 |
**GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
575 |
|
576 |
Downloads a document from a specified dataset.
|
577 |
|
578 |
-
|
579 |
|
580 |
- Method: GET
|
581 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
@@ -584,7 +580,7 @@ Downloads a document from a specified dataset.
|
|
584 |
- Output:
|
585 |
- `'{PATH_TO_THE_FILE}'`
|
586 |
|
587 |
-
|
588 |
|
589 |
```bash
|
590 |
curl --request GET \
|
@@ -593,14 +589,14 @@ curl --request GET \
|
|
593 |
--output ./ragflow.txt
|
594 |
```
|
595 |
|
596 |
-
|
597 |
|
598 |
- `dataset_id`: (*Path parameter*)
|
599 |
The associated dataset ID.
|
600 |
- `documents_id`: (*Path parameter*)
|
601 |
The ID of the document to download.
|
602 |
|
603 |
-
|
604 |
|
605 |
Success:
|
606 |
|
@@ -619,13 +615,13 @@ Failure:
|
|
619 |
|
620 |
---
|
621 |
|
622 |
-
|
623 |
|
624 |
**GET** `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
|
625 |
|
626 |
Lists documents in a specified dataset.
|
627 |
|
628 |
-
|
629 |
|
630 |
- Method: GET
|
631 |
- URL: `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
|
@@ -633,7 +629,7 @@ Lists documents in a specified dataset.
|
|
633 |
- `'content-Type: application/json'`
|
634 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
635 |
|
636 |
-
|
637 |
|
638 |
```bash
|
639 |
curl --request GET \
|
@@ -641,7 +637,7 @@ curl --request GET \
|
|
641 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
642 |
```
|
643 |
|
644 |
-
|
645 |
|
646 |
- `dataset_id`: (*Path parameter*)
|
647 |
The associated dataset ID.
|
@@ -660,7 +656,7 @@ curl --request GET \
|
|
660 |
- `id`: (*Filter parameter*), `string`
|
661 |
The ID of the document to retrieve.
|
662 |
|
663 |
-
|
664 |
|
665 |
Success:
|
666 |
|
@@ -716,13 +712,13 @@ Failure:
|
|
716 |
|
717 |
---
|
718 |
|
719 |
-
|
720 |
|
721 |
**DELETE** `/api/v1/datasets/{dataset_id}/documents`
|
722 |
|
723 |
Deletes documents by ID.
|
724 |
|
725 |
-
|
726 |
|
727 |
- Method: DELETE
|
728 |
- URL: `/api/v1/datasets/{dataset_id}/documents`
|
@@ -732,7 +728,7 @@ Deletes documents by ID.
|
|
732 |
- Body:
|
733 |
- `"ids"`: `list[string]`
|
734 |
|
735 |
-
|
736 |
|
737 |
```bash
|
738 |
curl --request DELETE \
|
@@ -745,14 +741,14 @@ curl --request DELETE \
|
|
745 |
}'
|
746 |
```
|
747 |
|
748 |
-
|
749 |
|
750 |
- `dataset_id`: (*Path parameter*)
|
751 |
The associated dataset ID.
|
752 |
- `"ids"`: (*Body parameter*), `list[string]`
|
753 |
The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
|
754 |
|
755 |
-
|
756 |
|
757 |
Success:
|
758 |
|
@@ -773,13 +769,13 @@ Failure:
|
|
773 |
|
774 |
---
|
775 |
|
776 |
-
|
777 |
|
778 |
**POST** `/api/v1/datasets/{dataset_id}/chunks`
|
779 |
|
780 |
Parses documents in a specified dataset.
|
781 |
|
782 |
-
|
783 |
|
784 |
- Method: POST
|
785 |
- URL: `/api/v1/datasets/{dataset_id}/chunks`
|
@@ -789,7 +785,7 @@ Parses documents in a specified dataset.
|
|
789 |
- Body:
|
790 |
- `"document_ids"`: `list[string]`
|
791 |
|
792 |
-
|
793 |
|
794 |
```bash
|
795 |
curl --request POST \
|
@@ -802,14 +798,14 @@ curl --request POST \
|
|
802 |
}'
|
803 |
```
|
804 |
|
805 |
-
|
806 |
|
807 |
- `dataset_id`: (*Path parameter*)
|
808 |
The dataset ID.
|
809 |
- `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
|
810 |
The IDs of the documents to parse.
|
811 |
|
812 |
-
|
813 |
|
814 |
Success:
|
815 |
|
@@ -830,13 +826,13 @@ Failure:
|
|
830 |
|
831 |
---
|
832 |
|
833 |
-
|
834 |
|
835 |
**DELETE** `/api/v1/datasets/{dataset_id}/chunks`
|
836 |
|
837 |
Stops parsing specified documents.
|
838 |
|
839 |
-
|
840 |
|
841 |
- Method: DELETE
|
842 |
- URL: `/api/v1/datasets/{dataset_id}/chunks`
|
@@ -846,7 +842,7 @@ Stops parsing specified documents.
|
|
846 |
- Body:
|
847 |
- `"document_ids"`: `list[string]`
|
848 |
|
849 |
-
|
850 |
|
851 |
```bash
|
852 |
curl --request DELETE \
|
@@ -859,14 +855,14 @@ curl --request DELETE \
|
|
859 |
}'
|
860 |
```
|
861 |
|
862 |
-
|
863 |
|
864 |
- `dataset_id`: (*Path parameter*)
|
865 |
The associated dataset ID.
|
866 |
- `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
|
867 |
The IDs of the documents for which the parsing should be stopped.
|
868 |
|
869 |
-
|
870 |
|
871 |
Success:
|
872 |
|
@@ -887,13 +883,13 @@ Failure:
|
|
887 |
|
888 |
---
|
889 |
|
890 |
-
|
891 |
|
892 |
**POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
893 |
|
894 |
Adds a chunk to a specified document in a specified dataset.
|
895 |
|
896 |
-
|
897 |
|
898 |
- Method: POST
|
899 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
@@ -904,7 +900,7 @@ Adds a chunk to a specified document in a specified dataset.
|
|
904 |
- `"content"`: `string`
|
905 |
- `"important_keywords"`: `list[string]`
|
906 |
|
907 |
-
|
908 |
|
909 |
```bash
|
910 |
curl --request POST \
|
@@ -917,7 +913,7 @@ curl --request POST \
|
|
917 |
}'
|
918 |
```
|
919 |
|
920 |
-
|
921 |
|
922 |
- `dataset_id`: (*Path parameter*)
|
923 |
The associated dataset ID.
|
@@ -928,7 +924,7 @@ curl --request POST \
|
|
928 |
- `"important_keywords`(*Body parameter*), `list[string]`
|
929 |
The key terms or phrases to tag with the chunk.
|
930 |
|
931 |
-
|
932 |
|
933 |
Success:
|
934 |
|
@@ -962,20 +958,20 @@ Failure:
|
|
962 |
|
963 |
---
|
964 |
|
965 |
-
|
966 |
|
967 |
**GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}`
|
968 |
|
969 |
Lists chunks in a specified document.
|
970 |
|
971 |
-
|
972 |
|
973 |
- Method: GET
|
974 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id}`
|
975 |
- Headers:
|
976 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
977 |
|
978 |
-
|
979 |
|
980 |
```bash
|
981 |
curl --request GET \
|
@@ -983,7 +979,7 @@ curl --request GET \
|
|
983 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
984 |
```
|
985 |
|
986 |
-
|
987 |
|
988 |
- `dataset_id`: (*Path parameter*)
|
989 |
The associated dataset ID.
|
@@ -998,7 +994,7 @@ curl --request GET \
|
|
998 |
- `id`(*Filter parameter*), `string`
|
999 |
The ID of the chunk to retrieve.
|
1000 |
|
1001 |
-
|
1002 |
|
1003 |
Success:
|
1004 |
|
@@ -1069,13 +1065,13 @@ Failure:
|
|
1069 |
|
1070 |
---
|
1071 |
|
1072 |
-
|
1073 |
|
1074 |
**DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
1075 |
|
1076 |
Deletes chunks by ID.
|
1077 |
|
1078 |
-
|
1079 |
|
1080 |
- Method: DELETE
|
1081 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
@@ -1085,7 +1081,7 @@ Deletes chunks by ID.
|
|
1085 |
- Body:
|
1086 |
- `"chunk_ids"`: `list[string]`
|
1087 |
|
1088 |
-
|
1089 |
|
1090 |
```bash
|
1091 |
curl --request DELETE \
|
@@ -1098,7 +1094,7 @@ curl --request DELETE \
|
|
1098 |
}'
|
1099 |
```
|
1100 |
|
1101 |
-
|
1102 |
|
1103 |
- `dataset_id`: (*Path parameter*)
|
1104 |
The associated dataset ID.
|
@@ -1107,7 +1103,7 @@ curl --request DELETE \
|
|
1107 |
- `"chunk_ids"`: (*Body parameter*), `list[string]`
|
1108 |
The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
|
1109 |
|
1110 |
-
|
1111 |
|
1112 |
Success:
|
1113 |
|
@@ -1128,13 +1124,13 @@ Failure:
|
|
1128 |
|
1129 |
---
|
1130 |
|
1131 |
-
|
1132 |
|
1133 |
**PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
|
1134 |
|
1135 |
Updates content or configurations for a specified chunk.
|
1136 |
|
1137 |
-
|
1138 |
|
1139 |
- Method: PUT
|
1140 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
|
@@ -1146,7 +1142,7 @@ Updates content or configurations for a specified chunk.
|
|
1146 |
- `"important_keywords"`: `list[string]`
|
1147 |
- `"available"`: `boolean`
|
1148 |
|
1149 |
-
|
1150 |
|
1151 |
```bash
|
1152 |
curl --request PUT \
|
@@ -1160,7 +1156,7 @@ curl --request PUT \
|
|
1160 |
}'
|
1161 |
```
|
1162 |
|
1163 |
-
|
1164 |
|
1165 |
- `dataset_id`: (*Path parameter*)
|
1166 |
The associated dataset ID.
|
@@ -1177,7 +1173,7 @@ curl --request PUT \
|
|
1177 |
- `true`: Available (default)
|
1178 |
- `false`: Unavailable
|
1179 |
|
1180 |
-
|
1181 |
|
1182 |
Success:
|
1183 |
|
@@ -1198,13 +1194,13 @@ Failure:
|
|
1198 |
|
1199 |
---
|
1200 |
|
1201 |
-
|
1202 |
|
1203 |
**POST** `/api/v1/retrieval`
|
1204 |
|
1205 |
Retrieves chunks from specified datasets.
|
1206 |
|
1207 |
-
|
1208 |
|
1209 |
- Method: POST
|
1210 |
- URL: `/api/v1/retrieval`
|
@@ -1224,7 +1220,7 @@ Retrieves chunks from specified datasets.
|
|
1224 |
- `"keyword"`: `boolean`
|
1225 |
- `"highlight"`: `boolean`
|
1226 |
|
1227 |
-
|
1228 |
|
1229 |
```bash
|
1230 |
curl --request POST \
|
@@ -1239,7 +1235,7 @@ curl --request POST \
|
|
1239 |
}'
|
1240 |
```
|
1241 |
|
1242 |
-
|
1243 |
|
1244 |
- `"question"`: (*Body parameter*), `string`, *Required*
|
1245 |
The user query or query keywords.
|
@@ -1268,7 +1264,7 @@ curl --request POST \
|
|
1268 |
- `true`: Enable highlighting of matched terms.
|
1269 |
- `false`: Disable highlighting of matched terms (default).
|
1270 |
|
1271 |
-
|
1272 |
|
1273 |
Success:
|
1274 |
|
@@ -1320,19 +1316,17 @@ Failure:
|
|
1320 |
|
1321 |
---
|
1322 |
|
1323 |
-
|
1324 |
-
Chat Assistant Management
|
1325 |
-
:::
|
1326 |
|
1327 |
---
|
1328 |
|
1329 |
-
|
1330 |
|
1331 |
**POST** `/api/v1/chats`
|
1332 |
|
1333 |
Creates a chat assistant.
|
1334 |
|
1335 |
-
|
1336 |
|
1337 |
- Method: POST
|
1338 |
- URL: `/api/v1/chats`
|
@@ -1346,7 +1340,7 @@ Creates a chat assistant.
|
|
1346 |
- `"llm"`: `object`
|
1347 |
- `"prompt"`: `object`
|
1348 |
|
1349 |
-
|
1350 |
|
1351 |
```shell
|
1352 |
curl --request POST \
|
@@ -1359,7 +1353,7 @@ curl --request POST \
|
|
1359 |
}'
|
1360 |
```
|
1361 |
|
1362 |
-
|
1363 |
|
1364 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
1365 |
The name of the chat assistant.
|
@@ -1396,7 +1390,7 @@ curl --request POST \
|
|
1396 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1397 |
- `"prompt"`: `string` The prompt content.
|
1398 |
|
1399 |
-
|
1400 |
|
1401 |
Success:
|
1402 |
|
@@ -1459,13 +1453,13 @@ Failure:
|
|
1459 |
|
1460 |
---
|
1461 |
|
1462 |
-
|
1463 |
|
1464 |
**PUT** `/api/v1/chats/{chat_id}`
|
1465 |
|
1466 |
Updates configurations for a specified chat assistant.
|
1467 |
|
1468 |
-
|
1469 |
|
1470 |
- Method: PUT
|
1471 |
- URL: `/api/v1/chats/{chat_id}`
|
@@ -1479,7 +1473,7 @@ Updates configurations for a specified chat assistant.
|
|
1479 |
- `"llm"`: `object`
|
1480 |
- `"prompt"`: `object`
|
1481 |
|
1482 |
-
|
1483 |
|
1484 |
```bash
|
1485 |
curl --request PUT \
|
@@ -1531,7 +1525,7 @@ curl --request PUT \
|
|
1531 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1532 |
- `"prompt"`: `string` The prompt content.
|
1533 |
|
1534 |
-
|
1535 |
|
1536 |
Success:
|
1537 |
|
@@ -1552,13 +1546,13 @@ Failure:
|
|
1552 |
|
1553 |
---
|
1554 |
|
1555 |
-
|
1556 |
|
1557 |
**DELETE** `/api/v1/chats`
|
1558 |
|
1559 |
Deletes chat assistants by ID.
|
1560 |
|
1561 |
-
|
1562 |
|
1563 |
- Method: DELETE
|
1564 |
- URL: `/api/v1/chats`
|
@@ -1568,7 +1562,7 @@ Deletes chat assistants by ID.
|
|
1568 |
- Body:
|
1569 |
- `"ids"`: `list[string]`
|
1570 |
|
1571 |
-
|
1572 |
|
1573 |
```bash
|
1574 |
curl --request DELETE \
|
@@ -1581,12 +1575,12 @@ curl --request DELETE \
|
|
1581 |
}'
|
1582 |
```
|
1583 |
|
1584 |
-
|
1585 |
|
1586 |
- `"ids"`: (*Body parameter*), `list[string]`
|
1587 |
The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
|
1588 |
|
1589 |
-
|
1590 |
|
1591 |
Success:
|
1592 |
|
@@ -1607,20 +1601,20 @@ Failure:
|
|
1607 |
|
1608 |
---
|
1609 |
|
1610 |
-
|
1611 |
|
1612 |
**GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
|
1613 |
|
1614 |
Lists chat assistants.
|
1615 |
|
1616 |
-
|
1617 |
|
1618 |
- Method: GET
|
1619 |
- URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
1620 |
- Headers:
|
1621 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
1622 |
|
1623 |
-
|
1624 |
|
1625 |
```bash
|
1626 |
curl --request GET \
|
@@ -1628,7 +1622,7 @@ curl --request GET \
|
|
1628 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
1629 |
```
|
1630 |
|
1631 |
-
|
1632 |
|
1633 |
- `page`: (*Filter parameter*), `integer`
|
1634 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
@@ -1645,7 +1639,7 @@ curl --request GET \
|
|
1645 |
- `name`: (*Filter parameter*), `string`
|
1646 |
The name of the chat assistant to retrieve.
|
1647 |
|
1648 |
-
|
1649 |
|
1650 |
Success:
|
1651 |
|
@@ -1706,13 +1700,19 @@ Failure:
|
|
1706 |
}
|
1707 |
```
|
1708 |
|
1709 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1710 |
|
1711 |
**POST** `/api/v1/chats/{chat_id}/sessions`
|
1712 |
|
1713 |
Creates a session with a chat assistant.
|
1714 |
|
1715 |
-
|
1716 |
|
1717 |
- Method: POST
|
1718 |
- URL: `/api/v1/chats/{chat_id}/sessions`
|
@@ -1722,7 +1722,7 @@ Creates a session with a chat assistant.
|
|
1722 |
- Body:
|
1723 |
- `"name"`: `string`
|
1724 |
|
1725 |
-
|
1726 |
|
1727 |
```bash
|
1728 |
curl --request POST \
|
@@ -1735,14 +1735,14 @@ curl --request POST \
|
|
1735 |
}'
|
1736 |
```
|
1737 |
|
1738 |
-
|
1739 |
|
1740 |
- `chat_id`: (*Path parameter*)
|
1741 |
The ID of the associated chat assistant.
|
1742 |
- `"name"`: (*Body parameter*), `string`
|
1743 |
The name of the chat session to create.
|
1744 |
|
1745 |
-
|
1746 |
|
1747 |
Success:
|
1748 |
|
@@ -1778,13 +1778,13 @@ Failure:
|
|
1778 |
|
1779 |
---
|
1780 |
|
1781 |
-
|
1782 |
|
1783 |
**PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
|
1784 |
|
1785 |
Updates a session of a specified chat assistant.
|
1786 |
|
1787 |
-
|
1788 |
|
1789 |
- Method: PUT
|
1790 |
- URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
|
@@ -1794,7 +1794,7 @@ Updates a session of a specified chat assistant.
|
|
1794 |
- Body:
|
1795 |
- `"name`: `string`
|
1796 |
|
1797 |
-
|
1798 |
|
1799 |
```bash
|
1800 |
curl --request PUT \
|
@@ -1807,7 +1807,7 @@ curl --request PUT \
|
|
1807 |
}'
|
1808 |
```
|
1809 |
|
1810 |
-
|
1811 |
|
1812 |
- `chat_id`: (*Path parameter*)
|
1813 |
The ID of the associated chat assistant.
|
@@ -1816,7 +1816,7 @@ curl --request PUT \
|
|
1816 |
- `"name"`: (*Body Parameter), `string`
|
1817 |
The revised name of the session.
|
1818 |
|
1819 |
-
|
1820 |
|
1821 |
Success:
|
1822 |
|
@@ -1837,20 +1837,20 @@ Failure:
|
|
1837 |
|
1838 |
---
|
1839 |
|
1840 |
-
|
1841 |
|
1842 |
**GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
|
1843 |
|
1844 |
Lists sessions associated with a specified chat assistant.
|
1845 |
|
1846 |
-
|
1847 |
|
1848 |
- Method: GET
|
1849 |
- URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
|
1850 |
- Headers:
|
1851 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
1852 |
|
1853 |
-
|
1854 |
|
1855 |
```bash
|
1856 |
curl --request GET \
|
@@ -1858,7 +1858,7 @@ curl --request GET \
|
|
1858 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
1859 |
```
|
1860 |
|
1861 |
-
|
1862 |
|
1863 |
- `chat_id`: (*Path parameter*)
|
1864 |
The ID of the associated chat assistant.
|
@@ -1877,7 +1877,7 @@ curl --request GET \
|
|
1877 |
- `id`: (*Filter parameter*), `string`
|
1878 |
The ID of the chat session to retrieve.
|
1879 |
|
1880 |
-
|
1881 |
|
1882 |
Success:
|
1883 |
|
@@ -1915,13 +1915,13 @@ Failure:
|
|
1915 |
|
1916 |
---
|
1917 |
|
1918 |
-
|
1919 |
|
1920 |
**DELETE** `/api/v1/chats/{chat_id}/sessions`
|
1921 |
|
1922 |
Deletes sessions of a chat assistant by ID.
|
1923 |
|
1924 |
-
|
1925 |
|
1926 |
- Method: DELETE
|
1927 |
- URL: `/api/v1/chats/{chat_id}/sessions`
|
@@ -1931,10 +1931,9 @@ Deletes sessions of a chat assistant by ID.
|
|
1931 |
- Body:
|
1932 |
- `"ids"`: `list[string]`
|
1933 |
|
1934 |
-
|
1935 |
|
1936 |
```bash
|
1937 |
-
# Either id or name must be provided, but not both.
|
1938 |
curl --request DELETE \
|
1939 |
--url http://{address}/api/v1/chats/{chat_id}/sessions \
|
1940 |
--header 'Content-Type: application/json' \
|
@@ -1945,14 +1944,14 @@ curl --request DELETE \
|
|
1945 |
}'
|
1946 |
```
|
1947 |
|
1948 |
-
|
1949 |
|
1950 |
- `chat_id`: (*Path parameter*)
|
1951 |
The ID of the associated chat assistant.
|
1952 |
- `"ids"`: (*Body Parameter*), `list[string]`
|
1953 |
The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
|
1954 |
|
1955 |
-
|
1956 |
|
1957 |
Success:
|
1958 |
|
@@ -1973,7 +1972,7 @@ Failure:
|
|
1973 |
|
1974 |
---
|
1975 |
|
1976 |
-
|
1977 |
|
1978 |
**POST** `/api/v1/chats/{chat_id}/completions`
|
1979 |
|
@@ -1994,7 +1993,7 @@ Asks a specified chat assistant a question to start an AI-powered conversation.
|
|
1994 |
|
1995 |
:::
|
1996 |
|
1997 |
-
|
1998 |
|
1999 |
- Method: POST
|
2000 |
- URL: `/api/v1/chats/{chat_id}/completions`
|
@@ -2006,7 +2005,7 @@ Asks a specified chat assistant a question to start an AI-powered conversation.
|
|
2006 |
- `"stream"`: `boolean`
|
2007 |
- `"session_id"`: `string`
|
2008 |
|
2009 |
-
|
2010 |
|
2011 |
```bash
|
2012 |
curl --request POST \
|
@@ -2029,7 +2028,8 @@ curl --request POST \
|
|
2029 |
"session_id":"9fa7691cb85c11ef9c5f0242ac120005"
|
2030 |
}'
|
2031 |
```
|
2032 |
-
|
|
|
2033 |
|
2034 |
- `chat_id`: (*Path parameter*)
|
2035 |
The ID of the associated chat assistant.
|
@@ -2042,7 +2042,8 @@ curl --request POST \
|
|
2042 |
- `"session_id"`: (*Body Parameter*)
|
2043 |
The ID of session. If it is not provided, a new session will be generated.
|
2044 |
|
2045 |
-
|
|
|
2046 |
Success without `session_id`:
|
2047 |
```text
|
2048 |
data:{
|
@@ -2148,15 +2149,13 @@ Failure:
|
|
2148 |
|
2149 |
---
|
2150 |
|
2151 |
-
|
2152 |
-
|
2153 |
-
*If there are parameters in the `begin` component, the session cannot be created in this way.*
|
2154 |
|
2155 |
**POST** `/api/v1/agents/{agent_id}/sessions`
|
2156 |
|
2157 |
Creates a session with an agent.
|
2158 |
|
2159 |
-
|
2160 |
|
2161 |
- Method: POST
|
2162 |
- URL: `/api/v1/agents/{agent_id}/sessions`
|
@@ -2165,7 +2164,7 @@ Creates a session with an agent.
|
|
2165 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2166 |
- Body:
|
2167 |
|
2168 |
-
|
2169 |
|
2170 |
```bash
|
2171 |
curl --request POST \
|
@@ -2176,12 +2175,12 @@ curl --request POST \
|
|
2176 |
}'
|
2177 |
```
|
2178 |
|
2179 |
-
|
2180 |
|
2181 |
- `agent_id`: (*Path parameter*)
|
2182 |
The ID of the associated agent assistant.
|
2183 |
|
2184 |
-
|
2185 |
|
2186 |
Success:
|
2187 |
|
@@ -2299,7 +2298,7 @@ Failure:
|
|
2299 |
|
2300 |
---
|
2301 |
|
2302 |
-
|
2303 |
|
2304 |
**POST** `/api/v1/agents/{agent_id}/completions`
|
2305 |
|
@@ -2320,7 +2319,7 @@ Asks a specified agent a question to start an AI-powered conversation.
|
|
2320 |
|
2321 |
:::
|
2322 |
|
2323 |
-
|
2324 |
|
2325 |
- Method: POST
|
2326 |
- URL: `/api/v1/agents/{agent_id}/completions`
|
@@ -2332,7 +2331,7 @@ Asks a specified agent a question to start an AI-powered conversation.
|
|
2332 |
- `"stream"`: `boolean`
|
2333 |
- `"session_id"`: `string`
|
2334 |
- other parameters: `string`
|
2335 |
-
|
2336 |
|
2337 |
```bash
|
2338 |
curl --request POST \
|
@@ -2368,7 +2367,7 @@ curl --request POST \
|
|
2368 |
```
|
2369 |
|
2370 |
|
2371 |
-
|
2372 |
|
2373 |
- `agent_id`: (*Path parameter*), `string`
|
2374 |
The ID of the associated agent assistant.
|
@@ -2382,7 +2381,7 @@ curl --request POST \
|
|
2382 |
The ID of the session. If it is not provided, a new session will be generated.
|
2383 |
- Other parameters: (*Body Parameter*)
|
2384 |
The parameters in the begin component.
|
2385 |
-
|
2386 |
success without `session_id` provided and with no parameters in the `begin` component:
|
2387 |
```text
|
2388 |
data:{
|
@@ -2600,20 +2599,20 @@ Failure:
|
|
2600 |
|
2601 |
---
|
2602 |
|
2603 |
-
|
2604 |
|
2605 |
**GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
|
2606 |
|
2607 |
Lists sessions associated with a specified agent.
|
2608 |
|
2609 |
-
|
2610 |
|
2611 |
- Method: GET
|
2612 |
- URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
|
2613 |
- Headers:
|
2614 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2615 |
|
2616 |
-
|
2617 |
|
2618 |
```bash
|
2619 |
curl --request GET \
|
@@ -2621,7 +2620,7 @@ curl --request GET \
|
|
2621 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
2622 |
```
|
2623 |
|
2624 |
-
|
2625 |
|
2626 |
- `agent_id`: (*Path parameter*)
|
2627 |
The ID of the associated agent.
|
@@ -2638,7 +2637,7 @@ curl --request GET \
|
|
2638 |
- `id`: (*Filter parameter*), `string`
|
2639 |
The ID of the agent session to retrieve.
|
2640 |
|
2641 |
-
|
2642 |
|
2643 |
Success:
|
2644 |
|
@@ -2789,21 +2788,23 @@ Failure:
|
|
2789 |
"message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
|
2790 |
}
|
2791 |
```
|
|
|
2792 |
---
|
2793 |
-
|
|
|
2794 |
|
2795 |
**GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
|
2796 |
|
2797 |
Lists agents.
|
2798 |
|
2799 |
-
|
2800 |
|
2801 |
- Method: GET
|
2802 |
- URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
|
2803 |
- Headers:
|
2804 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2805 |
|
2806 |
-
|
2807 |
|
2808 |
```bash
|
2809 |
curl --request GET \
|
@@ -2811,7 +2812,7 @@ curl --request GET \
|
|
2811 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
2812 |
```
|
2813 |
|
2814 |
-
|
2815 |
|
2816 |
- `page`: (*Filter parameter*), `integer`
|
2817 |
Specifies the page on which the agents will be displayed. Defaults to `1`.
|
@@ -2828,7 +2829,7 @@ curl --request GET \
|
|
2828 |
- `name`: (*Filter parameter*), `string`
|
2829 |
The name of the agent to retrieve.
|
2830 |
|
2831 |
-
|
2832 |
|
2833 |
Success:
|
2834 |
|
@@ -2897,4 +2898,6 @@ Failure:
|
|
2897 |
"code": 102,
|
2898 |
"message": "The agent doesn't exist."
|
2899 |
}
|
2900 |
-
```
|
|
|
|
|
|
9 |
|
10 |
---
|
11 |
|
12 |
+
## DATASET MANAGEMENT
|
|
|
|
|
13 |
|
14 |
---
|
15 |
|
16 |
+
### Create dataset
|
17 |
|
18 |
**POST** `/api/v1/datasets`
|
19 |
|
20 |
Creates a dataset.
|
21 |
|
22 |
+
#### Request
|
23 |
|
24 |
- Method: POST
|
25 |
- URL: `/api/v1/datasets`
|
|
|
36 |
- `"chunk_method"`: `string`
|
37 |
- `"parser_config"`: `object`
|
38 |
|
39 |
+
##### Request example
|
40 |
|
41 |
```bash
|
42 |
curl --request POST \
|
|
|
48 |
}'
|
49 |
```
|
50 |
|
51 |
+
##### Request parameters
|
52 |
|
53 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
54 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
|
|
112 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
113 |
- `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
|
114 |
|
115 |
+
#### Response
|
116 |
|
117 |
Success:
|
118 |
|
|
|
164 |
|
165 |
---
|
166 |
|
167 |
+
### Delete datasets
|
168 |
|
169 |
**DELETE** `/api/v1/datasets`
|
170 |
|
171 |
Deletes datasets by ID.
|
172 |
|
173 |
+
#### Request
|
174 |
|
175 |
- Method: DELETE
|
176 |
- URL: `/api/v1/datasets`
|
|
|
180 |
- Body:
|
181 |
- `"ids"`: `list[string]`
|
182 |
|
183 |
+
##### Request example
|
184 |
|
185 |
```bash
|
186 |
curl --request DELETE \
|
|
|
192 |
}'
|
193 |
```
|
194 |
|
195 |
+
##### Request parameters
|
196 |
|
197 |
- `"ids"`: (*Body parameter*), `list[string]`
|
198 |
The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
|
199 |
|
200 |
+
#### Response
|
201 |
|
202 |
Success:
|
203 |
|
|
|
218 |
|
219 |
---
|
220 |
|
221 |
+
### Update dataset
|
222 |
|
223 |
**PUT** `/api/v1/datasets/{dataset_id}`
|
224 |
|
225 |
Updates configurations for a specified dataset.
|
226 |
|
227 |
+
#### Request
|
228 |
|
229 |
- Method: PUT
|
230 |
- URL: `/api/v1/datasets/{dataset_id}`
|
|
|
236 |
- `"embedding_model"`: `string`
|
237 |
- `"chunk_method"`: `enum<string>`
|
238 |
|
239 |
+
##### Request example
|
240 |
|
241 |
```bash
|
242 |
curl --request PUT \
|
|
|
249 |
}'
|
250 |
```
|
251 |
|
252 |
+
##### Request parameters
|
253 |
|
254 |
- `dataset_id`: (*Path parameter*)
|
255 |
The ID of the dataset to update.
|
|
|
274 |
- `"knowledge_graph"`: Knowledge Graph
|
275 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
276 |
|
277 |
+
#### Response
|
278 |
|
279 |
Success:
|
280 |
|
|
|
295 |
|
296 |
---
|
297 |
|
298 |
+
### List datasets
|
299 |
|
300 |
**GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
301 |
|
302 |
Lists datasets.
|
303 |
|
304 |
+
#### Request
|
305 |
|
306 |
- Method: GET
|
307 |
- URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
308 |
- Headers:
|
309 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
310 |
|
311 |
+
##### Request example
|
312 |
|
313 |
```bash
|
314 |
curl --request GET \
|
|
|
316 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
317 |
```
|
318 |
|
319 |
+
##### Request parameters
|
320 |
|
321 |
- `page`: (*Filter parameter*)
|
322 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
|
|
333 |
- `id`: (*Filter parameter*)
|
334 |
The ID of the dataset to retrieve.
|
335 |
|
336 |
+
#### Response
|
337 |
|
338 |
Success:
|
339 |
|
|
|
389 |
|
390 |
---
|
391 |
|
392 |
+
## FILE MANAGEMENT WITHIN DATASET
|
|
|
|
|
393 |
|
394 |
---
|
395 |
|
396 |
+
### Upload documents
|
397 |
|
398 |
**POST** `/api/v1/datasets/{dataset_id}/documents`
|
399 |
|
400 |
Uploads documents to a specified dataset.
|
401 |
|
402 |
+
#### Request
|
403 |
|
404 |
- Method: POST
|
405 |
- URL: `/api/v1/datasets/{dataset_id}/documents`
|
|
|
409 |
- Form:
|
410 |
- `'file=@{FILE_PATH}'`
|
411 |
|
412 |
+
##### Request example
|
413 |
|
414 |
```bash
|
415 |
curl --request POST \
|
|
|
420 |
--form 'file=@./test2.pdf'
|
421 |
```
|
422 |
|
423 |
+
##### Request parameters
|
424 |
|
425 |
- `dataset_id`: (*Path parameter*)
|
426 |
The ID of the dataset to which the documents will be uploaded.
|
427 |
- `'file'`: (*Body parameter*)
|
428 |
A document to upload.
|
429 |
|
430 |
+
#### Response
|
431 |
|
432 |
Success:
|
433 |
|
|
|
471 |
|
472 |
---
|
473 |
|
474 |
+
### Update document
|
475 |
|
476 |
**PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
477 |
|
478 |
Updates configurations for a specified document.
|
479 |
|
480 |
+
#### Request
|
481 |
|
482 |
- Method: PUT
|
483 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
|
|
489 |
- `"chunk_method"`:`string`
|
490 |
- `"parser_config"`:`object`
|
491 |
|
492 |
+
##### Request example
|
493 |
|
494 |
```bash
|
495 |
curl --request PUT \
|
|
|
505 |
|
506 |
```
|
507 |
|
508 |
+
##### Request parameters
|
509 |
|
510 |
- `dataset_id`: (*Path parameter*)
|
511 |
The ID of the associated dataset.
|
|
|
544 |
- `"delimiter"`: Defaults to `"\n!?。;!?"`.
|
545 |
- `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
|
546 |
|
547 |
+
#### Response
|
548 |
|
549 |
Success:
|
550 |
|
|
|
565 |
|
566 |
---
|
567 |
|
568 |
+
### Download document
|
569 |
|
570 |
**GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
571 |
|
572 |
Downloads a document from a specified dataset.
|
573 |
|
574 |
+
#### Request
|
575 |
|
576 |
- Method: GET
|
577 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
|
|
|
580 |
- Output:
|
581 |
- `'{PATH_TO_THE_FILE}'`
|
582 |
|
583 |
+
##### Request example
|
584 |
|
585 |
```bash
|
586 |
curl --request GET \
|
|
|
589 |
--output ./ragflow.txt
|
590 |
```
|
591 |
|
592 |
+
##### Request parameters
|
593 |
|
594 |
- `dataset_id`: (*Path parameter*)
|
595 |
The associated dataset ID.
|
596 |
- `documents_id`: (*Path parameter*)
|
597 |
The ID of the document to download.
|
598 |
|
599 |
+
#### Response
|
600 |
|
601 |
Success:
|
602 |
|
|
|
615 |
|
616 |
---
|
617 |
|
618 |
+
### List documents
|
619 |
|
620 |
**GET** `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
|
621 |
|
622 |
Lists documents in a specified dataset.
|
623 |
|
624 |
+
#### Request
|
625 |
|
626 |
- Method: GET
|
627 |
- URL: `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
|
|
|
629 |
- `'content-Type: application/json'`
|
630 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
631 |
|
632 |
+
##### Request example
|
633 |
|
634 |
```bash
|
635 |
curl --request GET \
|
|
|
637 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
638 |
```
|
639 |
|
640 |
+
##### Request parameters
|
641 |
|
642 |
- `dataset_id`: (*Path parameter*)
|
643 |
The associated dataset ID.
|
|
|
656 |
- `id`: (*Filter parameter*), `string`
|
657 |
The ID of the document to retrieve.
|
658 |
|
659 |
+
#### Response
|
660 |
|
661 |
Success:
|
662 |
|
|
|
712 |
|
713 |
---
|
714 |
|
715 |
+
### Delete documents
|
716 |
|
717 |
**DELETE** `/api/v1/datasets/{dataset_id}/documents`
|
718 |
|
719 |
Deletes documents by ID.
|
720 |
|
721 |
+
#### Request
|
722 |
|
723 |
- Method: DELETE
|
724 |
- URL: `/api/v1/datasets/{dataset_id}/documents`
|
|
|
728 |
- Body:
|
729 |
- `"ids"`: `list[string]`
|
730 |
|
731 |
+
##### Request example
|
732 |
|
733 |
```bash
|
734 |
curl --request DELETE \
|
|
|
741 |
}'
|
742 |
```
|
743 |
|
744 |
+
##### Request parameters
|
745 |
|
746 |
- `dataset_id`: (*Path parameter*)
|
747 |
The associated dataset ID.
|
748 |
- `"ids"`: (*Body parameter*), `list[string]`
|
749 |
The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
|
750 |
|
751 |
+
#### Response
|
752 |
|
753 |
Success:
|
754 |
|
|
|
769 |
|
770 |
---
|
771 |
|
772 |
+
### Parse documents
|
773 |
|
774 |
**POST** `/api/v1/datasets/{dataset_id}/chunks`
|
775 |
|
776 |
Parses documents in a specified dataset.
|
777 |
|
778 |
+
#### Request
|
779 |
|
780 |
- Method: POST
|
781 |
- URL: `/api/v1/datasets/{dataset_id}/chunks`
|
|
|
785 |
- Body:
|
786 |
- `"document_ids"`: `list[string]`
|
787 |
|
788 |
+
##### Request example
|
789 |
|
790 |
```bash
|
791 |
curl --request POST \
|
|
|
798 |
}'
|
799 |
```
|
800 |
|
801 |
+
##### Request parameters
|
802 |
|
803 |
- `dataset_id`: (*Path parameter*)
|
804 |
The dataset ID.
|
805 |
- `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
|
806 |
The IDs of the documents to parse.
|
807 |
|
808 |
+
#### Response
|
809 |
|
810 |
Success:
|
811 |
|
|
|
826 |
|
827 |
---
|
828 |
|
829 |
+
### Stop parsing documents
|
830 |
|
831 |
**DELETE** `/api/v1/datasets/{dataset_id}/chunks`
|
832 |
|
833 |
Stops parsing specified documents.
|
834 |
|
835 |
+
#### Request
|
836 |
|
837 |
- Method: DELETE
|
838 |
- URL: `/api/v1/datasets/{dataset_id}/chunks`
|
|
|
842 |
- Body:
|
843 |
- `"document_ids"`: `list[string]`
|
844 |
|
845 |
+
##### Request example
|
846 |
|
847 |
```bash
|
848 |
curl --request DELETE \
|
|
|
855 |
}'
|
856 |
```
|
857 |
|
858 |
+
##### Request parameters
|
859 |
|
860 |
- `dataset_id`: (*Path parameter*)
|
861 |
The associated dataset ID.
|
862 |
- `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
|
863 |
The IDs of the documents for which the parsing should be stopped.
|
864 |
|
865 |
+
#### Response
|
866 |
|
867 |
Success:
|
868 |
|
|
|
883 |
|
884 |
---
|
885 |
|
886 |
+
### Add chunk
|
887 |
|
888 |
**POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
889 |
|
890 |
Adds a chunk to a specified document in a specified dataset.
|
891 |
|
892 |
+
#### Request
|
893 |
|
894 |
- Method: POST
|
895 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
|
|
900 |
- `"content"`: `string`
|
901 |
- `"important_keywords"`: `list[string]`
|
902 |
|
903 |
+
##### Request example
|
904 |
|
905 |
```bash
|
906 |
curl --request POST \
|
|
|
913 |
}'
|
914 |
```
|
915 |
|
916 |
+
##### Request parameters
|
917 |
|
918 |
- `dataset_id`: (*Path parameter*)
|
919 |
The associated dataset ID.
|
|
|
924 |
- `"important_keywords`(*Body parameter*), `list[string]`
|
925 |
The key terms or phrases to tag with the chunk.
|
926 |
|
927 |
+
#### Response
|
928 |
|
929 |
Success:
|
930 |
|
|
|
958 |
|
959 |
---
|
960 |
|
961 |
+
### List chunks
|
962 |
|
963 |
**GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}`
|
964 |
|
965 |
Lists chunks in a specified document.
|
966 |
|
967 |
+
#### Request
|
968 |
|
969 |
- Method: GET
|
970 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id}`
|
971 |
- Headers:
|
972 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
973 |
|
974 |
+
##### Request example
|
975 |
|
976 |
```bash
|
977 |
curl --request GET \
|
|
|
979 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
980 |
```
|
981 |
|
982 |
+
##### Request parameters
|
983 |
|
984 |
- `dataset_id`: (*Path parameter*)
|
985 |
The associated dataset ID.
|
|
|
994 |
- `id`(*Filter parameter*), `string`
|
995 |
The ID of the chunk to retrieve.
|
996 |
|
997 |
+
#### Response
|
998 |
|
999 |
Success:
|
1000 |
|
|
|
1065 |
|
1066 |
---
|
1067 |
|
1068 |
+
### Delete chunks
|
1069 |
|
1070 |
**DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
1071 |
|
1072 |
Deletes chunks by ID.
|
1073 |
|
1074 |
+
#### Request
|
1075 |
|
1076 |
- Method: DELETE
|
1077 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
|
|
|
1081 |
- Body:
|
1082 |
- `"chunk_ids"`: `list[string]`
|
1083 |
|
1084 |
+
##### Request example
|
1085 |
|
1086 |
```bash
|
1087 |
curl --request DELETE \
|
|
|
1094 |
}'
|
1095 |
```
|
1096 |
|
1097 |
+
##### Request parameters
|
1098 |
|
1099 |
- `dataset_id`: (*Path parameter*)
|
1100 |
The associated dataset ID.
|
|
|
1103 |
- `"chunk_ids"`: (*Body parameter*), `list[string]`
|
1104 |
The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
|
1105 |
|
1106 |
+
#### Response
|
1107 |
|
1108 |
Success:
|
1109 |
|
|
|
1124 |
|
1125 |
---
|
1126 |
|
1127 |
+
### Update chunk
|
1128 |
|
1129 |
**PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
|
1130 |
|
1131 |
Updates content or configurations for a specified chunk.
|
1132 |
|
1133 |
+
#### Request
|
1134 |
|
1135 |
- Method: PUT
|
1136 |
- URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
|
|
|
1142 |
- `"important_keywords"`: `list[string]`
|
1143 |
- `"available"`: `boolean`
|
1144 |
|
1145 |
+
##### Request example
|
1146 |
|
1147 |
```bash
|
1148 |
curl --request PUT \
|
|
|
1156 |
}'
|
1157 |
```
|
1158 |
|
1159 |
+
##### Request parameters
|
1160 |
|
1161 |
- `dataset_id`: (*Path parameter*)
|
1162 |
The associated dataset ID.
|
|
|
1173 |
- `true`: Available (default)
|
1174 |
- `false`: Unavailable
|
1175 |
|
1176 |
+
#### Response
|
1177 |
|
1178 |
Success:
|
1179 |
|
|
|
1194 |
|
1195 |
---
|
1196 |
|
1197 |
+
### Retrieve chunks
|
1198 |
|
1199 |
**POST** `/api/v1/retrieval`
|
1200 |
|
1201 |
Retrieves chunks from specified datasets.
|
1202 |
|
1203 |
+
#### Request
|
1204 |
|
1205 |
- Method: POST
|
1206 |
- URL: `/api/v1/retrieval`
|
|
|
1220 |
- `"keyword"`: `boolean`
|
1221 |
- `"highlight"`: `boolean`
|
1222 |
|
1223 |
+
##### Request example
|
1224 |
|
1225 |
```bash
|
1226 |
curl --request POST \
|
|
|
1235 |
}'
|
1236 |
```
|
1237 |
|
1238 |
+
##### Request parameter
|
1239 |
|
1240 |
- `"question"`: (*Body parameter*), `string`, *Required*
|
1241 |
The user query or query keywords.
|
|
|
1264 |
- `true`: Enable highlighting of matched terms.
|
1265 |
- `false`: Disable highlighting of matched terms (default).
|
1266 |
|
1267 |
+
#### Response
|
1268 |
|
1269 |
Success:
|
1270 |
|
|
|
1316 |
|
1317 |
---
|
1318 |
|
1319 |
+
## CHAT ASSISTANT MANAGEMENT
|
|
|
|
|
1320 |
|
1321 |
---
|
1322 |
|
1323 |
+
### Create chat assistant
|
1324 |
|
1325 |
**POST** `/api/v1/chats`
|
1326 |
|
1327 |
Creates a chat assistant.
|
1328 |
|
1329 |
+
#### Request
|
1330 |
|
1331 |
- Method: POST
|
1332 |
- URL: `/api/v1/chats`
|
|
|
1340 |
- `"llm"`: `object`
|
1341 |
- `"prompt"`: `object`
|
1342 |
|
1343 |
+
##### Request example
|
1344 |
|
1345 |
```shell
|
1346 |
curl --request POST \
|
|
|
1353 |
}'
|
1354 |
```
|
1355 |
|
1356 |
+
##### Request parameters
|
1357 |
|
1358 |
- `"name"`: (*Body parameter*), `string`, *Required*
|
1359 |
The name of the chat assistant.
|
|
|
1390 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1391 |
- `"prompt"`: `string` The prompt content.
|
1392 |
|
1393 |
+
#### Response
|
1394 |
|
1395 |
Success:
|
1396 |
|
|
|
1453 |
|
1454 |
---
|
1455 |
|
1456 |
+
### Update chat assistant
|
1457 |
|
1458 |
**PUT** `/api/v1/chats/{chat_id}`
|
1459 |
|
1460 |
Updates configurations for a specified chat assistant.
|
1461 |
|
1462 |
+
#### Request
|
1463 |
|
1464 |
- Method: PUT
|
1465 |
- URL: `/api/v1/chats/{chat_id}`
|
|
|
1473 |
- `"llm"`: `object`
|
1474 |
- `"prompt"`: `object`
|
1475 |
|
1476 |
+
##### Request example
|
1477 |
|
1478 |
```bash
|
1479 |
curl --request PUT \
|
|
|
1525 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
1526 |
- `"prompt"`: `string` The prompt content.
|
1527 |
|
1528 |
+
#### Response
|
1529 |
|
1530 |
Success:
|
1531 |
|
|
|
1546 |
|
1547 |
---
|
1548 |
|
1549 |
+
### Delete chat assistants
|
1550 |
|
1551 |
**DELETE** `/api/v1/chats`
|
1552 |
|
1553 |
Deletes chat assistants by ID.
|
1554 |
|
1555 |
+
#### Request
|
1556 |
|
1557 |
- Method: DELETE
|
1558 |
- URL: `/api/v1/chats`
|
|
|
1562 |
- Body:
|
1563 |
- `"ids"`: `list[string]`
|
1564 |
|
1565 |
+
##### Request example
|
1566 |
|
1567 |
```bash
|
1568 |
curl --request DELETE \
|
|
|
1575 |
}'
|
1576 |
```
|
1577 |
|
1578 |
+
##### Request parameters
|
1579 |
|
1580 |
- `"ids"`: (*Body parameter*), `list[string]`
|
1581 |
The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
|
1582 |
|
1583 |
+
#### Response
|
1584 |
|
1585 |
Success:
|
1586 |
|
|
|
1601 |
|
1602 |
---
|
1603 |
|
1604 |
+
### List chat assistants
|
1605 |
|
1606 |
**GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
|
1607 |
|
1608 |
Lists chat assistants.
|
1609 |
|
1610 |
+
#### Request
|
1611 |
|
1612 |
- Method: GET
|
1613 |
- URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
|
1614 |
- Headers:
|
1615 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
1616 |
|
1617 |
+
##### Request example
|
1618 |
|
1619 |
```bash
|
1620 |
curl --request GET \
|
|
|
1622 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
1623 |
```
|
1624 |
|
1625 |
+
##### Request parameters
|
1626 |
|
1627 |
- `page`: (*Filter parameter*), `integer`
|
1628 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
|
|
1639 |
- `name`: (*Filter parameter*), `string`
|
1640 |
The name of the chat assistant to retrieve.
|
1641 |
|
1642 |
+
#### Response
|
1643 |
|
1644 |
Success:
|
1645 |
|
|
|
1700 |
}
|
1701 |
```
|
1702 |
|
1703 |
+
---
|
1704 |
+
|
1705 |
+
## CHAT SESSIONS
|
1706 |
+
|
1707 |
+
---
|
1708 |
+
|
1709 |
+
### Create session with chat assistant
|
1710 |
|
1711 |
**POST** `/api/v1/chats/{chat_id}/sessions`
|
1712 |
|
1713 |
Creates a session with a chat assistant.
|
1714 |
|
1715 |
+
#### Request
|
1716 |
|
1717 |
- Method: POST
|
1718 |
- URL: `/api/v1/chats/{chat_id}/sessions`
|
|
|
1722 |
- Body:
|
1723 |
- `"name"`: `string`
|
1724 |
|
1725 |
+
##### Request example
|
1726 |
|
1727 |
```bash
|
1728 |
curl --request POST \
|
|
|
1735 |
}'
|
1736 |
```
|
1737 |
|
1738 |
+
##### Request parameters
|
1739 |
|
1740 |
- `chat_id`: (*Path parameter*)
|
1741 |
The ID of the associated chat assistant.
|
1742 |
- `"name"`: (*Body parameter*), `string`
|
1743 |
The name of the chat session to create.
|
1744 |
|
1745 |
+
#### Response
|
1746 |
|
1747 |
Success:
|
1748 |
|
|
|
1778 |
|
1779 |
---
|
1780 |
|
1781 |
+
### Update session
|
1782 |
|
1783 |
**PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
|
1784 |
|
1785 |
Updates a session of a specified chat assistant.
|
1786 |
|
1787 |
+
#### Request
|
1788 |
|
1789 |
- Method: PUT
|
1790 |
- URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
|
|
|
1794 |
- Body:
|
1795 |
- `"name`: `string`
|
1796 |
|
1797 |
+
##### Request example
|
1798 |
|
1799 |
```bash
|
1800 |
curl --request PUT \
|
|
|
1807 |
}'
|
1808 |
```
|
1809 |
|
1810 |
+
##### Request Parameter
|
1811 |
|
1812 |
- `chat_id`: (*Path parameter*)
|
1813 |
The ID of the associated chat assistant.
|
|
|
1816 |
- `"name"`: (*Body Parameter), `string`
|
1817 |
The revised name of the session.
|
1818 |
|
1819 |
+
#### Response
|
1820 |
|
1821 |
Success:
|
1822 |
|
|
|
1837 |
|
1838 |
---
|
1839 |
|
1840 |
+
### List sessions
|
1841 |
|
1842 |
**GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
|
1843 |
|
1844 |
Lists sessions associated with a specified chat assistant.
|
1845 |
|
1846 |
+
#### Request
|
1847 |
|
1848 |
- Method: GET
|
1849 |
- URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
|
1850 |
- Headers:
|
1851 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
1852 |
|
1853 |
+
##### Request example
|
1854 |
|
1855 |
```bash
|
1856 |
curl --request GET \
|
|
|
1858 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
1859 |
```
|
1860 |
|
1861 |
+
##### Request Parameters
|
1862 |
|
1863 |
- `chat_id`: (*Path parameter*)
|
1864 |
The ID of the associated chat assistant.
|
|
|
1877 |
- `id`: (*Filter parameter*), `string`
|
1878 |
The ID of the chat session to retrieve.
|
1879 |
|
1880 |
+
#### Response
|
1881 |
|
1882 |
Success:
|
1883 |
|
|
|
1915 |
|
1916 |
---
|
1917 |
|
1918 |
+
### Delete sessions
|
1919 |
|
1920 |
**DELETE** `/api/v1/chats/{chat_id}/sessions`
|
1921 |
|
1922 |
Deletes sessions of a chat assistant by ID.
|
1923 |
|
1924 |
+
#### Request
|
1925 |
|
1926 |
- Method: DELETE
|
1927 |
- URL: `/api/v1/chats/{chat_id}/sessions`
|
|
|
1931 |
- Body:
|
1932 |
- `"ids"`: `list[string]`
|
1933 |
|
1934 |
+
##### Request example
|
1935 |
|
1936 |
```bash
|
|
|
1937 |
curl --request DELETE \
|
1938 |
--url http://{address}/api/v1/chats/{chat_id}/sessions \
|
1939 |
--header 'Content-Type: application/json' \
|
|
|
1944 |
}'
|
1945 |
```
|
1946 |
|
1947 |
+
##### Request Parameters
|
1948 |
|
1949 |
- `chat_id`: (*Path parameter*)
|
1950 |
The ID of the associated chat assistant.
|
1951 |
- `"ids"`: (*Body Parameter*), `list[string]`
|
1952 |
The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
|
1953 |
|
1954 |
+
#### Response
|
1955 |
|
1956 |
Success:
|
1957 |
|
|
|
1972 |
|
1973 |
---
|
1974 |
|
1975 |
+
### Converse with chat assistant
|
1976 |
|
1977 |
**POST** `/api/v1/chats/{chat_id}/completions`
|
1978 |
|
|
|
1993 |
|
1994 |
:::
|
1995 |
|
1996 |
+
#### Request
|
1997 |
|
1998 |
- Method: POST
|
1999 |
- URL: `/api/v1/chats/{chat_id}/completions`
|
|
|
2005 |
- `"stream"`: `boolean`
|
2006 |
- `"session_id"`: `string`
|
2007 |
|
2008 |
+
##### Request example
|
2009 |
|
2010 |
```bash
|
2011 |
curl --request POST \
|
|
|
2028 |
"session_id":"9fa7691cb85c11ef9c5f0242ac120005"
|
2029 |
}'
|
2030 |
```
|
2031 |
+
|
2032 |
+
##### Request Parameters
|
2033 |
|
2034 |
- `chat_id`: (*Path parameter*)
|
2035 |
The ID of the associated chat assistant.
|
|
|
2042 |
- `"session_id"`: (*Body Parameter*)
|
2043 |
The ID of session. If it is not provided, a new session will be generated.
|
2044 |
|
2045 |
+
#### Response
|
2046 |
+
|
2047 |
Success without `session_id`:
|
2048 |
```text
|
2049 |
data:{
|
|
|
2149 |
|
2150 |
---
|
2151 |
|
2152 |
+
### Create session with agent
|
|
|
|
|
2153 |
|
2154 |
**POST** `/api/v1/agents/{agent_id}/sessions`
|
2155 |
|
2156 |
Creates a session with an agent.
|
2157 |
|
2158 |
+
#### Request
|
2159 |
|
2160 |
- Method: POST
|
2161 |
- URL: `/api/v1/agents/{agent_id}/sessions`
|
|
|
2164 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2165 |
- Body:
|
2166 |
|
2167 |
+
##### Request example
|
2168 |
|
2169 |
```bash
|
2170 |
curl --request POST \
|
|
|
2175 |
}'
|
2176 |
```
|
2177 |
|
2178 |
+
##### Request parameters
|
2179 |
|
2180 |
- `agent_id`: (*Path parameter*)
|
2181 |
The ID of the associated agent assistant.
|
2182 |
|
2183 |
+
#### Response
|
2184 |
|
2185 |
Success:
|
2186 |
|
|
|
2298 |
|
2299 |
---
|
2300 |
|
2301 |
+
### Converse with agent
|
2302 |
|
2303 |
**POST** `/api/v1/agents/{agent_id}/completions`
|
2304 |
|
|
|
2319 |
|
2320 |
:::
|
2321 |
|
2322 |
+
#### Request
|
2323 |
|
2324 |
- Method: POST
|
2325 |
- URL: `/api/v1/agents/{agent_id}/completions`
|
|
|
2331 |
- `"stream"`: `boolean`
|
2332 |
- `"session_id"`: `string`
|
2333 |
- other parameters: `string`
|
2334 |
+
##### Request example
|
2335 |
|
2336 |
```bash
|
2337 |
curl --request POST \
|
|
|
2367 |
```
|
2368 |
|
2369 |
|
2370 |
+
##### Request Parameters
|
2371 |
|
2372 |
- `agent_id`: (*Path parameter*), `string`
|
2373 |
The ID of the associated agent assistant.
|
|
|
2381 |
The ID of the session. If it is not provided, a new session will be generated.
|
2382 |
- Other parameters: (*Body Parameter*)
|
2383 |
The parameters in the begin component.
|
2384 |
+
#### Response
|
2385 |
success without `session_id` provided and with no parameters in the `begin` component:
|
2386 |
```text
|
2387 |
data:{
|
|
|
2599 |
|
2600 |
---
|
2601 |
|
2602 |
+
### List agent sessions
|
2603 |
|
2604 |
**GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
|
2605 |
|
2606 |
Lists sessions associated with a specified agent.
|
2607 |
|
2608 |
+
#### Request
|
2609 |
|
2610 |
- Method: GET
|
2611 |
- URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
|
2612 |
- Headers:
|
2613 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2614 |
|
2615 |
+
##### Request example
|
2616 |
|
2617 |
```bash
|
2618 |
curl --request GET \
|
|
|
2620 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
2621 |
```
|
2622 |
|
2623 |
+
##### Request Parameters
|
2624 |
|
2625 |
- `agent_id`: (*Path parameter*)
|
2626 |
The ID of the associated agent.
|
|
|
2637 |
- `id`: (*Filter parameter*), `string`
|
2638 |
The ID of the agent session to retrieve.
|
2639 |
|
2640 |
+
#### Response
|
2641 |
|
2642 |
Success:
|
2643 |
|
|
|
2788 |
"message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
|
2789 |
}
|
2790 |
```
|
2791 |
+
|
2792 |
---
|
2793 |
+
|
2794 |
+
### List agents
|
2795 |
|
2796 |
**GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
|
2797 |
|
2798 |
Lists agents.
|
2799 |
|
2800 |
+
#### Request
|
2801 |
|
2802 |
- Method: GET
|
2803 |
- URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
|
2804 |
- Headers:
|
2805 |
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
2806 |
|
2807 |
+
##### Request example
|
2808 |
|
2809 |
```bash
|
2810 |
curl --request GET \
|
|
|
2812 |
--header 'Authorization: Bearer <YOUR_API_KEY>'
|
2813 |
```
|
2814 |
|
2815 |
+
##### Request parameters
|
2816 |
|
2817 |
- `page`: (*Filter parameter*), `integer`
|
2818 |
Specifies the page on which the agents will be displayed. Defaults to `1`.
|
|
|
2829 |
- `name`: (*Filter parameter*), `string`
|
2830 |
The name of the agent to retrieve.
|
2831 |
|
2832 |
+
#### Response
|
2833 |
|
2834 |
Success:
|
2835 |
|
|
|
2898 |
"code": 102,
|
2899 |
"message": "The agent doesn't exist."
|
2900 |
}
|
2901 |
+
```
|
2902 |
+
|
2903 |
+
---
|
docs/references/python_api_reference.md
CHANGED
@@ -7,22 +7,21 @@ slug: /python_api_reference
|
|
7 |
|
8 |
A complete reference for RAGFlow's Python APIs. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](https://ragflow.io/docs/dev/acquire_ragflow_api_key).
|
9 |
|
10 |
-
|
|
|
11 |
|
12 |
-
|
13 |
-
|
|
|
14 |
:::
|
15 |
|
16 |
---
|
17 |
-
### Install the RAGFlow SDK
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
pip install ragflow-sdk
|
23 |
-
```
|
24 |
|
25 |
-
|
26 |
|
27 |
```python
|
28 |
RAGFlow.create_dataset(
|
@@ -39,9 +38,9 @@ RAGFlow.create_dataset(
|
|
39 |
|
40 |
Creates a dataset.
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
|
46 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
47 |
|
@@ -53,29 +52,29 @@ The unique name of the dataset to create. It must adhere to the following requir
|
|
53 |
- Maximum 65,535 characters.
|
54 |
- Case-insensitive.
|
55 |
|
56 |
-
|
57 |
|
58 |
Base64 encoding of the avatar. Defaults to `""`
|
59 |
|
60 |
-
|
61 |
|
62 |
A brief description of the dataset to create. Defaults to `""`.
|
63 |
|
64 |
-
|
65 |
|
66 |
The language setting of the dataset to create. Available options:
|
67 |
|
68 |
- `"English"` (default)
|
69 |
- `"Chinese"`
|
70 |
|
71 |
-
|
72 |
|
73 |
Specifies who can access the dataset to create. Available options:
|
74 |
|
75 |
- `"me"`: (Default) Only you can manage the dataset.
|
76 |
- `"team"`: All team members can manage the dataset.
|
77 |
|
78 |
-
|
79 |
|
80 |
The chunking method of the dataset to create. Available options:
|
81 |
|
@@ -93,7 +92,7 @@ The chunking method of the dataset to create. Available options:
|
|
93 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
94 |
- `"email"`: Email
|
95 |
|
96 |
-
|
97 |
|
98 |
The parser configuration of the dataset. A `ParserConfig` object's attributes vary based on the selected `chunk_method`:
|
99 |
|
@@ -122,12 +121,12 @@ The parser configuration of the dataset. A `ParserConfig` object's attributes va
|
|
122 |
- `chunk_method`=`"email"`:
|
123 |
`None`
|
124 |
|
125 |
-
|
126 |
|
127 |
- Success: A `dataset` object.
|
128 |
- Failure: `Exception`
|
129 |
|
130 |
-
|
131 |
|
132 |
```python
|
133 |
from ragflow_sdk import RAGFlow
|
@@ -138,7 +137,7 @@ dataset = rag_object.create_dataset(name="kb_1")
|
|
138 |
|
139 |
---
|
140 |
|
141 |
-
|
142 |
|
143 |
```python
|
144 |
RAGFlow.delete_datasets(ids: list[str] = None)
|
@@ -146,18 +145,18 @@ RAGFlow.delete_datasets(ids: list[str] = None)
|
|
146 |
|
147 |
Deletes datasets by ID.
|
148 |
|
149 |
-
|
150 |
|
151 |
-
|
152 |
|
153 |
The IDs of the datasets to delete. Defaults to `None`. If it is not specified, all datasets will be deleted.
|
154 |
|
155 |
-
|
156 |
|
157 |
- Success: No value is returned.
|
158 |
- Failure: `Exception`
|
159 |
|
160 |
-
|
161 |
|
162 |
```python
|
163 |
rag_object.delete_datasets(ids=["id_1","id_2"])
|
@@ -165,7 +164,7 @@ rag_object.delete_datasets(ids=["id_1","id_2"])
|
|
165 |
|
166 |
---
|
167 |
|
168 |
-
|
169 |
|
170 |
```python
|
171 |
RAGFlow.list_datasets(
|
@@ -180,50 +179,50 @@ RAGFlow.list_datasets(
|
|
180 |
|
181 |
Lists datasets.
|
182 |
|
183 |
-
|
184 |
|
185 |
-
|
186 |
|
187 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
188 |
|
189 |
-
|
190 |
|
191 |
The number of datasets on each page. Defaults to `30`.
|
192 |
|
193 |
-
|
194 |
|
195 |
The field by which datasets should be sorted. Available options:
|
196 |
|
197 |
- `"create_time"` (default)
|
198 |
- `"update_time"`
|
199 |
|
200 |
-
|
201 |
|
202 |
Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `True`.
|
203 |
|
204 |
-
|
205 |
|
206 |
The ID of the dataset to retrieve. Defaults to `None`.
|
207 |
|
208 |
-
|
209 |
|
210 |
The name of the dataset to retrieve. Defaults to `None`.
|
211 |
|
212 |
-
|
213 |
|
214 |
- Success: A list of `DataSet` objects.
|
215 |
- Failure: `Exception`.
|
216 |
|
217 |
-
|
218 |
|
219 |
-
|
220 |
|
221 |
```python
|
222 |
for dataset in rag_object.list_datasets():
|
223 |
print(dataset)
|
224 |
```
|
225 |
|
226 |
-
|
227 |
|
228 |
```python
|
229 |
dataset = rag_object.list_datasets(id = "id_1")
|
@@ -232,7 +231,7 @@ print(dataset[0])
|
|
232 |
|
233 |
---
|
234 |
|
235 |
-
|
236 |
|
237 |
```python
|
238 |
DataSet.update(update_message: dict)
|
@@ -240,9 +239,9 @@ DataSet.update(update_message: dict)
|
|
240 |
|
241 |
Updates configurations for the current dataset.
|
242 |
|
243 |
-
|
244 |
|
245 |
-
|
246 |
|
247 |
A dictionary representing the attributes to update, with the following keys:
|
248 |
|
@@ -264,12 +263,12 @@ A dictionary representing the attributes to update, with the following keys:
|
|
264 |
- `"knowledge_graph"`: Knowledge Graph
|
265 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
266 |
|
267 |
-
|
268 |
|
269 |
- Success: No value is returned.
|
270 |
- Failure: `Exception`
|
271 |
|
272 |
-
|
273 |
|
274 |
```python
|
275 |
from ragflow_sdk import RAGFlow
|
@@ -281,13 +280,11 @@ dataset.update({"embedding_model":"BAAI/bge-zh-v1.5", "chunk_method":"manual"})
|
|
281 |
|
282 |
---
|
283 |
|
284 |
-
|
285 |
-
File Management within Dataset
|
286 |
-
:::
|
287 |
|
288 |
---
|
289 |
|
290 |
-
|
291 |
|
292 |
```python
|
293 |
DataSet.upload_documents(document_list: list[dict])
|
@@ -295,21 +292,21 @@ DataSet.upload_documents(document_list: list[dict])
|
|
295 |
|
296 |
Uploads documents to the current dataset.
|
297 |
|
298 |
-
|
299 |
|
300 |
-
|
301 |
|
302 |
A list of dictionaries representing the documents to upload, each containing the following keys:
|
303 |
|
304 |
- `"display_name"`: (Optional) The file name to display in the dataset.
|
305 |
- `"blob"`: (Optional) The binary content of the file to upload.
|
306 |
|
307 |
-
|
308 |
|
309 |
- Success: No value is returned.
|
310 |
- Failure: `Exception`
|
311 |
|
312 |
-
|
313 |
|
314 |
```python
|
315 |
dataset = rag_object.create_dataset(name="kb_name")
|
@@ -318,7 +315,7 @@ dataset.upload_documents([{"display_name": "1.txt", "blob": "<BINARY_CONTENT_OF_
|
|
318 |
|
319 |
---
|
320 |
|
321 |
-
|
322 |
|
323 |
```python
|
324 |
Document.update(update_message:dict)
|
@@ -326,9 +323,9 @@ Document.update(update_message:dict)
|
|
326 |
|
327 |
Updates configurations for the current document.
|
328 |
|
329 |
-
|
330 |
|
331 |
-
|
332 |
|
333 |
A dictionary representing the attributes to update, with the following keys:
|
334 |
|
@@ -373,12 +370,12 @@ A dictionary representing the attributes to update, with the following keys:
|
|
373 |
- `chunk_method`=`"email"`:
|
374 |
`None`
|
375 |
|
376 |
-
|
377 |
|
378 |
- Success: No value is returned.
|
379 |
- Failure: `Exception`
|
380 |
|
381 |
-
|
382 |
|
383 |
```python
|
384 |
from ragflow_sdk import RAGFlow
|
@@ -393,7 +390,7 @@ doc.update([{"parser_config": {"chunk_token_count": 256}}, {"chunk_method": "man
|
|
393 |
|
394 |
---
|
395 |
|
396 |
-
|
397 |
|
398 |
```python
|
399 |
Document.download() -> bytes
|
@@ -401,11 +398,11 @@ Document.download() -> bytes
|
|
401 |
|
402 |
Downloads the current document.
|
403 |
|
404 |
-
|
405 |
|
406 |
The downloaded document in bytes.
|
407 |
|
408 |
-
|
409 |
|
410 |
```python
|
411 |
from ragflow_sdk import RAGFlow
|
@@ -421,7 +418,7 @@ print(doc)
|
|
421 |
|
422 |
---
|
423 |
|
424 |
-
|
425 |
|
426 |
```python
|
427 |
Dataset.list_documents(id:str =None, keywords: str=None, page: int=1, page_size:int = 30, order_by:str = "create_time", desc: bool = True) -> list[Document]
|
@@ -429,36 +426,36 @@ Dataset.list_documents(id:str =None, keywords: str=None, page: int=1, page_size:
|
|
429 |
|
430 |
Lists documents in the current dataset.
|
431 |
|
432 |
-
|
433 |
|
434 |
-
|
435 |
|
436 |
The ID of the document to retrieve. Defaults to `None`.
|
437 |
|
438 |
-
|
439 |
|
440 |
The keywords used to match document titles. Defaults to `None`.
|
441 |
|
442 |
-
|
443 |
|
444 |
Specifies the page on which the documents will be displayed. Defaults to `1`.
|
445 |
|
446 |
-
|
447 |
|
448 |
The maximum number of documents on each page. Defaults to `30`.
|
449 |
|
450 |
-
|
451 |
|
452 |
The field by which documents should be sorted. Available options:
|
453 |
|
454 |
- `"create_time"` (default)
|
455 |
- `"update_time"`
|
456 |
|
457 |
-
|
458 |
|
459 |
Indicates whether the retrieved documents should be sorted in descending order. Defaults to `True`.
|
460 |
|
461 |
-
|
462 |
|
463 |
- Success: A list of `Document` objects.
|
464 |
- Failure: `Exception`.
|
@@ -513,7 +510,7 @@ A `Document` object contains the following attributes:
|
|
513 |
- `chunk_method`=`"email"`:
|
514 |
`None`
|
515 |
|
516 |
-
|
517 |
|
518 |
```python
|
519 |
from ragflow_sdk import RAGFlow
|
@@ -530,7 +527,7 @@ for doc in dataset.list_documents(keywords="rag", page=0, page_size=12):
|
|
530 |
|
531 |
---
|
532 |
|
533 |
-
|
534 |
|
535 |
```python
|
536 |
DataSet.delete_documents(ids: list[str] = None)
|
@@ -538,18 +535,18 @@ DataSet.delete_documents(ids: list[str] = None)
|
|
538 |
|
539 |
Deletes documents by ID.
|
540 |
|
541 |
-
|
542 |
|
543 |
-
|
544 |
|
545 |
The IDs of the documents to delete. Defaults to `None`. If it is not specified, all documents in the dataset will be deleted.
|
546 |
|
547 |
-
|
548 |
|
549 |
- Success: No value is returned.
|
550 |
- Failure: `Exception`
|
551 |
|
552 |
-
|
553 |
|
554 |
```python
|
555 |
from ragflow_sdk import RAGFlow
|
@@ -562,7 +559,7 @@ dataset.delete_documents(ids=["id_1","id_2"])
|
|
562 |
|
563 |
---
|
564 |
|
565 |
-
|
566 |
|
567 |
```python
|
568 |
DataSet.async_parse_documents(document_ids:list[str]) -> None
|
@@ -570,18 +567,18 @@ DataSet.async_parse_documents(document_ids:list[str]) -> None
|
|
570 |
|
571 |
Parses documents in the current dataset.
|
572 |
|
573 |
-
|
574 |
|
575 |
-
|
576 |
|
577 |
The IDs of the documents to parse.
|
578 |
|
579 |
-
|
580 |
|
581 |
- Success: No value is returned.
|
582 |
- Failure: `Exception`
|
583 |
|
584 |
-
|
585 |
|
586 |
```python
|
587 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
@@ -602,7 +599,7 @@ print("Async bulk parsing initiated.")
|
|
602 |
|
603 |
---
|
604 |
|
605 |
-
|
606 |
|
607 |
```python
|
608 |
DataSet.async_cancel_parse_documents(document_ids:list[str])-> None
|
@@ -610,18 +607,18 @@ DataSet.async_cancel_parse_documents(document_ids:list[str])-> None
|
|
610 |
|
611 |
Stops parsing specified documents.
|
612 |
|
613 |
-
|
614 |
|
615 |
-
|
616 |
|
617 |
The IDs of the documents for which parsing should be stopped.
|
618 |
|
619 |
-
|
620 |
|
621 |
- Success: No value is returned.
|
622 |
- Failure: `Exception`
|
623 |
|
624 |
-
|
625 |
|
626 |
```python
|
627 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
@@ -644,7 +641,7 @@ print("Async bulk parsing cancelled.")
|
|
644 |
|
645 |
---
|
646 |
|
647 |
-
|
648 |
|
649 |
```python
|
650 |
Document.add_chunk(content:str, important_keywords:list[str] = []) -> Chunk
|
@@ -652,17 +649,17 @@ Document.add_chunk(content:str, important_keywords:list[str] = []) -> Chunk
|
|
652 |
|
653 |
Adds a chunk to the current document.
|
654 |
|
655 |
-
|
656 |
|
657 |
-
|
658 |
|
659 |
The text content of the chunk.
|
660 |
|
661 |
-
|
662 |
|
663 |
The key terms or phrases to tag with the chunk.
|
664 |
|
665 |
-
|
666 |
|
667 |
- Success: A `Chunk` object.
|
668 |
- Failure: `Exception`.
|
@@ -681,8 +678,7 @@ A `Chunk` object contains the following attributes:
|
|
681 |
- `False`: Unavailable
|
682 |
- `True`: Available (default)
|
683 |
|
684 |
-
|
685 |
-
### Examples
|
686 |
|
687 |
```python
|
688 |
from ragflow_sdk import RAGFlow
|
@@ -697,7 +693,7 @@ chunk = doc.add_chunk(content="xxxxxxx")
|
|
697 |
|
698 |
---
|
699 |
|
700 |
-
|
701 |
|
702 |
```python
|
703 |
Document.list_chunks(keywords: str = None, page: int = 1, page_size: int = 30, id : str = None) -> list[Chunk]
|
@@ -705,30 +701,30 @@ Document.list_chunks(keywords: str = None, page: int = 1, page_size: int = 30, i
|
|
705 |
|
706 |
Lists chunks in the current document.
|
707 |
|
708 |
-
|
709 |
|
710 |
-
|
711 |
|
712 |
The keywords used to match chunk content. Defaults to `None`
|
713 |
|
714 |
-
|
715 |
|
716 |
Specifies the page on which the chunks will be displayed. Defaults to `1`.
|
717 |
|
718 |
-
|
719 |
|
720 |
The maximum number of chunks on each page. Defaults to `30`.
|
721 |
|
722 |
-
|
723 |
|
724 |
The ID of the chunk to retrieve. Default: `None`
|
725 |
|
726 |
-
|
727 |
|
728 |
- Success: A list of `Chunk` objects.
|
729 |
- Failure: `Exception`.
|
730 |
|
731 |
-
|
732 |
|
733 |
```python
|
734 |
from ragflow_sdk import RAGFlow
|
@@ -743,7 +739,7 @@ for chunk in doc.list_chunks(keywords="rag", page=0, page_size=12):
|
|
743 |
|
744 |
---
|
745 |
|
746 |
-
|
747 |
|
748 |
```python
|
749 |
Document.delete_chunks(chunk_ids: list[str])
|
@@ -751,18 +747,18 @@ Document.delete_chunks(chunk_ids: list[str])
|
|
751 |
|
752 |
Deletes chunks by ID.
|
753 |
|
754 |
-
|
755 |
|
756 |
-
|
757 |
|
758 |
The IDs of the chunks to delete. Defaults to `None`. If it is not specified, all chunks of the current document will be deleted.
|
759 |
|
760 |
-
|
761 |
|
762 |
- Success: No value is returned.
|
763 |
- Failure: `Exception`
|
764 |
|
765 |
-
|
766 |
|
767 |
```python
|
768 |
from ragflow_sdk import RAGFlow
|
@@ -778,7 +774,7 @@ doc.delete_chunks(["id_1","id_2"])
|
|
778 |
|
779 |
---
|
780 |
|
781 |
-
|
782 |
|
783 |
```python
|
784 |
Chunk.update(update_message: dict)
|
@@ -786,9 +782,9 @@ Chunk.update(update_message: dict)
|
|
786 |
|
787 |
Updates content or configurations for the current chunk.
|
788 |
|
789 |
-
|
790 |
|
791 |
-
|
792 |
|
793 |
A dictionary representing the attributes to update, with the following keys:
|
794 |
|
@@ -798,12 +794,12 @@ A dictionary representing the attributes to update, with the following keys:
|
|
798 |
- `False`: Unavailable
|
799 |
- `True`: Available (default)
|
800 |
|
801 |
-
|
802 |
|
803 |
- Success: No value is returned.
|
804 |
- Failure: `Exception`
|
805 |
|
806 |
-
|
807 |
|
808 |
```python
|
809 |
from ragflow_sdk import RAGFlow
|
@@ -819,7 +815,7 @@ chunk.update({"content":"sdfx..."})
|
|
819 |
|
820 |
---
|
821 |
|
822 |
-
|
823 |
|
824 |
```python
|
825 |
RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, page:int=1, page_size:int=30, 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]
|
@@ -827,64 +823,64 @@ RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[
|
|
827 |
|
828 |
Retrieves chunks from specified datasets.
|
829 |
|
830 |
-
|
831 |
|
832 |
-
|
833 |
|
834 |
The user query or query keywords. Defaults to `""`.
|
835 |
|
836 |
-
|
837 |
|
838 |
The IDs of the datasets to search. Defaults to `None`. If you do not set this argument, ensure that you set `document_ids`.
|
839 |
|
840 |
-
|
841 |
|
842 |
The IDs of the documents to search. Defaults to `None`. You must ensure all selected documents use the same embedding model. Otherwise, an error will occur. If you do not set this argument, ensure that you set `dataset_ids`.
|
843 |
|
844 |
-
|
845 |
|
846 |
The starting index for the documents to retrieve. Defaults to `1`.
|
847 |
|
848 |
-
|
849 |
|
850 |
The maximum number of chunks to retrieve. Defaults to `30`.
|
851 |
|
852 |
-
|
853 |
|
854 |
The minimum similarity score. Defaults to `0.2`.
|
855 |
|
856 |
-
|
857 |
|
858 |
The weight of vector cosine similarity. Defaults to `0.3`. If x represents the vector cosine similarity, then (1 - x) is the term similarity weight.
|
859 |
|
860 |
-
|
861 |
|
862 |
The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
|
863 |
|
864 |
-
|
865 |
|
866 |
The ID of the rerank model. Defaults to `None`.
|
867 |
|
868 |
-
|
869 |
|
870 |
Indicates whether to enable keyword-based matching:
|
871 |
|
872 |
- `True`: Enable keyword-based matching.
|
873 |
- `False`: Disable keyword-based matching (default).
|
874 |
|
875 |
-
|
876 |
|
877 |
Specifies whether to enable highlighting of matched terms in the results:
|
878 |
|
879 |
- `True`: Enable highlighting of matched terms.
|
880 |
- `False`: Disable highlighting of matched terms (default).
|
881 |
|
882 |
-
|
883 |
|
884 |
- Success: A list of `Chunk` objects representing the document chunks.
|
885 |
- Failure: `Exception`
|
886 |
|
887 |
-
|
888 |
|
889 |
```python
|
890 |
from ragflow_sdk import RAGFlow
|
@@ -909,13 +905,11 @@ for c in rag_object.retrieve(question="What's ragflow?",
|
|
909 |
|
910 |
---
|
911 |
|
912 |
-
|
913 |
-
Chat Assistant Management
|
914 |
-
:::
|
915 |
|
916 |
---
|
917 |
|
918 |
-
|
919 |
|
920 |
```python
|
921 |
RAGFlow.create_chat(
|
@@ -929,21 +923,21 @@ RAGFlow.create_chat(
|
|
929 |
|
930 |
Creates a chat assistant.
|
931 |
|
932 |
-
|
933 |
|
934 |
-
|
935 |
|
936 |
The name of the chat assistant.
|
937 |
|
938 |
-
|
939 |
|
940 |
Base64 encoding of the avatar. Defaults to `""`.
|
941 |
|
942 |
-
|
943 |
|
944 |
The IDs of the associated datasets. Defaults to `[""]`.
|
945 |
|
946 |
-
|
947 |
|
948 |
The LLM settings for the chat assistant to create. Defaults to `None`. When the value is `None`, a dictionary with the following values will be generated as the default. An `LLM` object contains the following attributes:
|
949 |
|
@@ -960,7 +954,7 @@ The LLM settings for the chat assistant to create. Defaults to `None`. When the
|
|
960 |
- `max_token`: `int`
|
961 |
The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
|
962 |
|
963 |
-
|
964 |
|
965 |
Instructions for the LLM to follow. A `Prompt` object contains the following attributes:
|
966 |
|
@@ -977,12 +971,12 @@ Instructions for the LLM to follow. A `Prompt` object contains the following at
|
|
977 |
- `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`.
|
978 |
- `prompt`: `str` The prompt content.
|
979 |
|
980 |
-
|
981 |
|
982 |
- Success: A `Chat` object representing the chat assistant.
|
983 |
- Failure: `Exception`
|
984 |
|
985 |
-
|
986 |
|
987 |
```python
|
988 |
from ragflow_sdk import RAGFlow
|
@@ -997,7 +991,7 @@ assistant = rag_object.create_chat("Miss R", dataset_ids=dataset_ids)
|
|
997 |
|
998 |
---
|
999 |
|
1000 |
-
|
1001 |
|
1002 |
```python
|
1003 |
Chat.update(update_message: dict)
|
@@ -1005,9 +999,9 @@ Chat.update(update_message: dict)
|
|
1005 |
|
1006 |
Updates configurations for the current chat assistant.
|
1007 |
|
1008 |
-
|
1009 |
|
1010 |
-
|
1011 |
|
1012 |
A dictionary representing the attributes to update, with the following keys:
|
1013 |
|
@@ -1035,12 +1029,12 @@ A dictionary representing the attributes to update, with the following keys:
|
|
1035 |
- `"show_quote`: `bool` Indicates whether the source of text should be displayed Defaults to `True`.
|
1036 |
- `"prompt"`: `str` The prompt content.
|
1037 |
|
1038 |
-
|
1039 |
|
1040 |
- Success: No value is returned.
|
1041 |
- Failure: `Exception`
|
1042 |
|
1043 |
-
|
1044 |
|
1045 |
```python
|
1046 |
from ragflow_sdk import RAGFlow
|
@@ -1054,7 +1048,7 @@ assistant.update({"name": "Stefan", "llm": {"temperature": 0.8}, "prompt": {"top
|
|
1054 |
|
1055 |
---
|
1056 |
|
1057 |
-
|
1058 |
|
1059 |
```python
|
1060 |
RAGFlow.delete_chats(ids: list[str] = None)
|
@@ -1062,18 +1056,18 @@ RAGFlow.delete_chats(ids: list[str] = None)
|
|
1062 |
|
1063 |
Deletes chat assistants by ID.
|
1064 |
|
1065 |
-
|
1066 |
|
1067 |
-
|
1068 |
|
1069 |
The IDs of the chat assistants to delete. Defaults to `None`. If it is empty or not specified, all chat assistants in the system will be deleted.
|
1070 |
|
1071 |
-
|
1072 |
|
1073 |
- Success: No value is returned.
|
1074 |
- Failure: `Exception`
|
1075 |
|
1076 |
-
|
1077 |
|
1078 |
```python
|
1079 |
from ragflow_sdk import RAGFlow
|
@@ -1084,7 +1078,7 @@ rag_object.delete_chats(ids=["id_1","id_2"])
|
|
1084 |
|
1085 |
---
|
1086 |
|
1087 |
-
|
1088 |
|
1089 |
```python
|
1090 |
RAGFlow.list_chats(
|
@@ -1099,41 +1093,41 @@ RAGFlow.list_chats(
|
|
1099 |
|
1100 |
Lists chat assistants.
|
1101 |
|
1102 |
-
|
1103 |
|
1104 |
-
|
1105 |
|
1106 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
1107 |
|
1108 |
-
|
1109 |
|
1110 |
The number of chat assistants on each page. Defaults to `30`.
|
1111 |
|
1112 |
-
|
1113 |
|
1114 |
The attribute by which the results are sorted. Available options:
|
1115 |
|
1116 |
- `"create_time"` (default)
|
1117 |
- `"update_time"`
|
1118 |
|
1119 |
-
|
1120 |
|
1121 |
Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `True`.
|
1122 |
|
1123 |
-
|
1124 |
|
1125 |
The ID of the chat assistant to retrieve. Defaults to `None`.
|
1126 |
|
1127 |
-
|
1128 |
|
1129 |
The name of the chat assistant to retrieve. Defaults to `None`.
|
1130 |
|
1131 |
-
|
1132 |
|
1133 |
- Success: A list of `Chat` objects.
|
1134 |
- Failure: `Exception`.
|
1135 |
|
1136 |
-
|
1137 |
|
1138 |
```python
|
1139 |
from ragflow_sdk import RAGFlow
|
@@ -1145,13 +1139,11 @@ for assistant in rag_object.list_chats():
|
|
1145 |
|
1146 |
---
|
1147 |
|
1148 |
-
|
1149 |
-
Chat Session APIs
|
1150 |
-
:::
|
1151 |
|
1152 |
---
|
1153 |
|
1154 |
-
|
1155 |
|
1156 |
```python
|
1157 |
Chat.create_session(name: str = "New session") -> Session
|
@@ -1159,22 +1151,22 @@ Chat.create_session(name: str = "New session") -> Session
|
|
1159 |
|
1160 |
Creates a session with the current chat assistant.
|
1161 |
|
1162 |
-
|
1163 |
|
1164 |
-
|
1165 |
|
1166 |
The name of the chat session to create.
|
1167 |
|
1168 |
-
|
1169 |
|
1170 |
- Success: A `Session` object containing the following attributes:
|
1171 |
- `id`: `str` The auto-generated unique identifier of the created session.
|
1172 |
- `name`: `str` The name of the created session.
|
1173 |
-
- `message`: `list[Message]` The
|
1174 |
- `chat_id`: `str` The ID of the associated chat assistant.
|
1175 |
- Failure: `Exception`
|
1176 |
|
1177 |
-
|
1178 |
|
1179 |
```python
|
1180 |
from ragflow_sdk import RAGFlow
|
@@ -1187,7 +1179,7 @@ session = assistant.create_session()
|
|
1187 |
|
1188 |
---
|
1189 |
|
1190 |
-
|
1191 |
|
1192 |
```python
|
1193 |
Session.update(update_message: dict)
|
@@ -1195,20 +1187,20 @@ Session.update(update_message: dict)
|
|
1195 |
|
1196 |
Updates the current session of the current chat assistant.
|
1197 |
|
1198 |
-
|
1199 |
|
1200 |
-
|
1201 |
|
1202 |
A dictionary representing the attributes to update, with only one key:
|
1203 |
|
1204 |
- `"name"`: `str` The revised name of the session.
|
1205 |
|
1206 |
-
|
1207 |
|
1208 |
- Success: No value is returned.
|
1209 |
- Failure: `Exception`
|
1210 |
|
1211 |
-
|
1212 |
|
1213 |
```python
|
1214 |
from ragflow_sdk import RAGFlow
|
@@ -1222,7 +1214,7 @@ session.update({"name": "updated_name"})
|
|
1222 |
|
1223 |
---
|
1224 |
|
1225 |
-
|
1226 |
|
1227 |
```python
|
1228 |
Chat.list_sessions(
|
@@ -1237,41 +1229,41 @@ Chat.list_sessions(
|
|
1237 |
|
1238 |
Lists sessions associated with the current chat assistant.
|
1239 |
|
1240 |
-
|
1241 |
|
1242 |
-
|
1243 |
|
1244 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1245 |
|
1246 |
-
|
1247 |
|
1248 |
The number of sessions on each page. Defaults to `30`.
|
1249 |
|
1250 |
-
|
1251 |
|
1252 |
The field by which sessions should be sorted. Available options:
|
1253 |
|
1254 |
- `"create_time"` (default)
|
1255 |
- `"update_time"`
|
1256 |
|
1257 |
-
|
1258 |
|
1259 |
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`.
|
1260 |
|
1261 |
-
|
1262 |
|
1263 |
The ID of the chat session to retrieve. Defaults to `None`.
|
1264 |
|
1265 |
-
|
1266 |
|
1267 |
The name of the chat session to retrieve. Defaults to `None`.
|
1268 |
|
1269 |
-
|
1270 |
|
1271 |
- Success: A list of `Session` objects associated with the current chat assistant.
|
1272 |
- Failure: `Exception`.
|
1273 |
|
1274 |
-
|
1275 |
|
1276 |
```python
|
1277 |
from ragflow_sdk import RAGFlow
|
@@ -1285,7 +1277,7 @@ for session in assistant.list_sessions():
|
|
1285 |
|
1286 |
---
|
1287 |
|
1288 |
-
|
1289 |
|
1290 |
```python
|
1291 |
Chat.delete_sessions(ids:list[str] = None)
|
@@ -1293,18 +1285,18 @@ Chat.delete_sessions(ids:list[str] = None)
|
|
1293 |
|
1294 |
Deletes sessions of the current chat assistant by ID.
|
1295 |
|
1296 |
-
|
1297 |
|
1298 |
-
|
1299 |
|
1300 |
The IDs of the sessions to delete. Defaults to `None`. If it is not specified, all sessions associated with the current chat assistant will be deleted.
|
1301 |
|
1302 |
-
|
1303 |
|
1304 |
- Success: No value is returned.
|
1305 |
- Failure: `Exception`
|
1306 |
|
1307 |
-
|
1308 |
|
1309 |
```python
|
1310 |
from ragflow_sdk import RAGFlow
|
@@ -1317,7 +1309,7 @@ assistant.delete_sessions(ids=["id_1","id_2"])
|
|
1317 |
|
1318 |
---
|
1319 |
|
1320 |
-
|
1321 |
|
1322 |
```python
|
1323 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
@@ -1329,35 +1321,35 @@ Asks a specified chat assistant a question to start an AI-powered conversation.
|
|
1329 |
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
|
1330 |
:::
|
1331 |
|
1332 |
-
|
1333 |
|
1334 |
-
|
1335 |
|
1336 |
The question to start an AI-powered conversation.
|
1337 |
|
1338 |
-
|
1339 |
|
1340 |
Indicates whether to output responses in a streaming way:
|
1341 |
|
1342 |
- `True`: Enable streaming (default).
|
1343 |
- `False`: Disable streaming.
|
1344 |
|
1345 |
-
|
1346 |
|
1347 |
-
- A `Message` object containing the response to the question if `stream` is set to `False
|
1348 |
- An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True`
|
1349 |
|
1350 |
The following shows the attributes of a `Message` object:
|
1351 |
|
1352 |
-
|
1353 |
|
1354 |
The auto-generated message ID.
|
1355 |
|
1356 |
-
|
1357 |
|
1358 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1359 |
|
1360 |
-
|
1361 |
|
1362 |
A list of `Chunk` objects representing references to the message, each containing the following attributes:
|
1363 |
|
@@ -1382,7 +1374,7 @@ A list of `Chunk` objects representing references to the message, each containin
|
|
1382 |
- `term_similarity` `float`
|
1383 |
A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords.
|
1384 |
|
1385 |
-
|
1386 |
|
1387 |
```python
|
1388 |
from ragflow_sdk import RAGFlow
|
@@ -1407,15 +1399,15 @@ while True:
|
|
1407 |
|
1408 |
---
|
1409 |
|
1410 |
-
|
1411 |
-
|
1412 |
```python
|
1413 |
Agent.create_session(id,rag) -> Session
|
1414 |
```
|
1415 |
|
1416 |
-
Creates a
|
1417 |
|
1418 |
-
|
1419 |
|
1420 |
- Success: A `Session` object containing the following attributes:
|
1421 |
- `id`: `str` The auto-generated unique identifier of the created session.
|
@@ -1423,7 +1415,7 @@ Creates a session with the current agent.
|
|
1423 |
- `agent_id`: `str` The ID of the associated agent assistant.
|
1424 |
- Failure: `Exception`
|
1425 |
|
1426 |
-
|
1427 |
|
1428 |
```python
|
1429 |
from ragflow_sdk import RAGFlow
|
@@ -1435,7 +1427,7 @@ session = create_session(AGENT_ID,rag_object)
|
|
1435 |
|
1436 |
---
|
1437 |
|
1438 |
-
|
1439 |
|
1440 |
```python
|
1441 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
@@ -1447,35 +1439,35 @@ Asks a specified agent a question to start an AI-powered conversation.
|
|
1447 |
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
|
1448 |
:::
|
1449 |
|
1450 |
-
|
1451 |
|
1452 |
-
|
1453 |
|
1454 |
The question to start an AI-powered conversation.
|
1455 |
|
1456 |
-
|
1457 |
|
1458 |
Indicates whether to output responses in a streaming way:
|
1459 |
|
1460 |
- `True`: Enable streaming (default).
|
1461 |
- `False`: Disable streaming.
|
1462 |
|
1463 |
-
|
1464 |
|
1465 |
- A `Message` object containing the response to the question if `stream` is set to `False`
|
1466 |
- An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True`
|
1467 |
|
1468 |
The following shows the attributes of a `Message` object:
|
1469 |
|
1470 |
-
|
1471 |
|
1472 |
The auto-generated message ID.
|
1473 |
|
1474 |
-
|
1475 |
|
1476 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1477 |
|
1478 |
-
|
1479 |
|
1480 |
A list of `Chunk` objects representing references to the message, each containing the following attributes:
|
1481 |
|
@@ -1500,7 +1492,7 @@ A list of `Chunk` objects representing references to the message, each containin
|
|
1500 |
- `term_similarity` `float`
|
1501 |
A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords.
|
1502 |
|
1503 |
-
|
1504 |
|
1505 |
```python
|
1506 |
from ragflow_sdk import RAGFlow,Agent
|
@@ -1521,9 +1513,10 @@ while True:
|
|
1521 |
print(ans.content[len(cont):], end='', flush=True)
|
1522 |
cont = ans.content
|
1523 |
```
|
|
|
1524 |
---
|
1525 |
|
1526 |
-
|
1527 |
|
1528 |
```python
|
1529 |
Agent.list_sessions(
|
@@ -1539,38 +1532,37 @@ Agent.list_sessions(
|
|
1539 |
|
1540 |
Lists sessions associated with the current agent.
|
1541 |
|
1542 |
-
|
1543 |
|
1544 |
-
|
1545 |
|
1546 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1547 |
|
1548 |
-
|
1549 |
|
1550 |
The number of sessions on each page. Defaults to `30`.
|
1551 |
|
1552 |
-
|
1553 |
|
1554 |
The field by which sessions should be sorted. Available options:
|
1555 |
|
1556 |
- `"create_time"`
|
1557 |
- `"update_time"`(default)
|
1558 |
|
1559 |
-
|
1560 |
|
1561 |
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`.
|
1562 |
|
1563 |
-
|
1564 |
|
1565 |
The ID of the agent session to retrieve. Defaults to `None`.
|
1566 |
|
1567 |
-
|
1568 |
-
### Returns
|
1569 |
|
1570 |
- Success: A list of `Session` objects associated with the current agent.
|
1571 |
- Failure: `Exception`.
|
1572 |
|
1573 |
-
|
1574 |
|
1575 |
```python
|
1576 |
from ragflow_sdk import RAGFlow
|
@@ -1583,7 +1575,8 @@ for session in sessions:
|
|
1583 |
```
|
1584 |
|
1585 |
---
|
1586 |
-
|
|
|
1587 |
|
1588 |
```python
|
1589 |
RAGFlow.list_agents(
|
@@ -1598,45 +1591,47 @@ RAGFlow.list_agents(
|
|
1598 |
|
1599 |
Lists agents.
|
1600 |
|
1601 |
-
|
1602 |
|
1603 |
-
|
1604 |
|
1605 |
Specifies the page on which the agents will be displayed. Defaults to `1`.
|
1606 |
|
1607 |
-
|
1608 |
|
1609 |
The number of agents on each page. Defaults to `30`.
|
1610 |
|
1611 |
-
|
1612 |
|
1613 |
The attribute by which the results are sorted. Available options:
|
1614 |
|
1615 |
- `"create_time"` (default)
|
1616 |
- `"update_time"`
|
1617 |
|
1618 |
-
|
1619 |
|
1620 |
Indicates whether the retrieved agents should be sorted in descending order. Defaults to `True`.
|
1621 |
|
1622 |
-
|
1623 |
|
1624 |
The ID of the agent to retrieve. Defaults to `None`.
|
1625 |
|
1626 |
-
|
1627 |
|
1628 |
The name of the agent to retrieve. Defaults to `None`.
|
1629 |
|
1630 |
-
|
1631 |
|
1632 |
- Success: A list of `Agent` objects.
|
1633 |
- Failure: `Exception`.
|
1634 |
|
1635 |
-
|
1636 |
|
1637 |
```python
|
1638 |
from ragflow_sdk import RAGFlow
|
1639 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
1640 |
for agent in rag_object.list_agents():
|
1641 |
print(agent)
|
1642 |
-
```
|
|
|
|
|
|
7 |
|
8 |
A complete reference for RAGFlow's Python APIs. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](https://ragflow.io/docs/dev/acquire_ragflow_api_key).
|
9 |
|
10 |
+
:::tip NOTE
|
11 |
+
Run the following command to download the Python SDK:
|
12 |
|
13 |
+
```bash
|
14 |
+
pip install ragflow-sdk
|
15 |
+
```
|
16 |
:::
|
17 |
|
18 |
---
|
|
|
19 |
|
20 |
+
## DATASET MANAGEMENT
|
21 |
|
22 |
+
---
|
|
|
|
|
23 |
|
24 |
+
### Create dataset
|
25 |
|
26 |
```python
|
27 |
RAGFlow.create_dataset(
|
|
|
38 |
|
39 |
Creates a dataset.
|
40 |
|
41 |
+
#### Parameters
|
42 |
|
43 |
+
##### name: `str`, *Required*
|
44 |
|
45 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
46 |
|
|
|
52 |
- Maximum 65,535 characters.
|
53 |
- Case-insensitive.
|
54 |
|
55 |
+
##### avatar: `str`
|
56 |
|
57 |
Base64 encoding of the avatar. Defaults to `""`
|
58 |
|
59 |
+
##### description: `str`
|
60 |
|
61 |
A brief description of the dataset to create. Defaults to `""`.
|
62 |
|
63 |
+
##### language: `str`
|
64 |
|
65 |
The language setting of the dataset to create. Available options:
|
66 |
|
67 |
- `"English"` (default)
|
68 |
- `"Chinese"`
|
69 |
|
70 |
+
##### permission
|
71 |
|
72 |
Specifies who can access the dataset to create. Available options:
|
73 |
|
74 |
- `"me"`: (Default) Only you can manage the dataset.
|
75 |
- `"team"`: All team members can manage the dataset.
|
76 |
|
77 |
+
##### chunk_method, `str`
|
78 |
|
79 |
The chunking method of the dataset to create. Available options:
|
80 |
|
|
|
92 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
93 |
- `"email"`: Email
|
94 |
|
95 |
+
##### parser_config
|
96 |
|
97 |
The parser configuration of the dataset. A `ParserConfig` object's attributes vary based on the selected `chunk_method`:
|
98 |
|
|
|
121 |
- `chunk_method`=`"email"`:
|
122 |
`None`
|
123 |
|
124 |
+
#### Returns
|
125 |
|
126 |
- Success: A `dataset` object.
|
127 |
- Failure: `Exception`
|
128 |
|
129 |
+
#### Examples
|
130 |
|
131 |
```python
|
132 |
from ragflow_sdk import RAGFlow
|
|
|
137 |
|
138 |
---
|
139 |
|
140 |
+
### Delete datasets
|
141 |
|
142 |
```python
|
143 |
RAGFlow.delete_datasets(ids: list[str] = None)
|
|
|
145 |
|
146 |
Deletes datasets by ID.
|
147 |
|
148 |
+
#### Parameters
|
149 |
|
150 |
+
##### ids: `list[str]`, *Required*
|
151 |
|
152 |
The IDs of the datasets to delete. Defaults to `None`. If it is not specified, all datasets will be deleted.
|
153 |
|
154 |
+
#### Returns
|
155 |
|
156 |
- Success: No value is returned.
|
157 |
- Failure: `Exception`
|
158 |
|
159 |
+
#### Examples
|
160 |
|
161 |
```python
|
162 |
rag_object.delete_datasets(ids=["id_1","id_2"])
|
|
|
164 |
|
165 |
---
|
166 |
|
167 |
+
### List datasets
|
168 |
|
169 |
```python
|
170 |
RAGFlow.list_datasets(
|
|
|
179 |
|
180 |
Lists datasets.
|
181 |
|
182 |
+
#### Parameters
|
183 |
|
184 |
+
##### page: `int`
|
185 |
|
186 |
Specifies the page on which the datasets will be displayed. Defaults to `1`.
|
187 |
|
188 |
+
##### page_size: `int`
|
189 |
|
190 |
The number of datasets on each page. Defaults to `30`.
|
191 |
|
192 |
+
##### orderby: `str`
|
193 |
|
194 |
The field by which datasets should be sorted. Available options:
|
195 |
|
196 |
- `"create_time"` (default)
|
197 |
- `"update_time"`
|
198 |
|
199 |
+
##### desc: `bool`
|
200 |
|
201 |
Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `True`.
|
202 |
|
203 |
+
##### id: `str`
|
204 |
|
205 |
The ID of the dataset to retrieve. Defaults to `None`.
|
206 |
|
207 |
+
##### name: `str`
|
208 |
|
209 |
The name of the dataset to retrieve. Defaults to `None`.
|
210 |
|
211 |
+
#### Returns
|
212 |
|
213 |
- Success: A list of `DataSet` objects.
|
214 |
- Failure: `Exception`.
|
215 |
|
216 |
+
#### Examples
|
217 |
|
218 |
+
##### List all datasets
|
219 |
|
220 |
```python
|
221 |
for dataset in rag_object.list_datasets():
|
222 |
print(dataset)
|
223 |
```
|
224 |
|
225 |
+
##### Retrieve a dataset by ID
|
226 |
|
227 |
```python
|
228 |
dataset = rag_object.list_datasets(id = "id_1")
|
|
|
231 |
|
232 |
---
|
233 |
|
234 |
+
### Update dataset
|
235 |
|
236 |
```python
|
237 |
DataSet.update(update_message: dict)
|
|
|
239 |
|
240 |
Updates configurations for the current dataset.
|
241 |
|
242 |
+
#### Parameters
|
243 |
|
244 |
+
##### update_message: `dict[str, str|int]`, *Required*
|
245 |
|
246 |
A dictionary representing the attributes to update, with the following keys:
|
247 |
|
|
|
263 |
- `"knowledge_graph"`: Knowledge Graph
|
264 |
Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
|
265 |
|
266 |
+
#### Returns
|
267 |
|
268 |
- Success: No value is returned.
|
269 |
- Failure: `Exception`
|
270 |
|
271 |
+
#### Examples
|
272 |
|
273 |
```python
|
274 |
from ragflow_sdk import RAGFlow
|
|
|
280 |
|
281 |
---
|
282 |
|
283 |
+
## FILE MANAGEMENT WITHIN DATASET
|
|
|
|
|
284 |
|
285 |
---
|
286 |
|
287 |
+
### Upload documents
|
288 |
|
289 |
```python
|
290 |
DataSet.upload_documents(document_list: list[dict])
|
|
|
292 |
|
293 |
Uploads documents to the current dataset.
|
294 |
|
295 |
+
#### Parameters
|
296 |
|
297 |
+
##### document_list: `list[dict]`, *Required*
|
298 |
|
299 |
A list of dictionaries representing the documents to upload, each containing the following keys:
|
300 |
|
301 |
- `"display_name"`: (Optional) The file name to display in the dataset.
|
302 |
- `"blob"`: (Optional) The binary content of the file to upload.
|
303 |
|
304 |
+
#### Returns
|
305 |
|
306 |
- Success: No value is returned.
|
307 |
- Failure: `Exception`
|
308 |
|
309 |
+
#### Examples
|
310 |
|
311 |
```python
|
312 |
dataset = rag_object.create_dataset(name="kb_name")
|
|
|
315 |
|
316 |
---
|
317 |
|
318 |
+
### Update document
|
319 |
|
320 |
```python
|
321 |
Document.update(update_message:dict)
|
|
|
323 |
|
324 |
Updates configurations for the current document.
|
325 |
|
326 |
+
#### Parameters
|
327 |
|
328 |
+
##### update_message: `dict[str, str|dict[]]`, *Required*
|
329 |
|
330 |
A dictionary representing the attributes to update, with the following keys:
|
331 |
|
|
|
370 |
- `chunk_method`=`"email"`:
|
371 |
`None`
|
372 |
|
373 |
+
#### Returns
|
374 |
|
375 |
- Success: No value is returned.
|
376 |
- Failure: `Exception`
|
377 |
|
378 |
+
#### Examples
|
379 |
|
380 |
```python
|
381 |
from ragflow_sdk import RAGFlow
|
|
|
390 |
|
391 |
---
|
392 |
|
393 |
+
### Download document
|
394 |
|
395 |
```python
|
396 |
Document.download() -> bytes
|
|
|
398 |
|
399 |
Downloads the current document.
|
400 |
|
401 |
+
#### Returns
|
402 |
|
403 |
The downloaded document in bytes.
|
404 |
|
405 |
+
#### Examples
|
406 |
|
407 |
```python
|
408 |
from ragflow_sdk import RAGFlow
|
|
|
418 |
|
419 |
---
|
420 |
|
421 |
+
### List documents
|
422 |
|
423 |
```python
|
424 |
Dataset.list_documents(id:str =None, keywords: str=None, page: int=1, page_size:int = 30, order_by:str = "create_time", desc: bool = True) -> list[Document]
|
|
|
426 |
|
427 |
Lists documents in the current dataset.
|
428 |
|
429 |
+
#### Parameters
|
430 |
|
431 |
+
##### id: `str`
|
432 |
|
433 |
The ID of the document to retrieve. Defaults to `None`.
|
434 |
|
435 |
+
##### keywords: `str`
|
436 |
|
437 |
The keywords used to match document titles. Defaults to `None`.
|
438 |
|
439 |
+
##### page: `int`
|
440 |
|
441 |
Specifies the page on which the documents will be displayed. Defaults to `1`.
|
442 |
|
443 |
+
##### page_size: `int`
|
444 |
|
445 |
The maximum number of documents on each page. Defaults to `30`.
|
446 |
|
447 |
+
##### orderby: `str`
|
448 |
|
449 |
The field by which documents should be sorted. Available options:
|
450 |
|
451 |
- `"create_time"` (default)
|
452 |
- `"update_time"`
|
453 |
|
454 |
+
##### desc: `bool`
|
455 |
|
456 |
Indicates whether the retrieved documents should be sorted in descending order. Defaults to `True`.
|
457 |
|
458 |
+
#### Returns
|
459 |
|
460 |
- Success: A list of `Document` objects.
|
461 |
- Failure: `Exception`.
|
|
|
510 |
- `chunk_method`=`"email"`:
|
511 |
`None`
|
512 |
|
513 |
+
#### Examples
|
514 |
|
515 |
```python
|
516 |
from ragflow_sdk import RAGFlow
|
|
|
527 |
|
528 |
---
|
529 |
|
530 |
+
### Delete documents
|
531 |
|
532 |
```python
|
533 |
DataSet.delete_documents(ids: list[str] = None)
|
|
|
535 |
|
536 |
Deletes documents by ID.
|
537 |
|
538 |
+
#### Parameters
|
539 |
|
540 |
+
##### ids: `list[list]`
|
541 |
|
542 |
The IDs of the documents to delete. Defaults to `None`. If it is not specified, all documents in the dataset will be deleted.
|
543 |
|
544 |
+
#### Returns
|
545 |
|
546 |
- Success: No value is returned.
|
547 |
- Failure: `Exception`
|
548 |
|
549 |
+
#### Examples
|
550 |
|
551 |
```python
|
552 |
from ragflow_sdk import RAGFlow
|
|
|
559 |
|
560 |
---
|
561 |
|
562 |
+
### Parse documents
|
563 |
|
564 |
```python
|
565 |
DataSet.async_parse_documents(document_ids:list[str]) -> None
|
|
|
567 |
|
568 |
Parses documents in the current dataset.
|
569 |
|
570 |
+
#### Parameters
|
571 |
|
572 |
+
##### document_ids: `list[str]`, *Required*
|
573 |
|
574 |
The IDs of the documents to parse.
|
575 |
|
576 |
+
#### Returns
|
577 |
|
578 |
- Success: No value is returned.
|
579 |
- Failure: `Exception`
|
580 |
|
581 |
+
#### Examples
|
582 |
|
583 |
```python
|
584 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
|
|
599 |
|
600 |
---
|
601 |
|
602 |
+
### Stop parsing documents
|
603 |
|
604 |
```python
|
605 |
DataSet.async_cancel_parse_documents(document_ids:list[str])-> None
|
|
|
607 |
|
608 |
Stops parsing specified documents.
|
609 |
|
610 |
+
#### Parameters
|
611 |
|
612 |
+
##### document_ids: `list[str]`, *Required*
|
613 |
|
614 |
The IDs of the documents for which parsing should be stopped.
|
615 |
|
616 |
+
#### Returns
|
617 |
|
618 |
- Success: No value is returned.
|
619 |
- Failure: `Exception`
|
620 |
|
621 |
+
#### Examples
|
622 |
|
623 |
```python
|
624 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
|
|
641 |
|
642 |
---
|
643 |
|
644 |
+
### Add chunk
|
645 |
|
646 |
```python
|
647 |
Document.add_chunk(content:str, important_keywords:list[str] = []) -> Chunk
|
|
|
649 |
|
650 |
Adds a chunk to the current document.
|
651 |
|
652 |
+
#### Parameters
|
653 |
|
654 |
+
##### content: `str`, *Required*
|
655 |
|
656 |
The text content of the chunk.
|
657 |
|
658 |
+
##### important_keywords: `list[str]`
|
659 |
|
660 |
The key terms or phrases to tag with the chunk.
|
661 |
|
662 |
+
#### Returns
|
663 |
|
664 |
- Success: A `Chunk` object.
|
665 |
- Failure: `Exception`.
|
|
|
678 |
- `False`: Unavailable
|
679 |
- `True`: Available (default)
|
680 |
|
681 |
+
#### Examples
|
|
|
682 |
|
683 |
```python
|
684 |
from ragflow_sdk import RAGFlow
|
|
|
693 |
|
694 |
---
|
695 |
|
696 |
+
### List chunks
|
697 |
|
698 |
```python
|
699 |
Document.list_chunks(keywords: str = None, page: int = 1, page_size: int = 30, id : str = None) -> list[Chunk]
|
|
|
701 |
|
702 |
Lists chunks in the current document.
|
703 |
|
704 |
+
#### Parameters
|
705 |
|
706 |
+
##### keywords: `str`
|
707 |
|
708 |
The keywords used to match chunk content. Defaults to `None`
|
709 |
|
710 |
+
##### page: `int`
|
711 |
|
712 |
Specifies the page on which the chunks will be displayed. Defaults to `1`.
|
713 |
|
714 |
+
##### page_size: `int`
|
715 |
|
716 |
The maximum number of chunks on each page. Defaults to `30`.
|
717 |
|
718 |
+
##### id: `str`
|
719 |
|
720 |
The ID of the chunk to retrieve. Default: `None`
|
721 |
|
722 |
+
#### Returns
|
723 |
|
724 |
- Success: A list of `Chunk` objects.
|
725 |
- Failure: `Exception`.
|
726 |
|
727 |
+
#### Examples
|
728 |
|
729 |
```python
|
730 |
from ragflow_sdk import RAGFlow
|
|
|
739 |
|
740 |
---
|
741 |
|
742 |
+
### Delete chunks
|
743 |
|
744 |
```python
|
745 |
Document.delete_chunks(chunk_ids: list[str])
|
|
|
747 |
|
748 |
Deletes chunks by ID.
|
749 |
|
750 |
+
#### Parameters
|
751 |
|
752 |
+
##### chunk_ids: `list[str]`
|
753 |
|
754 |
The IDs of the chunks to delete. Defaults to `None`. If it is not specified, all chunks of the current document will be deleted.
|
755 |
|
756 |
+
#### Returns
|
757 |
|
758 |
- Success: No value is returned.
|
759 |
- Failure: `Exception`
|
760 |
|
761 |
+
#### Examples
|
762 |
|
763 |
```python
|
764 |
from ragflow_sdk import RAGFlow
|
|
|
774 |
|
775 |
---
|
776 |
|
777 |
+
### Update chunk
|
778 |
|
779 |
```python
|
780 |
Chunk.update(update_message: dict)
|
|
|
782 |
|
783 |
Updates content or configurations for the current chunk.
|
784 |
|
785 |
+
#### Parameters
|
786 |
|
787 |
+
##### update_message: `dict[str, str|list[str]|int]` *Required*
|
788 |
|
789 |
A dictionary representing the attributes to update, with the following keys:
|
790 |
|
|
|
794 |
- `False`: Unavailable
|
795 |
- `True`: Available (default)
|
796 |
|
797 |
+
#### Returns
|
798 |
|
799 |
- Success: No value is returned.
|
800 |
- Failure: `Exception`
|
801 |
|
802 |
+
#### Examples
|
803 |
|
804 |
```python
|
805 |
from ragflow_sdk import RAGFlow
|
|
|
815 |
|
816 |
---
|
817 |
|
818 |
+
### Retrieve chunks
|
819 |
|
820 |
```python
|
821 |
RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, page:int=1, page_size:int=30, 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]
|
|
|
823 |
|
824 |
Retrieves chunks from specified datasets.
|
825 |
|
826 |
+
#### Parameters
|
827 |
|
828 |
+
##### question: `str`, *Required*
|
829 |
|
830 |
The user query or query keywords. Defaults to `""`.
|
831 |
|
832 |
+
##### dataset_ids: `list[str]`, *Required*
|
833 |
|
834 |
The IDs of the datasets to search. Defaults to `None`. If you do not set this argument, ensure that you set `document_ids`.
|
835 |
|
836 |
+
##### document_ids: `list[str]`
|
837 |
|
838 |
The IDs of the documents to search. Defaults to `None`. You must ensure all selected documents use the same embedding model. Otherwise, an error will occur. If you do not set this argument, ensure that you set `dataset_ids`.
|
839 |
|
840 |
+
##### page: `int`
|
841 |
|
842 |
The starting index for the documents to retrieve. Defaults to `1`.
|
843 |
|
844 |
+
##### page_size: `int`
|
845 |
|
846 |
The maximum number of chunks to retrieve. Defaults to `30`.
|
847 |
|
848 |
+
##### Similarity_threshold: `float`
|
849 |
|
850 |
The minimum similarity score. Defaults to `0.2`.
|
851 |
|
852 |
+
##### vector_similarity_weight: `float`
|
853 |
|
854 |
The weight of vector cosine similarity. Defaults to `0.3`. If x represents the vector cosine similarity, then (1 - x) is the term similarity weight.
|
855 |
|
856 |
+
##### top_k: `int`
|
857 |
|
858 |
The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
|
859 |
|
860 |
+
##### rerank_id: `str`
|
861 |
|
862 |
The ID of the rerank model. Defaults to `None`.
|
863 |
|
864 |
+
##### keyword: `bool`
|
865 |
|
866 |
Indicates whether to enable keyword-based matching:
|
867 |
|
868 |
- `True`: Enable keyword-based matching.
|
869 |
- `False`: Disable keyword-based matching (default).
|
870 |
|
871 |
+
##### highlight: `bool`
|
872 |
|
873 |
Specifies whether to enable highlighting of matched terms in the results:
|
874 |
|
875 |
- `True`: Enable highlighting of matched terms.
|
876 |
- `False`: Disable highlighting of matched terms (default).
|
877 |
|
878 |
+
#### Returns
|
879 |
|
880 |
- Success: A list of `Chunk` objects representing the document chunks.
|
881 |
- Failure: `Exception`
|
882 |
|
883 |
+
#### Examples
|
884 |
|
885 |
```python
|
886 |
from ragflow_sdk import RAGFlow
|
|
|
905 |
|
906 |
---
|
907 |
|
908 |
+
## CHAT ASSISTANT MANAGEMENT
|
|
|
|
|
909 |
|
910 |
---
|
911 |
|
912 |
+
### Create chat assistant
|
913 |
|
914 |
```python
|
915 |
RAGFlow.create_chat(
|
|
|
923 |
|
924 |
Creates a chat assistant.
|
925 |
|
926 |
+
#### Parameters
|
927 |
|
928 |
+
##### name: `str`, *Required*
|
929 |
|
930 |
The name of the chat assistant.
|
931 |
|
932 |
+
##### avatar: `str`
|
933 |
|
934 |
Base64 encoding of the avatar. Defaults to `""`.
|
935 |
|
936 |
+
##### dataset_ids: `list[str]`
|
937 |
|
938 |
The IDs of the associated datasets. Defaults to `[""]`.
|
939 |
|
940 |
+
##### llm: `Chat.LLM`
|
941 |
|
942 |
The LLM settings for the chat assistant to create. Defaults to `None`. When the value is `None`, a dictionary with the following values will be generated as the default. An `LLM` object contains the following attributes:
|
943 |
|
|
|
954 |
- `max_token`: `int`
|
955 |
The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
|
956 |
|
957 |
+
##### prompt: `Chat.Prompt`
|
958 |
|
959 |
Instructions for the LLM to follow. A `Prompt` object contains the following attributes:
|
960 |
|
|
|
971 |
- `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`.
|
972 |
- `prompt`: `str` The prompt content.
|
973 |
|
974 |
+
#### Returns
|
975 |
|
976 |
- Success: A `Chat` object representing the chat assistant.
|
977 |
- Failure: `Exception`
|
978 |
|
979 |
+
#### Examples
|
980 |
|
981 |
```python
|
982 |
from ragflow_sdk import RAGFlow
|
|
|
991 |
|
992 |
---
|
993 |
|
994 |
+
### Update chat assistant
|
995 |
|
996 |
```python
|
997 |
Chat.update(update_message: dict)
|
|
|
999 |
|
1000 |
Updates configurations for the current chat assistant.
|
1001 |
|
1002 |
+
#### Parameters
|
1003 |
|
1004 |
+
##### update_message: `dict[str, str|list[str]|dict[]]`, *Required*
|
1005 |
|
1006 |
A dictionary representing the attributes to update, with the following keys:
|
1007 |
|
|
|
1029 |
- `"show_quote`: `bool` Indicates whether the source of text should be displayed Defaults to `True`.
|
1030 |
- `"prompt"`: `str` The prompt content.
|
1031 |
|
1032 |
+
#### Returns
|
1033 |
|
1034 |
- Success: No value is returned.
|
1035 |
- Failure: `Exception`
|
1036 |
|
1037 |
+
#### Examples
|
1038 |
|
1039 |
```python
|
1040 |
from ragflow_sdk import RAGFlow
|
|
|
1048 |
|
1049 |
---
|
1050 |
|
1051 |
+
### Delete chat assistants
|
1052 |
|
1053 |
```python
|
1054 |
RAGFlow.delete_chats(ids: list[str] = None)
|
|
|
1056 |
|
1057 |
Deletes chat assistants by ID.
|
1058 |
|
1059 |
+
#### Parameters
|
1060 |
|
1061 |
+
##### ids: `list[str]`
|
1062 |
|
1063 |
The IDs of the chat assistants to delete. Defaults to `None`. If it is empty or not specified, all chat assistants in the system will be deleted.
|
1064 |
|
1065 |
+
#### Returns
|
1066 |
|
1067 |
- Success: No value is returned.
|
1068 |
- Failure: `Exception`
|
1069 |
|
1070 |
+
#### Examples
|
1071 |
|
1072 |
```python
|
1073 |
from ragflow_sdk import RAGFlow
|
|
|
1078 |
|
1079 |
---
|
1080 |
|
1081 |
+
### List chat assistants
|
1082 |
|
1083 |
```python
|
1084 |
RAGFlow.list_chats(
|
|
|
1093 |
|
1094 |
Lists chat assistants.
|
1095 |
|
1096 |
+
#### Parameters
|
1097 |
|
1098 |
+
##### page: `int`
|
1099 |
|
1100 |
Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
|
1101 |
|
1102 |
+
##### page_size: `int`
|
1103 |
|
1104 |
The number of chat assistants on each page. Defaults to `30`.
|
1105 |
|
1106 |
+
##### orderby: `str`
|
1107 |
|
1108 |
The attribute by which the results are sorted. Available options:
|
1109 |
|
1110 |
- `"create_time"` (default)
|
1111 |
- `"update_time"`
|
1112 |
|
1113 |
+
##### desc: `bool`
|
1114 |
|
1115 |
Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `True`.
|
1116 |
|
1117 |
+
##### id: `str`
|
1118 |
|
1119 |
The ID of the chat assistant to retrieve. Defaults to `None`.
|
1120 |
|
1121 |
+
##### name: `str`
|
1122 |
|
1123 |
The name of the chat assistant to retrieve. Defaults to `None`.
|
1124 |
|
1125 |
+
#### Returns
|
1126 |
|
1127 |
- Success: A list of `Chat` objects.
|
1128 |
- Failure: `Exception`.
|
1129 |
|
1130 |
+
#### Examples
|
1131 |
|
1132 |
```python
|
1133 |
from ragflow_sdk import RAGFlow
|
|
|
1139 |
|
1140 |
---
|
1141 |
|
1142 |
+
## CHAT SESSIONS
|
|
|
|
|
1143 |
|
1144 |
---
|
1145 |
|
1146 |
+
### Create session with chat assistant
|
1147 |
|
1148 |
```python
|
1149 |
Chat.create_session(name: str = "New session") -> Session
|
|
|
1151 |
|
1152 |
Creates a session with the current chat assistant.
|
1153 |
|
1154 |
+
#### Parameters
|
1155 |
|
1156 |
+
##### name: `str`
|
1157 |
|
1158 |
The name of the chat session to create.
|
1159 |
|
1160 |
+
#### Returns
|
1161 |
|
1162 |
- Success: A `Session` object containing the following attributes:
|
1163 |
- `id`: `str` The auto-generated unique identifier of the created session.
|
1164 |
- `name`: `str` The name of the created session.
|
1165 |
+
- `message`: `list[Message]` The opening message of the created session. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]`
|
1166 |
- `chat_id`: `str` The ID of the associated chat assistant.
|
1167 |
- Failure: `Exception`
|
1168 |
|
1169 |
+
#### Examples
|
1170 |
|
1171 |
```python
|
1172 |
from ragflow_sdk import RAGFlow
|
|
|
1179 |
|
1180 |
---
|
1181 |
|
1182 |
+
### Update chat assistant's session
|
1183 |
|
1184 |
```python
|
1185 |
Session.update(update_message: dict)
|
|
|
1187 |
|
1188 |
Updates the current session of the current chat assistant.
|
1189 |
|
1190 |
+
#### Parameters
|
1191 |
|
1192 |
+
##### update_message: `dict[str, Any]`, *Required*
|
1193 |
|
1194 |
A dictionary representing the attributes to update, with only one key:
|
1195 |
|
1196 |
- `"name"`: `str` The revised name of the session.
|
1197 |
|
1198 |
+
#### Returns
|
1199 |
|
1200 |
- Success: No value is returned.
|
1201 |
- Failure: `Exception`
|
1202 |
|
1203 |
+
#### Examples
|
1204 |
|
1205 |
```python
|
1206 |
from ragflow_sdk import RAGFlow
|
|
|
1214 |
|
1215 |
---
|
1216 |
|
1217 |
+
### List chat assistant's sessions
|
1218 |
|
1219 |
```python
|
1220 |
Chat.list_sessions(
|
|
|
1229 |
|
1230 |
Lists sessions associated with the current chat assistant.
|
1231 |
|
1232 |
+
#### Parameters
|
1233 |
|
1234 |
+
##### page: `int`
|
1235 |
|
1236 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1237 |
|
1238 |
+
##### page_size: `int`
|
1239 |
|
1240 |
The number of sessions on each page. Defaults to `30`.
|
1241 |
|
1242 |
+
##### orderby: `str`
|
1243 |
|
1244 |
The field by which sessions should be sorted. Available options:
|
1245 |
|
1246 |
- `"create_time"` (default)
|
1247 |
- `"update_time"`
|
1248 |
|
1249 |
+
##### desc: `bool`
|
1250 |
|
1251 |
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`.
|
1252 |
|
1253 |
+
##### id: `str`
|
1254 |
|
1255 |
The ID of the chat session to retrieve. Defaults to `None`.
|
1256 |
|
1257 |
+
##### name: `str`
|
1258 |
|
1259 |
The name of the chat session to retrieve. Defaults to `None`.
|
1260 |
|
1261 |
+
#### Returns
|
1262 |
|
1263 |
- Success: A list of `Session` objects associated with the current chat assistant.
|
1264 |
- Failure: `Exception`.
|
1265 |
|
1266 |
+
#### Examples
|
1267 |
|
1268 |
```python
|
1269 |
from ragflow_sdk import RAGFlow
|
|
|
1277 |
|
1278 |
---
|
1279 |
|
1280 |
+
### Delete chat assistant's sessions
|
1281 |
|
1282 |
```python
|
1283 |
Chat.delete_sessions(ids:list[str] = None)
|
|
|
1285 |
|
1286 |
Deletes sessions of the current chat assistant by ID.
|
1287 |
|
1288 |
+
#### Parameters
|
1289 |
|
1290 |
+
##### ids: `list[str]`
|
1291 |
|
1292 |
The IDs of the sessions to delete. Defaults to `None`. If it is not specified, all sessions associated with the current chat assistant will be deleted.
|
1293 |
|
1294 |
+
#### Returns
|
1295 |
|
1296 |
- Success: No value is returned.
|
1297 |
- Failure: `Exception`
|
1298 |
|
1299 |
+
#### Examples
|
1300 |
|
1301 |
```python
|
1302 |
from ragflow_sdk import RAGFlow
|
|
|
1309 |
|
1310 |
---
|
1311 |
|
1312 |
+
### Converse with chat assistant
|
1313 |
|
1314 |
```python
|
1315 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
|
|
1321 |
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
|
1322 |
:::
|
1323 |
|
1324 |
+
#### Parameters
|
1325 |
|
1326 |
+
##### question: `str`, *Required*
|
1327 |
|
1328 |
The question to start an AI-powered conversation.
|
1329 |
|
1330 |
+
##### stream: `bool`
|
1331 |
|
1332 |
Indicates whether to output responses in a streaming way:
|
1333 |
|
1334 |
- `True`: Enable streaming (default).
|
1335 |
- `False`: Disable streaming.
|
1336 |
|
1337 |
+
#### Returns
|
1338 |
|
1339 |
+
- A `Message` object containing the response to the question if `stream` is set to `False`.
|
1340 |
- An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True`
|
1341 |
|
1342 |
The following shows the attributes of a `Message` object:
|
1343 |
|
1344 |
+
##### id: `str`
|
1345 |
|
1346 |
The auto-generated message ID.
|
1347 |
|
1348 |
+
##### content: `str`
|
1349 |
|
1350 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1351 |
|
1352 |
+
##### reference: `list[Chunk]`
|
1353 |
|
1354 |
A list of `Chunk` objects representing references to the message, each containing the following attributes:
|
1355 |
|
|
|
1374 |
- `term_similarity` `float`
|
1375 |
A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords.
|
1376 |
|
1377 |
+
#### Examples
|
1378 |
|
1379 |
```python
|
1380 |
from ragflow_sdk import RAGFlow
|
|
|
1399 |
|
1400 |
---
|
1401 |
|
1402 |
+
### Create session with agent
|
1403 |
+
|
1404 |
```python
|
1405 |
Agent.create_session(id,rag) -> Session
|
1406 |
```
|
1407 |
|
1408 |
+
Creates a session with the current agent.
|
1409 |
|
1410 |
+
#### Returns
|
1411 |
|
1412 |
- Success: A `Session` object containing the following attributes:
|
1413 |
- `id`: `str` The auto-generated unique identifier of the created session.
|
|
|
1415 |
- `agent_id`: `str` The ID of the associated agent assistant.
|
1416 |
- Failure: `Exception`
|
1417 |
|
1418 |
+
#### Examples
|
1419 |
|
1420 |
```python
|
1421 |
from ragflow_sdk import RAGFlow
|
|
|
1427 |
|
1428 |
---
|
1429 |
|
1430 |
+
### Converse with agent
|
1431 |
|
1432 |
```python
|
1433 |
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
|
|
|
1439 |
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
|
1440 |
:::
|
1441 |
|
1442 |
+
#### Parameters
|
1443 |
|
1444 |
+
##### question: `str`, *Required*
|
1445 |
|
1446 |
The question to start an AI-powered conversation.
|
1447 |
|
1448 |
+
##### stream: `bool`
|
1449 |
|
1450 |
Indicates whether to output responses in a streaming way:
|
1451 |
|
1452 |
- `True`: Enable streaming (default).
|
1453 |
- `False`: Disable streaming.
|
1454 |
|
1455 |
+
#### Returns
|
1456 |
|
1457 |
- A `Message` object containing the response to the question if `stream` is set to `False`
|
1458 |
- An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True`
|
1459 |
|
1460 |
The following shows the attributes of a `Message` object:
|
1461 |
|
1462 |
+
##### id: `str`
|
1463 |
|
1464 |
The auto-generated message ID.
|
1465 |
|
1466 |
+
##### content: `str`
|
1467 |
|
1468 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1469 |
|
1470 |
+
##### reference: `list[Chunk]`
|
1471 |
|
1472 |
A list of `Chunk` objects representing references to the message, each containing the following attributes:
|
1473 |
|
|
|
1492 |
- `term_similarity` `float`
|
1493 |
A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords.
|
1494 |
|
1495 |
+
#### Examples
|
1496 |
|
1497 |
```python
|
1498 |
from ragflow_sdk import RAGFlow,Agent
|
|
|
1513 |
print(ans.content[len(cont):], end='', flush=True)
|
1514 |
cont = ans.content
|
1515 |
```
|
1516 |
+
|
1517 |
---
|
1518 |
|
1519 |
+
### List agent sessions
|
1520 |
|
1521 |
```python
|
1522 |
Agent.list_sessions(
|
|
|
1532 |
|
1533 |
Lists sessions associated with the current agent.
|
1534 |
|
1535 |
+
#### Parameters
|
1536 |
|
1537 |
+
##### page: `int`
|
1538 |
|
1539 |
Specifies the page on which the sessions will be displayed. Defaults to `1`.
|
1540 |
|
1541 |
+
##### page_size: `int`
|
1542 |
|
1543 |
The number of sessions on each page. Defaults to `30`.
|
1544 |
|
1545 |
+
##### orderby: `str`
|
1546 |
|
1547 |
The field by which sessions should be sorted. Available options:
|
1548 |
|
1549 |
- `"create_time"`
|
1550 |
- `"update_time"`(default)
|
1551 |
|
1552 |
+
##### desc: `bool`
|
1553 |
|
1554 |
Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`.
|
1555 |
|
1556 |
+
##### id: `str`
|
1557 |
|
1558 |
The ID of the agent session to retrieve. Defaults to `None`.
|
1559 |
|
1560 |
+
#### Returns
|
|
|
1561 |
|
1562 |
- Success: A list of `Session` objects associated with the current agent.
|
1563 |
- Failure: `Exception`.
|
1564 |
|
1565 |
+
#### Examples
|
1566 |
|
1567 |
```python
|
1568 |
from ragflow_sdk import RAGFlow
|
|
|
1575 |
```
|
1576 |
|
1577 |
---
|
1578 |
+
|
1579 |
+
### List agents
|
1580 |
|
1581 |
```python
|
1582 |
RAGFlow.list_agents(
|
|
|
1591 |
|
1592 |
Lists agents.
|
1593 |
|
1594 |
+
#### Parameters
|
1595 |
|
1596 |
+
##### page: `int`
|
1597 |
|
1598 |
Specifies the page on which the agents will be displayed. Defaults to `1`.
|
1599 |
|
1600 |
+
##### page_size: `int`
|
1601 |
|
1602 |
The number of agents on each page. Defaults to `30`.
|
1603 |
|
1604 |
+
##### orderby: `str`
|
1605 |
|
1606 |
The attribute by which the results are sorted. Available options:
|
1607 |
|
1608 |
- `"create_time"` (default)
|
1609 |
- `"update_time"`
|
1610 |
|
1611 |
+
##### desc: `bool`
|
1612 |
|
1613 |
Indicates whether the retrieved agents should be sorted in descending order. Defaults to `True`.
|
1614 |
|
1615 |
+
##### id: `str`
|
1616 |
|
1617 |
The ID of the agent to retrieve. Defaults to `None`.
|
1618 |
|
1619 |
+
##### name: `str`
|
1620 |
|
1621 |
The name of the agent to retrieve. Defaults to `None`.
|
1622 |
|
1623 |
+
#### Returns
|
1624 |
|
1625 |
- Success: A list of `Agent` objects.
|
1626 |
- Failure: `Exception`.
|
1627 |
|
1628 |
+
#### Examples
|
1629 |
|
1630 |
```python
|
1631 |
from ragflow_sdk import RAGFlow
|
1632 |
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
1633 |
for agent in rag_object.list_agents():
|
1634 |
print(agent)
|
1635 |
+
```
|
1636 |
+
|
1637 |
+
---
|