writinwaters
commited on
Commit
·
82f39fc
1
Parent(s):
cd7d2b9
Updated dataset APIs (#2820)
Browse files### What problem does this PR solve?
### Type of change
- [x] Documentation Update
- api/http_api.md +54 -54
- api/python_api_reference.md +120 -102
api/http_api.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
**POST** `/api/v1/dataset`
|
7 |
|
8 |
-
Creates a dataset.
|
9 |
|
10 |
### Request
|
11 |
|
@@ -31,11 +31,11 @@ Creates a dataset.
|
|
31 |
#### Request example
|
32 |
|
33 |
```bash
|
34 |
-
# "id": id must not be provided.
|
35 |
-
# "name": name is required and
|
36 |
# "tenant_id": tenant_id must not be provided.
|
37 |
-
# "embedding_model":
|
38 |
-
# "
|
39 |
curl --request POST \
|
40 |
--url http://{address}/api/v1/dataset \
|
41 |
--header 'Content-Type: application/json' \
|
@@ -51,21 +51,21 @@ curl --request POST \
|
|
51 |
#### Request parameters
|
52 |
|
53 |
- `"id"`: (*Body parameter*)
|
54 |
-
The
|
55 |
-
-
|
56 |
|
57 |
- `"name"`: (*Body parameter*)
|
58 |
The name of the dataset, which must adhere to the following requirements:
|
59 |
- Required when creating a dataset and must be unique.
|
60 |
-
-
|
61 |
|
62 |
- `"avatar"`: (*Body parameter*)
|
63 |
Base64 encoding of the avatar.
|
64 |
|
65 |
- `"tenant_id"`: (*Body parameter*)
|
66 |
The ID of the tenant associated with the dataset, used to link it with specific users.
|
67 |
-
-
|
68 |
-
-
|
69 |
|
70 |
- `"description"`: (*Body parameter*)
|
71 |
The description of the dataset.
|
@@ -74,31 +74,31 @@ curl --request POST \
|
|
74 |
The language setting for the dataset.
|
75 |
|
76 |
- `"embedding_model"`: (*Body parameter*)
|
77 |
-
Embedding model used in the dataset
|
78 |
-
-
|
79 |
-
-
|
80 |
|
81 |
- `"permission"`: (*Body parameter*)
|
82 |
Specifies who can manipulate the dataset.
|
83 |
|
84 |
- `"document_count"`: (*Body parameter*)
|
85 |
Document count of the dataset.
|
86 |
-
-
|
87 |
|
88 |
- `"chunk_count"`: (*Body parameter*)
|
89 |
Chunk count of the dataset.
|
90 |
-
-
|
91 |
|
92 |
- `"parse_method"`: (*Body parameter*)
|
93 |
Parsing method of the dataset.
|
94 |
-
-
|
95 |
|
96 |
- `"parser_config"`: (*Body parameter*)
|
97 |
The configuration settings for the dataset parser.
|
98 |
|
99 |
### Response
|
100 |
|
101 |
-
|
102 |
|
103 |
```json
|
104 |
{
|
@@ -139,8 +139,7 @@ The successful response includes a JSON object like the following:
|
|
139 |
- `"error_code"`: `integer`
|
140 |
`0`: The operation succeeds.
|
141 |
|
142 |
-
|
143 |
-
The error response includes a JSON object like the following:
|
144 |
|
145 |
```json
|
146 |
{
|
@@ -153,7 +152,7 @@ The error response includes a JSON object like the following:
|
|
153 |
|
154 |
**DELETE** `/api/v1/dataset`
|
155 |
|
156 |
-
Deletes datasets by
|
157 |
|
158 |
### Request
|
159 |
|
@@ -169,7 +168,7 @@ Deletes datasets by ids.
|
|
169 |
#### Request example
|
170 |
|
171 |
```bash
|
172 |
-
#
|
173 |
curl --request DELETE \
|
174 |
--url http://{address}/api/v1/dataset \
|
175 |
--header 'Content-Type: application/json' \
|
@@ -181,13 +180,13 @@ curl --request DELETE \
|
|
181 |
|
182 |
#### Request parameters
|
183 |
|
184 |
-
- `"ids"`: (*Body parameter*)
|
185 |
-
|
186 |
|
187 |
|
188 |
### Response
|
189 |
|
190 |
-
|
191 |
|
192 |
```json
|
193 |
{
|
@@ -199,7 +198,7 @@ The successful response includes a JSON object like the following:
|
|
199 |
`0`: The operation succeeds.
|
200 |
|
201 |
|
202 |
-
|
203 |
|
204 |
```json
|
205 |
{
|
@@ -212,7 +211,7 @@ The error response includes a JSON object like the following:
|
|
212 |
|
213 |
**PUT** `/api/v1/dataset/{dataset_id}`
|
214 |
|
215 |
-
Updates a dataset by its
|
216 |
|
217 |
### Request
|
218 |
|
@@ -227,14 +226,14 @@ Updates a dataset by its id.
|
|
227 |
#### Request example
|
228 |
|
229 |
```bash
|
230 |
-
# "id":
|
231 |
-
# "name": If you update name, it
|
232 |
-
# "tenant_id": If you update tenant_id, it
|
233 |
-
# "embedding_model": If you update embedding_model, it
|
234 |
-
# "chunk_count": If you update chunk_count, it
|
235 |
-
# "document_count": If you update document_count, it
|
236 |
-
# "parse_method": If you update parse_method, chunk_count must be 0.
|
237 |
-
# "
|
238 |
curl --request PUT \
|
239 |
--url http://{address}/api/v1/dataset/{dataset_id} \
|
240 |
--header 'Content-Type: application/json' \
|
@@ -245,17 +244,18 @@ curl --request PUT \
|
|
245 |
"embedding_model": "BAAI/bge-zh-v1.5",
|
246 |
"chunk_count": 0,
|
247 |
"document_count": 0,
|
248 |
-
"parse_method": "
|
249 |
}'
|
250 |
```
|
251 |
|
252 |
#### Request parameters
|
253 |
-
|
|
|
254 |
|
255 |
|
256 |
### Response
|
257 |
|
258 |
-
|
259 |
|
260 |
```json
|
261 |
{
|
@@ -267,7 +267,7 @@ The successful response includes a JSON object like the following:
|
|
267 |
`0`: The operation succeeds.
|
268 |
|
269 |
|
270 |
-
|
271 |
|
272 |
```json
|
273 |
{
|
@@ -321,7 +321,7 @@ curl --request GET \
|
|
321 |
|
322 |
### Response
|
323 |
|
324 |
-
|
325 |
|
326 |
```json
|
327 |
{
|
@@ -365,7 +365,7 @@ The successful response includes a JSON object like the following:
|
|
365 |
```
|
366 |
|
367 |
|
368 |
-
|
369 |
|
370 |
```json
|
371 |
{
|
@@ -409,7 +409,7 @@ curl --request POST \
|
|
409 |
|
410 |
### Response
|
411 |
|
412 |
-
|
413 |
|
414 |
```shell
|
415 |
{
|
@@ -421,7 +421,7 @@ The successful response includes a JSON object like the following:
|
|
421 |
`0`: The operation succeeds.
|
422 |
|
423 |
|
424 |
-
|
425 |
|
426 |
```shell
|
427 |
{
|
@@ -464,7 +464,7 @@ curl --request GET \
|
|
464 |
|
465 |
### Response
|
466 |
|
467 |
-
|
468 |
|
469 |
```shell
|
470 |
{
|
@@ -476,7 +476,7 @@ The successful response includes a JSON object like the following:
|
|
476 |
`0`: The operation succeeds.
|
477 |
|
478 |
|
479 |
-
|
480 |
|
481 |
```shell
|
482 |
{
|
@@ -528,7 +528,7 @@ curl --request GET \
|
|
528 |
|
529 |
### Response
|
530 |
|
531 |
-
|
532 |
|
533 |
```shell
|
534 |
{
|
@@ -605,7 +605,7 @@ The successful response includes a JSON object like the following:
|
|
605 |
`0`: The operation succeeds.
|
606 |
|
607 |
|
608 |
-
|
609 |
|
610 |
```shell
|
611 |
{
|
@@ -659,7 +659,7 @@ curl --request PUT \
|
|
659 |
|
660 |
### Response
|
661 |
|
662 |
-
|
663 |
|
664 |
```shell
|
665 |
{
|
@@ -667,7 +667,7 @@ The successful response includes a JSON object like the following:
|
|
667 |
}
|
668 |
```
|
669 |
|
670 |
-
|
671 |
|
672 |
```shell
|
673 |
{
|
@@ -710,7 +710,7 @@ curl --request POST \
|
|
710 |
|
711 |
### Response
|
712 |
|
713 |
-
|
714 |
|
715 |
```shell
|
716 |
{
|
@@ -718,7 +718,7 @@ The successful response includes a JSON object like the following:
|
|
718 |
}
|
719 |
```
|
720 |
|
721 |
-
|
722 |
|
723 |
```shell
|
724 |
{
|
@@ -761,7 +761,7 @@ curl --request DELETE \
|
|
761 |
|
762 |
### Response
|
763 |
|
764 |
-
|
765 |
|
766 |
```shell
|
767 |
{
|
@@ -769,7 +769,7 @@ The successful response includes a JSON object like the following:
|
|
769 |
}
|
770 |
```
|
771 |
|
772 |
-
|
773 |
|
774 |
```shell
|
775 |
{
|
@@ -808,7 +808,7 @@ curl --request GET \
|
|
808 |
|
809 |
### Response
|
810 |
|
811 |
-
|
812 |
|
813 |
```shell
|
814 |
{
|
@@ -863,7 +863,7 @@ The successful response includes a JSON object like the following:
|
|
863 |
}
|
864 |
```
|
865 |
|
866 |
-
|
867 |
|
868 |
```shell
|
869 |
{
|
|
|
5 |
|
6 |
**POST** `/api/v1/dataset`
|
7 |
|
8 |
+
Creates a knowledge base (dataset).
|
9 |
|
10 |
### Request
|
11 |
|
|
|
31 |
#### Request example
|
32 |
|
33 |
```bash
|
34 |
+
# "id": "id" must not be provided.
|
35 |
+
# "name": name is required and cannot be duplicated.
|
36 |
# "tenant_id": tenant_id must not be provided.
|
37 |
+
# "embedding_model": REQUIRED.
|
38 |
+
# "naive": general.
|
39 |
curl --request POST \
|
40 |
--url http://{address}/api/v1/dataset \
|
41 |
--header 'Content-Type: application/json' \
|
|
|
51 |
#### Request parameters
|
52 |
|
53 |
- `"id"`: (*Body parameter*)
|
54 |
+
The unique identifier of each created dataset.
|
55 |
+
- When creating a dataset, `id` must not be provided.
|
56 |
|
57 |
- `"name"`: (*Body parameter*)
|
58 |
The name of the dataset, which must adhere to the following requirements:
|
59 |
- Required when creating a dataset and must be unique.
|
60 |
+
- When updating a dataset, `name` must still be unique.
|
61 |
|
62 |
- `"avatar"`: (*Body parameter*)
|
63 |
Base64 encoding of the avatar.
|
64 |
|
65 |
- `"tenant_id"`: (*Body parameter*)
|
66 |
The ID of the tenant associated with the dataset, used to link it with specific users.
|
67 |
+
- When creating a dataset, `tenant_id` must not be provided.
|
68 |
+
- When updating a dataset, `tenant_id` cannot be changed.
|
69 |
|
70 |
- `"description"`: (*Body parameter*)
|
71 |
The description of the dataset.
|
|
|
74 |
The language setting for the dataset.
|
75 |
|
76 |
- `"embedding_model"`: (*Body parameter*)
|
77 |
+
Embedding model used in the dataset for generating vector embeddings.
|
78 |
+
- When creating a dataset, `embedding_model` must not be provided.
|
79 |
+
- When updating a dataset, `embedding_model` cannot be changed.
|
80 |
|
81 |
- `"permission"`: (*Body parameter*)
|
82 |
Specifies who can manipulate the dataset.
|
83 |
|
84 |
- `"document_count"`: (*Body parameter*)
|
85 |
Document count of the dataset.
|
86 |
+
- When updating a dataset, `document_count` cannot be changed.
|
87 |
|
88 |
- `"chunk_count"`: (*Body parameter*)
|
89 |
Chunk count of the dataset.
|
90 |
+
- When updating a dataset, `chunk_count` cannot be changed.
|
91 |
|
92 |
- `"parse_method"`: (*Body parameter*)
|
93 |
Parsing method of the dataset.
|
94 |
+
- When updating `parse_method`, `chunk_count` must be greater than 0.
|
95 |
|
96 |
- `"parser_config"`: (*Body parameter*)
|
97 |
The configuration settings for the dataset parser.
|
98 |
|
99 |
### Response
|
100 |
|
101 |
+
A successful response includes a JSON object like the following:
|
102 |
|
103 |
```json
|
104 |
{
|
|
|
139 |
- `"error_code"`: `integer`
|
140 |
`0`: The operation succeeds.
|
141 |
|
142 |
+
An error response includes a JSON object like the following:
|
|
|
143 |
|
144 |
```json
|
145 |
{
|
|
|
152 |
|
153 |
**DELETE** `/api/v1/dataset`
|
154 |
|
155 |
+
Deletes datasets by their IDs.
|
156 |
|
157 |
### Request
|
158 |
|
|
|
168 |
#### Request example
|
169 |
|
170 |
```bash
|
171 |
+
# Specify either "ids" or "names", NOT both.
|
172 |
curl --request DELETE \
|
173 |
--url http://{address}/api/v1/dataset \
|
174 |
--header 'Content-Type: application/json' \
|
|
|
180 |
|
181 |
#### Request parameters
|
182 |
|
183 |
+
- `"ids"`: (*Body parameter*)
|
184 |
+
IDs of the datasets to delete.
|
185 |
|
186 |
|
187 |
### Response
|
188 |
|
189 |
+
A successful response includes a JSON object like the following:
|
190 |
|
191 |
```json
|
192 |
{
|
|
|
198 |
`0`: The operation succeeds.
|
199 |
|
200 |
|
201 |
+
An error response includes a JSON object like the following:
|
202 |
|
203 |
```json
|
204 |
{
|
|
|
211 |
|
212 |
**PUT** `/api/v1/dataset/{dataset_id}`
|
213 |
|
214 |
+
Updates a dataset by its ID.
|
215 |
|
216 |
### Request
|
217 |
|
|
|
226 |
#### Request example
|
227 |
|
228 |
```bash
|
229 |
+
# "id": REQUIRED
|
230 |
+
# "name": If you update "name", it cannot be duplicated.
|
231 |
+
# "tenant_id": If you update "tenant_id", it cannot be changed
|
232 |
+
# "embedding_model": If you update "embedding_model", it cannot be changed.
|
233 |
+
# "chunk_count": If you update "chunk_count", it cannot be changed.
|
234 |
+
# "document_count": If you update "document_count", it cannot be changed.
|
235 |
+
# "parse_method": If you update "parse_method", "chunk_count" must be 0.
|
236 |
+
# "naive": General.
|
237 |
curl --request PUT \
|
238 |
--url http://{address}/api/v1/dataset/{dataset_id} \
|
239 |
--header 'Content-Type: application/json' \
|
|
|
244 |
"embedding_model": "BAAI/bge-zh-v1.5",
|
245 |
"chunk_count": 0,
|
246 |
"document_count": 0,
|
247 |
+
"parse_method": "naive"
|
248 |
}'
|
249 |
```
|
250 |
|
251 |
#### Request parameters
|
252 |
+
|
253 |
+
See the "Create Dataset" for the complete structure of the request parameters.
|
254 |
|
255 |
|
256 |
### Response
|
257 |
|
258 |
+
A successful response includes a JSON object like the following:
|
259 |
|
260 |
```json
|
261 |
{
|
|
|
267 |
`0`: The operation succeeds.
|
268 |
|
269 |
|
270 |
+
An error response includes a JSON object like the following:
|
271 |
|
272 |
```json
|
273 |
{
|
|
|
321 |
|
322 |
### Response
|
323 |
|
324 |
+
A successful response includes a JSON object like the following:
|
325 |
|
326 |
```json
|
327 |
{
|
|
|
365 |
```
|
366 |
|
367 |
|
368 |
+
An error response includes a JSON object like the following:
|
369 |
|
370 |
```json
|
371 |
{
|
|
|
409 |
|
410 |
### Response
|
411 |
|
412 |
+
A successful response includes a JSON object like the following:
|
413 |
|
414 |
```shell
|
415 |
{
|
|
|
421 |
`0`: The operation succeeds.
|
422 |
|
423 |
|
424 |
+
An error response includes a JSON object like the following:
|
425 |
|
426 |
```shell
|
427 |
{
|
|
|
464 |
|
465 |
### Response
|
466 |
|
467 |
+
A successful response includes a JSON object like the following:
|
468 |
|
469 |
```shell
|
470 |
{
|
|
|
476 |
`0`: The operation succeeds.
|
477 |
|
478 |
|
479 |
+
An error response includes a JSON object like the following:
|
480 |
|
481 |
```shell
|
482 |
{
|
|
|
528 |
|
529 |
### Response
|
530 |
|
531 |
+
A successful response includes a JSON object like the following:
|
532 |
|
533 |
```shell
|
534 |
{
|
|
|
605 |
`0`: The operation succeeds.
|
606 |
|
607 |
|
608 |
+
An error response includes a JSON object like the following:
|
609 |
|
610 |
```shell
|
611 |
{
|
|
|
659 |
|
660 |
### Response
|
661 |
|
662 |
+
A successful response includes a JSON object like the following:
|
663 |
|
664 |
```shell
|
665 |
{
|
|
|
667 |
}
|
668 |
```
|
669 |
|
670 |
+
An error response includes a JSON object like the following:
|
671 |
|
672 |
```shell
|
673 |
{
|
|
|
710 |
|
711 |
### Response
|
712 |
|
713 |
+
A successful response includes a JSON object like the following:
|
714 |
|
715 |
```shell
|
716 |
{
|
|
|
718 |
}
|
719 |
```
|
720 |
|
721 |
+
An error response includes a JSON object like the following:
|
722 |
|
723 |
```shell
|
724 |
{
|
|
|
761 |
|
762 |
### Response
|
763 |
|
764 |
+
A successful response includes a JSON object like the following:
|
765 |
|
766 |
```shell
|
767 |
{
|
|
|
769 |
}
|
770 |
```
|
771 |
|
772 |
+
An error response includes a JSON object like the following:
|
773 |
|
774 |
```shell
|
775 |
{
|
|
|
808 |
|
809 |
### Response
|
810 |
|
811 |
+
A successful response includes a JSON object like the following:
|
812 |
|
813 |
```shell
|
814 |
{
|
|
|
863 |
}
|
864 |
```
|
865 |
|
866 |
+
An error response includes a JSON object like the following:
|
867 |
|
868 |
```shell
|
869 |
{
|
api/python_api_reference.md
CHANGED
@@ -24,7 +24,7 @@ Creates a knowledge base (dataset).
|
|
24 |
|
25 |
### Parameters
|
26 |
|
27 |
-
#### name:
|
28 |
|
29 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
30 |
|
@@ -36,70 +36,81 @@ The unique name of the dataset to create. It must adhere to the following requir
|
|
36 |
- Maximum 65,535 characters.
|
37 |
- Case-insensitive.
|
38 |
|
39 |
-
#### avatar
|
40 |
|
41 |
Base64 encoding of the avatar. Defaults to `""`
|
42 |
|
43 |
-
#### tenant_id
|
44 |
|
45 |
The id of the tenant associated with the created dataset is used to identify different users. Defaults to `None`.
|
46 |
|
47 |
-
-
|
48 |
-
-
|
49 |
|
50 |
-
#### description
|
51 |
|
52 |
The description of the created dataset. Defaults to `""`.
|
53 |
|
54 |
-
#### language
|
55 |
|
56 |
-
The language setting of the created dataset. Defaults to `"English"`.
|
57 |
|
58 |
-
#### embedding_model
|
59 |
|
60 |
The specific model used by the dataset to generate vector embeddings. Defaults to `""`.
|
61 |
|
62 |
-
-
|
63 |
-
-
|
64 |
|
65 |
-
#### permission
|
66 |
|
67 |
-
|
68 |
|
69 |
-
#### document_count
|
70 |
|
71 |
The number of documents associated with the dataset. Defaults to `0`.
|
72 |
|
73 |
-
|
|
|
|
|
74 |
|
75 |
-
#### chunk_count
|
76 |
|
77 |
The number of data chunks generated or processed by the created dataset. Defaults to `0`.
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
|
|
|
|
84 |
|
85 |
-
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
|
|
|
|
|
|
90 |
|
91 |
### Returns
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
### Examples
|
97 |
|
98 |
```python
|
99 |
from ragflow import RAGFlow
|
100 |
|
101 |
-
|
102 |
-
ds =
|
103 |
```
|
104 |
|
105 |
---
|
@@ -107,28 +118,27 @@ ds = rag.create_dataset(name="kb_1")
|
|
107 |
## Delete knowledge bases
|
108 |
|
109 |
```python
|
110 |
-
RAGFlow.delete_datasets(ids:
|
111 |
```
|
112 |
-
Deletes knowledge bases.
|
113 |
-
### Parameters
|
114 |
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
|
118 |
|
|
|
119 |
|
120 |
### Returns
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
```
|
125 |
|
126 |
### Examples
|
127 |
|
128 |
-
|
129 |
-
from ragflow import RAGFlow
|
130 |
|
131 |
-
|
132 |
rag.delete_datasets(ids=["id_1","id_2"])
|
133 |
```
|
134 |
|
@@ -144,76 +154,84 @@ RAGFlow.list_datasets(
|
|
144 |
desc: bool = True,
|
145 |
id: str = None,
|
146 |
name: str = None
|
147 |
-
) ->
|
148 |
```
|
149 |
|
150 |
-
Lists all knowledge bases
|
151 |
|
152 |
### Parameters
|
153 |
|
154 |
-
#### page
|
155 |
|
156 |
The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched. Defaults to `1`.
|
157 |
|
158 |
-
#### page_size
|
159 |
|
160 |
The number of records to retrieve per page. This controls how many records will be included in each page. Defaults to `1024`.
|
161 |
|
162 |
-
#### order_by
|
163 |
|
164 |
-
The
|
165 |
|
166 |
-
#### desc
|
167 |
|
168 |
-
|
169 |
|
170 |
-
#### id
|
171 |
|
172 |
-
The
|
173 |
|
174 |
-
#### name
|
175 |
|
176 |
-
The name of the dataset to
|
177 |
|
178 |
### Returns
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
description:the list of datasets.
|
183 |
-
```
|
184 |
|
185 |
### Examples
|
186 |
|
|
|
|
|
187 |
```python
|
188 |
-
|
|
|
|
|
|
|
|
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
```
|
194 |
|
195 |
---
|
196 |
|
197 |
-
|
198 |
-
## Update knowledge base
|
199 |
|
200 |
```python
|
201 |
DataSet.update(update_message: dict)
|
202 |
```
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
### Returns
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
```
|
209 |
|
210 |
### Examples
|
211 |
|
212 |
```python
|
213 |
from ragflow import RAGFlow
|
214 |
|
215 |
-
rag = RAGFlow(api_key="
|
216 |
-
ds = rag.
|
217 |
ds.update({"parse_method":"manual", ...}}
|
218 |
```
|
219 |
|
@@ -336,7 +354,7 @@ Duration of the processing in seconds or minutes. Defaults to `0.0`.
|
|
336 |
```python
|
337 |
from ragflow import RAGFlow
|
338 |
|
339 |
-
rag = RAGFlow(api_key="
|
340 |
doc = rag.get_document(id="wdfxb5t547d",name='testdocument.txt')
|
341 |
print(doc)
|
342 |
```
|
@@ -358,7 +376,7 @@ bool
|
|
358 |
```python
|
359 |
from ragflow import RAGFlow
|
360 |
|
361 |
-
rag = RAGFlow(api_key="
|
362 |
doc = rag.get_document(id="wdfxb5t547d")
|
363 |
doc.parser_method= "manual"
|
364 |
doc.save()
|
@@ -381,7 +399,7 @@ bytes of the document.
|
|
381 |
```python
|
382 |
from ragflow import RAGFlow
|
383 |
|
384 |
-
rag = RAGFlow(api_key="
|
385 |
doc = rag.get_document(id="wdfxb5t547d")
|
386 |
open("~/ragflow.txt", "w+").write(doc.download())
|
387 |
print(doc)
|
@@ -392,7 +410,7 @@ print(doc)
|
|
392 |
## List documents
|
393 |
|
394 |
```python
|
395 |
-
Dataset.list_docs(keywords: str=None, offset: int=0, limit:int = -1) ->
|
396 |
```
|
397 |
|
398 |
### Parameters
|
@@ -407,18 +425,18 @@ The beginning number of records for paging. Defaults to `0`.
|
|
407 |
|
408 |
#### limit: `int`
|
409 |
|
410 |
-
Records number to return, -1 means all of them.
|
411 |
|
412 |
### Returns
|
413 |
|
414 |
-
|
415 |
|
416 |
### Examples
|
417 |
|
418 |
```python
|
419 |
from ragflow import RAGFlow
|
420 |
|
421 |
-
rag = RAGFlow(api_key="
|
422 |
ds = rag.create_dataset(name="kb_1")
|
423 |
|
424 |
filename1 = "~/ragflow.txt"
|
@@ -448,7 +466,7 @@ description: delete success or not
|
|
448 |
```python
|
449 |
from ragflow import RAGFlow
|
450 |
|
451 |
-
rag = RAGFlow(api_key="
|
452 |
ds = rag.create_dataset(name="kb_1")
|
453 |
|
454 |
filename1 = "~/ragflow.txt"
|
@@ -581,7 +599,7 @@ chunk
|
|
581 |
```python
|
582 |
from ragflow import RAGFlow
|
583 |
|
584 |
-
rag = RAGFlow(api_key="
|
585 |
doc = rag.get_document(id="wdfxb5t547d")
|
586 |
chunk = doc.add_chunk(content="xxxxxxx")
|
587 |
```
|
@@ -603,7 +621,7 @@ bool
|
|
603 |
```python
|
604 |
from ragflow import RAGFlow
|
605 |
|
606 |
-
rag = RAGFlow(api_key="
|
607 |
doc = rag.get_document(id="wdfxb5t547d")
|
608 |
chunk = doc.add_chunk(content="xxxxxxx")
|
609 |
chunk.delete()
|
@@ -626,7 +644,7 @@ bool
|
|
626 |
```python
|
627 |
from ragflow import RAGFlow
|
628 |
|
629 |
-
rag = RAGFlow(api_key="
|
630 |
doc = rag.get_document(id="wdfxb5t547d")
|
631 |
chunk = doc.add_chunk(content="xxxxxxx")
|
632 |
chunk.content = "sdfx"
|
@@ -638,7 +656,7 @@ chunk.save()
|
|
638 |
## Retrieval
|
639 |
|
640 |
```python
|
641 |
-
RAGFlow.retrieval(question:str, datasets:
|
642 |
```
|
643 |
|
644 |
### Parameters
|
@@ -647,11 +665,11 @@ RAGFlow.retrieval(question:str, datasets:List[Dataset], document=List[Document]=
|
|
647 |
|
648 |
The user query or query keywords. Defaults to `""`.
|
649 |
|
650 |
-
#### datasets: `
|
651 |
|
652 |
The scope of datasets.
|
653 |
|
654 |
-
#### document: `
|
655 |
|
656 |
The scope of document. `None` means no limitation. Defaults to `None`.
|
657 |
|
@@ -677,14 +695,14 @@ Number of records engaged in vector cosine computaton. Defaults to `1024`.
|
|
677 |
|
678 |
### Returns
|
679 |
|
680 |
-
|
681 |
|
682 |
### Examples
|
683 |
|
684 |
```python
|
685 |
from ragflow import RAGFlow
|
686 |
|
687 |
-
rag = RAGFlow(api_key="
|
688 |
ds = rag.get_dataset(name="ragflow")
|
689 |
name = 'ragflow_test.txt'
|
690 |
path = 'test_data/ragflow_test.txt'
|
@@ -715,7 +733,7 @@ Chat APIs
|
|
715 |
RAGFlow.create_chat(
|
716 |
name: str = "assistant",
|
717 |
avatar: str = "path",
|
718 |
-
knowledgebases:
|
719 |
llm: Chat.LLM = None,
|
720 |
prompt: Chat.Prompt = None
|
721 |
) -> Chat
|
@@ -736,7 +754,7 @@ The name of the created chat. Defaults to `"assistant"`.
|
|
736 |
|
737 |
The icon of the created chat. Defaults to `"path"`.
|
738 |
|
739 |
-
#### knowledgebases: `
|
740 |
|
741 |
Select knowledgebases associated. Defaults to `["kb1"]`.
|
742 |
|
@@ -778,7 +796,7 @@ You are an intelligent assistant. Please summarize the content of the knowledge
|
|
778 |
```python
|
779 |
from ragflow import RAGFlow
|
780 |
|
781 |
-
rag = RAGFlow(api_key="
|
782 |
kb = rag.get_dataset(name="kb_1")
|
783 |
assi = rag.create_chat("Miss R", knowledgebases=[kb])
|
784 |
```
|
@@ -802,7 +820,7 @@ no return
|
|
802 |
```python
|
803 |
from ragflow import RAGFlow
|
804 |
|
805 |
-
rag = RAGFlow(api_key="
|
806 |
kb = rag.get_knowledgebase(name="kb_1")
|
807 |
assi = rag.create_chat("Miss R", knowledgebases=[kb])
|
808 |
assi.update({"temperature":0.8})
|
@@ -813,7 +831,7 @@ assi.update({"temperature":0.8})
|
|
813 |
## Delete chats
|
814 |
|
815 |
```python
|
816 |
-
RAGFlow.delete_chats(ids:
|
817 |
```
|
818 |
### Parameters
|
819 |
|
@@ -833,7 +851,7 @@ no return
|
|
833 |
```python
|
834 |
from ragflow import RAGFlow
|
835 |
|
836 |
-
rag = RAGFlow(api_key="
|
837 |
rag.delete_chats(ids=["id_1","id_2"])
|
838 |
```
|
839 |
|
@@ -849,7 +867,7 @@ RAGFlow.list_chats(
|
|
849 |
desc: bool = True,
|
850 |
id: str = None,
|
851 |
name: str = None
|
852 |
-
) ->
|
853 |
```
|
854 |
|
855 |
### Parameters
|
@@ -892,7 +910,7 @@ A list of chat objects.
|
|
892 |
```python
|
893 |
from ragflow import RAGFlow
|
894 |
|
895 |
-
rag = RAGFlow(api_key="
|
896 |
for assi in rag.list_chats():
|
897 |
print(assi)
|
898 |
```
|
@@ -922,7 +940,7 @@ The id of the created session is used to identify different sessions.
|
|
922 |
|
923 |
The name of the created session. Defaults to `"New session"`.
|
924 |
|
925 |
-
#### messages: `
|
926 |
|
927 |
The messages of the created session.
|
928 |
- messages cannot be provided.
|
@@ -945,7 +963,7 @@ The id of associated chat
|
|
945 |
```python
|
946 |
from ragflow import RAGFlow
|
947 |
|
948 |
-
rag = RAGFlow(api_key="
|
949 |
assi = rag.list_chats(name="Miss R")
|
950 |
assi = assi[0]
|
951 |
sess = assi.create_session()
|
@@ -967,7 +985,7 @@ no return
|
|
967 |
```python
|
968 |
from ragflow import RAGFlow
|
969 |
|
970 |
-
rag = RAGFlow(api_key="
|
971 |
assi = rag.list_chats(name="Miss R")
|
972 |
assi = assi[0]
|
973 |
sess = assi.create_session("new_session")
|
@@ -1005,7 +1023,7 @@ The id of the message. `id` is automatically generated. Defaults to `None`. ????
|
|
1005 |
|
1006 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1007 |
|
1008 |
-
#### reference: `
|
1009 |
|
1010 |
The auto-generated reference of the message. Each `chunk` object includes the following attributes:
|
1011 |
|
@@ -1027,7 +1045,7 @@ The auto-generated reference of the message. Each `chunk` object includes the fo
|
|
1027 |
A similarity score based on vector representations. This score is obtained by converting texts, words, or objects into vectors and then calculating the cosine similarity or other distance measures between these vectors to determine the similarity in vector space. A higher value indicates greater similarity in the vector space. Defaults to `None`. ?????????????????????????????????
|
1028 |
- **term_similarity**: `float`
|
1029 |
The similarity score based on terms or keywords. This score is calculated by comparing the similarity of key terms between texts or datasets, typically measuring how similar two words or phrases are in meaning or context. A higher value indicates a stronger similarity between terms. Defaults to `None`. ???????????????????
|
1030 |
-
- **position**: `
|
1031 |
Indicates the position or index of keywords or specific terms within the text. An array is typically used to mark the location of keywords or specific elements, facilitating precise operations or analysis of the text. Defaults to `None`. ??????????????
|
1032 |
|
1033 |
### Examples
|
@@ -1035,7 +1053,7 @@ The auto-generated reference of the message. Each `chunk` object includes the fo
|
|
1035 |
```python
|
1036 |
from ragflow import RAGFlow
|
1037 |
|
1038 |
-
rag = RAGFlow(api_key="
|
1039 |
assi = rag.list_chats(name="Miss R")
|
1040 |
assi = assi[0]
|
1041 |
sess = assi.create_session()
|
@@ -1066,12 +1084,12 @@ Chat.list_sessions(
|
|
1066 |
desc: bool = True,
|
1067 |
id: str = None,
|
1068 |
name: str = None
|
1069 |
-
) ->
|
1070 |
```
|
1071 |
|
1072 |
### Returns
|
1073 |
|
1074 |
-
|
1075 |
description: the List contains information about multiple assistant object, with each dictionary containing information about one assistant.
|
1076 |
|
1077 |
### Examples
|
@@ -1079,7 +1097,7 @@ description: the List contains information about multiple assistant object, with
|
|
1079 |
```python
|
1080 |
from ragflow import RAGFlow
|
1081 |
|
1082 |
-
rag = RAGFlow(api_key="
|
1083 |
assi = rag.list_chats(name="Miss R")
|
1084 |
assi = assi[0]
|
1085 |
for sess in assi.list_sessions():
|
@@ -1122,7 +1140,7 @@ The name of the chat to be retrieved.
|
|
1122 |
## Delete session
|
1123 |
|
1124 |
```python
|
1125 |
-
Chat.delete_sessions(ids:
|
1126 |
```
|
1127 |
|
1128 |
### Returns
|
@@ -1134,13 +1152,13 @@ no return
|
|
1134 |
```python
|
1135 |
from ragflow import RAGFlow
|
1136 |
|
1137 |
-
rag = RAGFlow(api_key="
|
1138 |
assi = rag.list_chats(name="Miss R")
|
1139 |
assi = assi[0]
|
1140 |
assi.delete_sessions(ids=["id_1","id_2"])
|
1141 |
```
|
1142 |
### Parameters
|
1143 |
-
#### ids: `
|
1144 |
IDs of the sessions to be deleted.
|
1145 |
- `None`
|
1146 |
|
|
|
24 |
|
25 |
### Parameters
|
26 |
|
27 |
+
#### name: *Required*
|
28 |
|
29 |
The unique name of the dataset to create. It must adhere to the following requirements:
|
30 |
|
|
|
36 |
- Maximum 65,535 characters.
|
37 |
- Case-insensitive.
|
38 |
|
39 |
+
#### avatar
|
40 |
|
41 |
Base64 encoding of the avatar. Defaults to `""`
|
42 |
|
43 |
+
#### tenant_id
|
44 |
|
45 |
The id of the tenant associated with the created dataset is used to identify different users. Defaults to `None`.
|
46 |
|
47 |
+
- When creating a dataset, `tenant_id` must not be provided.
|
48 |
+
- When updating a dataset, `tenant_id` cannot be changed.
|
49 |
|
50 |
+
#### description
|
51 |
|
52 |
The description of the created dataset. Defaults to `""`.
|
53 |
|
54 |
+
#### language
|
55 |
|
56 |
+
The language setting of the created dataset. Defaults to `"English"`.
|
57 |
|
58 |
+
#### embedding_model
|
59 |
|
60 |
The specific model used by the dataset to generate vector embeddings. Defaults to `""`.
|
61 |
|
62 |
+
- When creating a dataset, `embedding_model` must not be provided.
|
63 |
+
- When updating a dataset, `embedding_model` cannot be changed.
|
64 |
|
65 |
+
#### permission
|
66 |
|
67 |
+
The person who can operate on the dataset. Defaults to `"me"`.
|
68 |
|
69 |
+
#### document_count
|
70 |
|
71 |
The number of documents associated with the dataset. Defaults to `0`.
|
72 |
|
73 |
+
:::tip NOTE
|
74 |
+
When updating a dataset, `document_count` cannot be changed.
|
75 |
+
:::
|
76 |
|
77 |
+
#### chunk_count
|
78 |
|
79 |
The number of data chunks generated or processed by the created dataset. Defaults to `0`.
|
80 |
|
81 |
+
:::tip NOTE
|
82 |
+
When updating a dataset, `chunk_count` cannot be changed.
|
83 |
+
:::
|
84 |
+
|
85 |
+
#### parse_method
|
86 |
|
87 |
+
The method used by the dataset to parse and process data. Defaults to `"naive"`.
|
88 |
|
89 |
+
:::tip NOTE
|
90 |
+
When updating `parse_method` in a dataset, `chunk_count` must be greater than 0.
|
91 |
+
:::
|
92 |
|
93 |
+
#### parser_config
|
94 |
|
95 |
+
The parser configuration of the dataset. A `ParserConfig` object contains the following attributes:
|
96 |
|
97 |
+
- `chunk_token_count`: Defaults to `128`.
|
98 |
+
- `layout_recognize`: Defaults to `True`.
|
99 |
+
- `delimiter`: Defaults to `'\n!?。;!?'`.
|
100 |
+
- `task_page_size`: Defaults to `12`.
|
101 |
|
102 |
### Returns
|
103 |
+
|
104 |
+
- Success: A `dataset` object.
|
105 |
+
- Failure: `Exception`
|
106 |
+
|
107 |
### Examples
|
108 |
|
109 |
```python
|
110 |
from ragflow import RAGFlow
|
111 |
|
112 |
+
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
113 |
+
ds = rag_object.create_dataset(name="kb_1")
|
114 |
```
|
115 |
|
116 |
---
|
|
|
118 |
## Delete knowledge bases
|
119 |
|
120 |
```python
|
121 |
+
RAGFlow.delete_datasets(ids: list[str] = None)
|
122 |
```
|
|
|
|
|
123 |
|
124 |
+
Deletes knowledge bases by name or ID.
|
125 |
+
|
126 |
+
### Parameters
|
127 |
|
128 |
+
#### ids
|
129 |
|
130 |
+
The IDs of the knowledge bases to delete.
|
131 |
|
132 |
### Returns
|
133 |
|
134 |
+
- Success: No value is returned.
|
135 |
+
- Failure: `Exception`
|
|
|
136 |
|
137 |
### Examples
|
138 |
|
139 |
+
#### Delete knowledge bases by name
|
|
|
140 |
|
141 |
+
```python
|
142 |
rag.delete_datasets(ids=["id_1","id_2"])
|
143 |
```
|
144 |
|
|
|
154 |
desc: bool = True,
|
155 |
id: str = None,
|
156 |
name: str = None
|
157 |
+
) -> list[DataSet]
|
158 |
```
|
159 |
|
160 |
+
Lists all knowledge bases.
|
161 |
|
162 |
### Parameters
|
163 |
|
164 |
+
#### page
|
165 |
|
166 |
The current page number to retrieve from the paginated data. This parameter determines which set of records will be fetched. Defaults to `1`.
|
167 |
|
168 |
+
#### page_size
|
169 |
|
170 |
The number of records to retrieve per page. This controls how many records will be included in each page. Defaults to `1024`.
|
171 |
|
172 |
+
#### order_by
|
173 |
|
174 |
+
The attribute by which the results are sorted. Defaults to `"create_time"`.
|
175 |
|
176 |
+
#### desc
|
177 |
|
178 |
+
Indicates whether to sort the results in descending order. Defaults to `True`.
|
179 |
|
180 |
+
#### id
|
181 |
|
182 |
+
The ID of the dataset to retrieve. Defaults to `None`.
|
183 |
|
184 |
+
#### name
|
185 |
|
186 |
+
The name of the dataset to retrieve. Defaults to `None`.
|
187 |
|
188 |
### Returns
|
189 |
|
190 |
+
- Success: A list of `DataSet` objects representing the retrieved knowledge bases.
|
191 |
+
- Failure: `Exception`.
|
|
|
|
|
192 |
|
193 |
### Examples
|
194 |
|
195 |
+
#### Retrieve a list of knowledge bases associated with the current user
|
196 |
+
|
197 |
```python
|
198 |
+
for ds in rag_object.list_datasets():
|
199 |
+
print(ds.name)
|
200 |
+
```
|
201 |
+
|
202 |
+
#### Retrieve a knowledge base by ID
|
203 |
|
204 |
+
```python
|
205 |
+
ds = rag_object.list_datasets(id = "id_1")
|
206 |
+
print(ds.name)
|
207 |
```
|
208 |
|
209 |
---
|
210 |
|
211 |
+
## Update knowledge base
|
|
|
212 |
|
213 |
```python
|
214 |
DataSet.update(update_message: dict)
|
215 |
```
|
216 |
|
217 |
+
Updates the current knowledge base.
|
218 |
+
|
219 |
+
### Parameters
|
220 |
+
|
221 |
+
#### update_message
|
222 |
+
|
223 |
### Returns
|
224 |
|
225 |
+
- Success: No value is returned.
|
226 |
+
- Failure: `Exception`
|
|
|
227 |
|
228 |
### Examples
|
229 |
|
230 |
```python
|
231 |
from ragflow import RAGFlow
|
232 |
|
233 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
234 |
+
ds = rag.list_datasets(name="kb_1")
|
235 |
ds.update({"parse_method":"manual", ...}}
|
236 |
```
|
237 |
|
|
|
354 |
```python
|
355 |
from ragflow import RAGFlow
|
356 |
|
357 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
358 |
doc = rag.get_document(id="wdfxb5t547d",name='testdocument.txt')
|
359 |
print(doc)
|
360 |
```
|
|
|
376 |
```python
|
377 |
from ragflow import RAGFlow
|
378 |
|
379 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
380 |
doc = rag.get_document(id="wdfxb5t547d")
|
381 |
doc.parser_method= "manual"
|
382 |
doc.save()
|
|
|
399 |
```python
|
400 |
from ragflow import RAGFlow
|
401 |
|
402 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
403 |
doc = rag.get_document(id="wdfxb5t547d")
|
404 |
open("~/ragflow.txt", "w+").write(doc.download())
|
405 |
print(doc)
|
|
|
410 |
## List documents
|
411 |
|
412 |
```python
|
413 |
+
Dataset.list_docs(keywords: str=None, offset: int=0, limit:int = -1) -> list[Document]
|
414 |
```
|
415 |
|
416 |
### Parameters
|
|
|
425 |
|
426 |
#### limit: `int`
|
427 |
|
428 |
+
Records number to return, -1 means all of them.
|
429 |
|
430 |
### Returns
|
431 |
|
432 |
+
list[Document]
|
433 |
|
434 |
### Examples
|
435 |
|
436 |
```python
|
437 |
from ragflow import RAGFlow
|
438 |
|
439 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
440 |
ds = rag.create_dataset(name="kb_1")
|
441 |
|
442 |
filename1 = "~/ragflow.txt"
|
|
|
466 |
```python
|
467 |
from ragflow import RAGFlow
|
468 |
|
469 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
470 |
ds = rag.create_dataset(name="kb_1")
|
471 |
|
472 |
filename1 = "~/ragflow.txt"
|
|
|
599 |
```python
|
600 |
from ragflow import RAGFlow
|
601 |
|
602 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
603 |
doc = rag.get_document(id="wdfxb5t547d")
|
604 |
chunk = doc.add_chunk(content="xxxxxxx")
|
605 |
```
|
|
|
621 |
```python
|
622 |
from ragflow import RAGFlow
|
623 |
|
624 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
625 |
doc = rag.get_document(id="wdfxb5t547d")
|
626 |
chunk = doc.add_chunk(content="xxxxxxx")
|
627 |
chunk.delete()
|
|
|
644 |
```python
|
645 |
from ragflow import RAGFlow
|
646 |
|
647 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
648 |
doc = rag.get_document(id="wdfxb5t547d")
|
649 |
chunk = doc.add_chunk(content="xxxxxxx")
|
650 |
chunk.content = "sdfx"
|
|
|
656 |
## Retrieval
|
657 |
|
658 |
```python
|
659 |
+
RAGFlow.retrieval(question:str, datasets:list[Dataset], document=list[Document]=None, offset:int=0, limit:int=6, similarity_threshold:float=0.1, vector_similarity_weight:float=0.3, top_k:int=1024) -> list[Chunk]
|
660 |
```
|
661 |
|
662 |
### Parameters
|
|
|
665 |
|
666 |
The user query or query keywords. Defaults to `""`.
|
667 |
|
668 |
+
#### datasets: `list[Dataset]`, *Required*
|
669 |
|
670 |
The scope of datasets.
|
671 |
|
672 |
+
#### document: `list[Document]`
|
673 |
|
674 |
The scope of document. `None` means no limitation. Defaults to `None`.
|
675 |
|
|
|
695 |
|
696 |
### Returns
|
697 |
|
698 |
+
list[Chunk]
|
699 |
|
700 |
### Examples
|
701 |
|
702 |
```python
|
703 |
from ragflow import RAGFlow
|
704 |
|
705 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
706 |
ds = rag.get_dataset(name="ragflow")
|
707 |
name = 'ragflow_test.txt'
|
708 |
path = 'test_data/ragflow_test.txt'
|
|
|
733 |
RAGFlow.create_chat(
|
734 |
name: str = "assistant",
|
735 |
avatar: str = "path",
|
736 |
+
knowledgebases: list[DataSet] = ["kb1"],
|
737 |
llm: Chat.LLM = None,
|
738 |
prompt: Chat.Prompt = None
|
739 |
) -> Chat
|
|
|
754 |
|
755 |
The icon of the created chat. Defaults to `"path"`.
|
756 |
|
757 |
+
#### knowledgebases: `list[DataSet]`
|
758 |
|
759 |
Select knowledgebases associated. Defaults to `["kb1"]`.
|
760 |
|
|
|
796 |
```python
|
797 |
from ragflow import RAGFlow
|
798 |
|
799 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
800 |
kb = rag.get_dataset(name="kb_1")
|
801 |
assi = rag.create_chat("Miss R", knowledgebases=[kb])
|
802 |
```
|
|
|
820 |
```python
|
821 |
from ragflow import RAGFlow
|
822 |
|
823 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
824 |
kb = rag.get_knowledgebase(name="kb_1")
|
825 |
assi = rag.create_chat("Miss R", knowledgebases=[kb])
|
826 |
assi.update({"temperature":0.8})
|
|
|
831 |
## Delete chats
|
832 |
|
833 |
```python
|
834 |
+
RAGFlow.delete_chats(ids: list[str] = None)
|
835 |
```
|
836 |
### Parameters
|
837 |
|
|
|
851 |
```python
|
852 |
from ragflow import RAGFlow
|
853 |
|
854 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
855 |
rag.delete_chats(ids=["id_1","id_2"])
|
856 |
```
|
857 |
|
|
|
867 |
desc: bool = True,
|
868 |
id: str = None,
|
869 |
name: str = None
|
870 |
+
) -> list[Chat]
|
871 |
```
|
872 |
|
873 |
### Parameters
|
|
|
910 |
```python
|
911 |
from ragflow import RAGFlow
|
912 |
|
913 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
914 |
for assi in rag.list_chats():
|
915 |
print(assi)
|
916 |
```
|
|
|
940 |
|
941 |
The name of the created session. Defaults to `"New session"`.
|
942 |
|
943 |
+
#### messages: `list[Message]`
|
944 |
|
945 |
The messages of the created session.
|
946 |
- messages cannot be provided.
|
|
|
963 |
```python
|
964 |
from ragflow import RAGFlow
|
965 |
|
966 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
967 |
assi = rag.list_chats(name="Miss R")
|
968 |
assi = assi[0]
|
969 |
sess = assi.create_session()
|
|
|
985 |
```python
|
986 |
from ragflow import RAGFlow
|
987 |
|
988 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
989 |
assi = rag.list_chats(name="Miss R")
|
990 |
assi = assi[0]
|
991 |
sess = assi.create_session("new_session")
|
|
|
1023 |
|
1024 |
The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1025 |
|
1026 |
+
#### reference: `list[Chunk]`
|
1027 |
|
1028 |
The auto-generated reference of the message. Each `chunk` object includes the following attributes:
|
1029 |
|
|
|
1045 |
A similarity score based on vector representations. This score is obtained by converting texts, words, or objects into vectors and then calculating the cosine similarity or other distance measures between these vectors to determine the similarity in vector space. A higher value indicates greater similarity in the vector space. Defaults to `None`. ?????????????????????????????????
|
1046 |
- **term_similarity**: `float`
|
1047 |
The similarity score based on terms or keywords. This score is calculated by comparing the similarity of key terms between texts or datasets, typically measuring how similar two words or phrases are in meaning or context. A higher value indicates a stronger similarity between terms. Defaults to `None`. ???????????????????
|
1048 |
+
- **position**: `list[string]`
|
1049 |
Indicates the position or index of keywords or specific terms within the text. An array is typically used to mark the location of keywords or specific elements, facilitating precise operations or analysis of the text. Defaults to `None`. ??????????????
|
1050 |
|
1051 |
### Examples
|
|
|
1053 |
```python
|
1054 |
from ragflow import RAGFlow
|
1055 |
|
1056 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
1057 |
assi = rag.list_chats(name="Miss R")
|
1058 |
assi = assi[0]
|
1059 |
sess = assi.create_session()
|
|
|
1084 |
desc: bool = True,
|
1085 |
id: str = None,
|
1086 |
name: str = None
|
1087 |
+
) -> list[Session]
|
1088 |
```
|
1089 |
|
1090 |
### Returns
|
1091 |
|
1092 |
+
list[Session]
|
1093 |
description: the List contains information about multiple assistant object, with each dictionary containing information about one assistant.
|
1094 |
|
1095 |
### Examples
|
|
|
1097 |
```python
|
1098 |
from ragflow import RAGFlow
|
1099 |
|
1100 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
1101 |
assi = rag.list_chats(name="Miss R")
|
1102 |
assi = assi[0]
|
1103 |
for sess in assi.list_sessions():
|
|
|
1140 |
## Delete session
|
1141 |
|
1142 |
```python
|
1143 |
+
Chat.delete_sessions(ids:list[str] = None)
|
1144 |
```
|
1145 |
|
1146 |
### Returns
|
|
|
1152 |
```python
|
1153 |
from ragflow import RAGFlow
|
1154 |
|
1155 |
+
rag = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
1156 |
assi = rag.list_chats(name="Miss R")
|
1157 |
assi = assi[0]
|
1158 |
assi.delete_sessions(ids=["id_1","id_2"])
|
1159 |
```
|
1160 |
### Parameters
|
1161 |
+
#### ids: `list[string]`
|
1162 |
IDs of the sessions to be deleted.
|
1163 |
- `None`
|
1164 |
|