liuhua
liuhua
commited on
Commit
·
970594e
1
Parent(s):
3f568cf
Update displayed_name to display_name (#4311)
Browse files### What problem does this PR solve?
Update displayed_name to display_name
### Type of change
- [x] Refactoring
Co-authored-by: liuhua <[email protected]>
docs/references/python_api_reference.md
CHANGED
@@ -894,7 +894,7 @@ dataset = rag_object.list_datasets(name="ragflow")
|
|
894 |
dataset = dataset[0]
|
895 |
name = 'ragflow_test.txt'
|
896 |
path = './test_data/ragflow_test.txt'
|
897 |
-
documents =[{"
|
898 |
docs = dataset.upload_documents(documents)
|
899 |
doc = docs[0]
|
900 |
doc.add_chunk(content="This is a chunk addition test")
|
|
|
894 |
dataset = dataset[0]
|
895 |
name = 'ragflow_test.txt'
|
896 |
path = './test_data/ragflow_test.txt'
|
897 |
+
documents =[{"display_name":"test_retrieve_chunks.txt","blob":open(path, "rb").read()}]
|
898 |
docs = dataset.upload_documents(documents)
|
899 |
doc = docs[0]
|
900 |
doc.add_chunk(content="This is a chunk addition test")
|
sdk/python/ragflow_sdk/modules/dataset.py
CHANGED
@@ -36,7 +36,7 @@ class DataSet(Base):
|
|
36 |
|
37 |
def upload_documents(self,document_list: list[dict]):
|
38 |
url = f"/datasets/{self.id}/documents"
|
39 |
-
files = [("file",(ele["
|
40 |
res = self.post(path=url,json=None,files=files)
|
41 |
res = res.json()
|
42 |
if res.get("code") == 0:
|
|
|
36 |
|
37 |
def upload_documents(self,document_list: list[dict]):
|
38 |
url = f"/datasets/{self.id}/documents"
|
39 |
+
files = [("file",(ele["display_name"],ele["blob"])) for ele in document_list]
|
40 |
res = self.post(path=url,json=None,files=files)
|
41 |
res = res.json()
|
42 |
if res.get("code") == 0:
|
sdk/python/test/test_sdk_api/t_chat.py
CHANGED
@@ -5,10 +5,10 @@ def test_create_chat_with_name(get_api_key_fixture):
|
|
5 |
API_KEY = get_api_key_fixture
|
6 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
7 |
kb = rag.create_dataset(name="test_create_chat")
|
8 |
-
|
9 |
with open("test_data/ragflow.txt", "rb") as file:
|
10 |
blob = file.read()
|
11 |
-
document = {"
|
12 |
documents = []
|
13 |
documents.append(document)
|
14 |
docs= kb.upload_documents(documents)
|
@@ -21,10 +21,10 @@ def test_update_chat_with_name(get_api_key_fixture):
|
|
21 |
API_KEY = get_api_key_fixture
|
22 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
23 |
kb = rag.create_dataset(name="test_update_chat")
|
24 |
-
|
25 |
with open("test_data/ragflow.txt", "rb") as file:
|
26 |
blob = file.read()
|
27 |
-
document = {"
|
28 |
documents = []
|
29 |
documents.append(document)
|
30 |
docs = kb.upload_documents(documents)
|
@@ -38,10 +38,10 @@ def test_delete_chats_with_success(get_api_key_fixture):
|
|
38 |
API_KEY = get_api_key_fixture
|
39 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
40 |
kb = rag.create_dataset(name="test_delete_chat")
|
41 |
-
|
42 |
with open("test_data/ragflow.txt", "rb") as file:
|
43 |
blob = file.read()
|
44 |
-
document = {"
|
45 |
documents = []
|
46 |
documents.append(document)
|
47 |
docs = kb.upload_documents(documents)
|
@@ -54,10 +54,10 @@ def test_list_chats_with_success(get_api_key_fixture):
|
|
54 |
API_KEY = get_api_key_fixture
|
55 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
56 |
kb = rag.create_dataset(name="test_list_chats")
|
57 |
-
|
58 |
with open("test_data/ragflow.txt", "rb") as file:
|
59 |
blob = file.read()
|
60 |
-
document = {"
|
61 |
documents = []
|
62 |
documents.append(document)
|
63 |
docs = kb.upload_documents(documents)
|
|
|
5 |
API_KEY = get_api_key_fixture
|
6 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
7 |
kb = rag.create_dataset(name="test_create_chat")
|
8 |
+
display_name = "ragflow.txt"
|
9 |
with open("test_data/ragflow.txt", "rb") as file:
|
10 |
blob = file.read()
|
11 |
+
document = {"display_name":display_name,"blob":blob}
|
12 |
documents = []
|
13 |
documents.append(document)
|
14 |
docs= kb.upload_documents(documents)
|
|
|
21 |
API_KEY = get_api_key_fixture
|
22 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
23 |
kb = rag.create_dataset(name="test_update_chat")
|
24 |
+
display_name = "ragflow.txt"
|
25 |
with open("test_data/ragflow.txt", "rb") as file:
|
26 |
blob = file.read()
|
27 |
+
document = {"display_name": display_name, "blob": blob}
|
28 |
documents = []
|
29 |
documents.append(document)
|
30 |
docs = kb.upload_documents(documents)
|
|
|
38 |
API_KEY = get_api_key_fixture
|
39 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
40 |
kb = rag.create_dataset(name="test_delete_chat")
|
41 |
+
display_name = "ragflow.txt"
|
42 |
with open("test_data/ragflow.txt", "rb") as file:
|
43 |
blob = file.read()
|
44 |
+
document = {"display_name": display_name, "blob": blob}
|
45 |
documents = []
|
46 |
documents.append(document)
|
47 |
docs = kb.upload_documents(documents)
|
|
|
54 |
API_KEY = get_api_key_fixture
|
55 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
56 |
kb = rag.create_dataset(name="test_list_chats")
|
57 |
+
display_name = "ragflow.txt"
|
58 |
with open("test_data/ragflow.txt", "rb") as file:
|
59 |
blob = file.read()
|
60 |
+
document = {"display_name": display_name, "blob": blob}
|
61 |
documents = []
|
62 |
documents.append(document)
|
63 |
docs = kb.upload_documents(documents)
|
sdk/python/test/test_sdk_api/t_chunk.py
CHANGED
@@ -9,7 +9,7 @@ def test_parse_document_with_txt(get_api_key_fixture):
|
|
9 |
name = 'ragflow_test.txt'
|
10 |
with open("test_data/ragflow_test.txt", "rb") as file :
|
11 |
blob = file.read()
|
12 |
-
docs = ds.upload_documents([{"
|
13 |
doc = docs[0]
|
14 |
ds.async_parse_documents(document_ids=[doc.id])
|
15 |
'''
|
@@ -28,7 +28,7 @@ def test_parse_and_cancel_document(get_api_key_fixture):
|
|
28 |
name = 'ragflow_test.txt'
|
29 |
with open("test_data/ragflow_test.txt", "rb") as file :
|
30 |
blob = file.read()
|
31 |
-
docs=ds.upload_documents([{"
|
32 |
doc = docs[0]
|
33 |
ds.async_parse_documents(document_ids=[doc.id])
|
34 |
sleep(1)
|
@@ -43,9 +43,9 @@ def test_bulk_parse_documents(get_api_key_fixture):
|
|
43 |
with open("test_data/ragflow.txt", "rb") as file:
|
44 |
blob = file.read()
|
45 |
documents = [
|
46 |
-
{'
|
47 |
-
{'
|
48 |
-
{'
|
49 |
]
|
50 |
docs = ds.upload_documents(documents)
|
51 |
ids = [doc.id for doc in docs]
|
@@ -70,10 +70,10 @@ def test_list_chunks_with_success(get_api_key_fixture):
|
|
70 |
# chunk_size = 1024 * 1024
|
71 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
72 |
documents = [
|
73 |
-
{'
|
74 |
]
|
75 |
'''
|
76 |
-
documents =[{"
|
77 |
docs = ds.upload_documents(documents)
|
78 |
ids = [doc.id for doc in docs]
|
79 |
ds.async_parse_documents(ids)
|
@@ -100,10 +100,10 @@ def test_add_chunk_with_success(get_api_key_fixture):
|
|
100 |
# chunk_size = 1024 * 1024
|
101 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
102 |
documents = [
|
103 |
-
{'
|
104 |
]
|
105 |
'''
|
106 |
-
documents =[{"
|
107 |
docs = ds.upload_documents(documents)
|
108 |
doc = docs[0]
|
109 |
doc.add_chunk(content="This is a chunk addition test")
|
@@ -119,10 +119,10 @@ def test_delete_chunk_with_success(get_api_key_fixture):
|
|
119 |
# chunk_size = 1024 * 1024
|
120 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
121 |
documents = [
|
122 |
-
{'
|
123 |
]
|
124 |
'''
|
125 |
-
documents =[{"
|
126 |
docs = ds.upload_documents(documents)
|
127 |
doc = docs[0]
|
128 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
@@ -140,10 +140,10 @@ def test_update_chunk_content(get_api_key_fixture):
|
|
140 |
# chunk_size = 1024 * 1024
|
141 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
142 |
documents = [
|
143 |
-
{'
|
144 |
]
|
145 |
'''
|
146 |
-
documents =[{"
|
147 |
docs = ds.upload_documents(documents)
|
148 |
doc = docs[0]
|
149 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
@@ -161,10 +161,10 @@ def test_update_chunk_available(get_api_key_fixture):
|
|
161 |
# chunk_size = 1024 * 1024
|
162 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
163 |
documents = [
|
164 |
-
{'
|
165 |
]
|
166 |
'''
|
167 |
-
documents =[{"
|
168 |
docs = ds.upload_documents(documents)
|
169 |
doc = docs[0]
|
170 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
@@ -183,10 +183,10 @@ def test_retrieve_chunks(get_api_key_fixture):
|
|
183 |
# chunk_size = 1024 * 1024
|
184 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
185 |
documents = [
|
186 |
-
{'
|
187 |
]
|
188 |
'''
|
189 |
-
documents =[{"
|
190 |
docs = ds.upload_documents(documents)
|
191 |
doc = docs[0]
|
192 |
doc.add_chunk(content="This is a chunk addition test")
|
|
|
9 |
name = 'ragflow_test.txt'
|
10 |
with open("test_data/ragflow_test.txt", "rb") as file :
|
11 |
blob = file.read()
|
12 |
+
docs = ds.upload_documents([{"display_name": name, "blob": blob}])
|
13 |
doc = docs[0]
|
14 |
ds.async_parse_documents(document_ids=[doc.id])
|
15 |
'''
|
|
|
28 |
name = 'ragflow_test.txt'
|
29 |
with open("test_data/ragflow_test.txt", "rb") as file :
|
30 |
blob = file.read()
|
31 |
+
docs=ds.upload_documents([{"display_name": name, "blob": blob}])
|
32 |
doc = docs[0]
|
33 |
ds.async_parse_documents(document_ids=[doc.id])
|
34 |
sleep(1)
|
|
|
43 |
with open("test_data/ragflow.txt", "rb") as file:
|
44 |
blob = file.read()
|
45 |
documents = [
|
46 |
+
{'display_name': 'test1.txt', 'blob': blob},
|
47 |
+
{'display_name': 'test2.txt', 'blob': blob},
|
48 |
+
{'display_name': 'test3.txt', 'blob': blob}
|
49 |
]
|
50 |
docs = ds.upload_documents(documents)
|
51 |
ids = [doc.id for doc in docs]
|
|
|
70 |
# chunk_size = 1024 * 1024
|
71 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
72 |
documents = [
|
73 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
74 |
]
|
75 |
'''
|
76 |
+
documents =[{"display_name":"test_list_chunks_with_success.txt","blob":blob}]
|
77 |
docs = ds.upload_documents(documents)
|
78 |
ids = [doc.id for doc in docs]
|
79 |
ds.async_parse_documents(ids)
|
|
|
100 |
# chunk_size = 1024 * 1024
|
101 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
102 |
documents = [
|
103 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
104 |
]
|
105 |
'''
|
106 |
+
documents =[{"display_name":"test_list_chunks_with_success.txt","blob":blob}]
|
107 |
docs = ds.upload_documents(documents)
|
108 |
doc = docs[0]
|
109 |
doc.add_chunk(content="This is a chunk addition test")
|
|
|
119 |
# chunk_size = 1024 * 1024
|
120 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
121 |
documents = [
|
122 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
123 |
]
|
124 |
'''
|
125 |
+
documents =[{"display_name":"test_delete_chunk_with_success.txt","blob":blob}]
|
126 |
docs = ds.upload_documents(documents)
|
127 |
doc = docs[0]
|
128 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
|
|
140 |
# chunk_size = 1024 * 1024
|
141 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
142 |
documents = [
|
143 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
144 |
]
|
145 |
'''
|
146 |
+
documents =[{"display_name":"test_update_chunk_content_with_success.txt","blob":blob}]
|
147 |
docs = ds.upload_documents(documents)
|
148 |
doc = docs[0]
|
149 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
|
|
161 |
# chunk_size = 1024 * 1024
|
162 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
163 |
documents = [
|
164 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
165 |
]
|
166 |
'''
|
167 |
+
documents =[{"display_name":"test_update_chunk_available_with_success.txt","blob":blob}]
|
168 |
docs = ds.upload_documents(documents)
|
169 |
doc = docs[0]
|
170 |
chunk = doc.add_chunk(content="This is a chunk addition test")
|
|
|
183 |
# chunk_size = 1024 * 1024
|
184 |
# chunks = [blob[i:i + chunk_size] for i in range(0, len(blob), chunk_size)]
|
185 |
documents = [
|
186 |
+
{'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks)
|
187 |
]
|
188 |
'''
|
189 |
+
documents =[{"display_name":"test_retrieve_chunks.txt","blob":blob}]
|
190 |
docs = ds.upload_documents(documents)
|
191 |
doc = docs[0]
|
192 |
doc.add_chunk(content="This is a chunk addition test")
|
sdk/python/test/test_sdk_api/t_document.py
CHANGED
@@ -10,8 +10,8 @@ def test_upload_document_with_success(get_api_key_fixture):
|
|
10 |
with open("test_data/ragflow.txt", "rb") as file:
|
11 |
blob_2=file.read()
|
12 |
document_infos = []
|
13 |
-
document_infos.append({"
|
14 |
-
document_infos.append({"
|
15 |
ds.upload_documents(document_infos)
|
16 |
|
17 |
|
@@ -20,7 +20,7 @@ def test_update_document_with_success(get_api_key_fixture):
|
|
20 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
21 |
ds = rag.create_dataset(name="test_update_document")
|
22 |
blob = b"Sample document content for test."
|
23 |
-
document_infos=[{"
|
24 |
docs=ds.upload_documents(document_infos)
|
25 |
doc = docs[0]
|
26 |
doc.update({"chunk_method": "manual", "name": "manual.txt"})
|
@@ -31,7 +31,7 @@ def test_download_document_with_success(get_api_key_fixture):
|
|
31 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
32 |
ds = rag.create_dataset(name="test_download_document")
|
33 |
blob = b"Sample document content for test."
|
34 |
-
document_infos=[{"
|
35 |
docs=ds.upload_documents(document_infos)
|
36 |
doc = docs[0]
|
37 |
with open("test_download.txt","wb+") as file:
|
@@ -43,7 +43,7 @@ def test_list_documents_in_dataset_with_success(get_api_key_fixture):
|
|
43 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
44 |
ds = rag.create_dataset(name="test_list_documents")
|
45 |
blob = b"Sample document content for test."
|
46 |
-
document_infos = [{"
|
47 |
ds.upload_documents(document_infos)
|
48 |
ds.list_documents(keywords="test", page=1, page_size=12)
|
49 |
|
@@ -54,7 +54,7 @@ def test_delete_documents_in_dataset_with_success(get_api_key_fixture):
|
|
54 |
ds = rag.create_dataset(name="test_delete_documents")
|
55 |
name = "test_delete_documents.txt"
|
56 |
blob = b"Sample document content for test."
|
57 |
-
document_infos=[{"
|
58 |
docs = ds.upload_documents(document_infos)
|
59 |
ds.delete_documents([docs[0].id])
|
60 |
|
@@ -65,7 +65,7 @@ def test_upload_and_parse_pdf_documents_with_general_parse_method(get_api_key_fi
|
|
65 |
ds = rag.create_dataset(name="test_pdf_document")
|
66 |
with open("test_data/test.pdf", "rb") as file:
|
67 |
blob=file.read()
|
68 |
-
document_infos = [{"
|
69 |
docs=ds.upload_documents(document_infos)
|
70 |
doc = docs[0]
|
71 |
ds.async_parse_documents([doc.id])
|
@@ -76,7 +76,7 @@ def test_upload_and_parse_docx_documents_with_general_parse_method(get_api_key_f
|
|
76 |
ds = rag.create_dataset(name="test_docx_document")
|
77 |
with open("test_data/test.docx", "rb") as file:
|
78 |
blob=file.read()
|
79 |
-
document_infos = [{"
|
80 |
docs=ds.upload_documents(document_infos)
|
81 |
doc = docs[0]
|
82 |
ds.async_parse_documents([doc.id])
|
@@ -86,7 +86,7 @@ def test_upload_and_parse_excel_documents_with_general_parse_method(get_api_key_
|
|
86 |
ds = rag.create_dataset(name="test_excel_document")
|
87 |
with open("test_data/test.xlsx", "rb") as file:
|
88 |
blob=file.read()
|
89 |
-
document_infos = [{"
|
90 |
docs=ds.upload_documents(document_infos)
|
91 |
doc = docs[0]
|
92 |
ds.async_parse_documents([doc.id])
|
@@ -96,7 +96,7 @@ def test_upload_and_parse_ppt_documents_with_general_parse_method(get_api_key_fi
|
|
96 |
ds = rag.create_dataset(name="test_ppt_document")
|
97 |
with open("test_data/test.ppt", "rb") as file:
|
98 |
blob=file.read()
|
99 |
-
document_infos = [{"
|
100 |
docs=ds.upload_documents(document_infos)
|
101 |
doc = docs[0]
|
102 |
ds.async_parse_documents([doc.id])
|
@@ -106,7 +106,7 @@ def test_upload_and_parse_image_documents_with_general_parse_method(get_api_key_
|
|
106 |
ds = rag.create_dataset(name="test_image_document")
|
107 |
with open("test_data/test.jpg", "rb") as file:
|
108 |
blob=file.read()
|
109 |
-
document_infos = [{"
|
110 |
docs=ds.upload_documents(document_infos)
|
111 |
doc = docs[0]
|
112 |
ds.async_parse_documents([doc.id])
|
@@ -116,7 +116,7 @@ def test_upload_and_parse_txt_documents_with_general_parse_method(get_api_key_fi
|
|
116 |
ds = rag.create_dataset(name="test_txt_document")
|
117 |
with open("test_data/test.txt", "rb") as file:
|
118 |
blob=file.read()
|
119 |
-
document_infos = [{"
|
120 |
docs=ds.upload_documents(document_infos)
|
121 |
doc = docs[0]
|
122 |
ds.async_parse_documents([doc.id])
|
@@ -126,7 +126,7 @@ def test_upload_and_parse_md_documents_with_general_parse_method(get_api_key_fix
|
|
126 |
ds = rag.create_dataset(name="test_md_document")
|
127 |
with open("test_data/test.md", "rb") as file:
|
128 |
blob=file.read()
|
129 |
-
document_infos = [{"
|
130 |
docs=ds.upload_documents(document_infos)
|
131 |
doc = docs[0]
|
132 |
ds.async_parse_documents([doc.id])
|
@@ -137,7 +137,7 @@ def test_upload_and_parse_json_documents_with_general_parse_method(get_api_key_f
|
|
137 |
ds = rag.create_dataset(name="test_json_document")
|
138 |
with open("test_data/test.json", "rb") as file:
|
139 |
blob=file.read()
|
140 |
-
document_infos = [{"
|
141 |
docs=ds.upload_documents(document_infos)
|
142 |
doc = docs[0]
|
143 |
ds.async_parse_documents([doc.id])
|
@@ -149,7 +149,7 @@ def test_upload_and_parse_eml_documents_with_general_parse_method(get_api_key_fi
|
|
149 |
ds = rag.create_dataset(name="test_eml_document")
|
150 |
with open("test_data/test.eml", "rb") as file:
|
151 |
blob=file.read()
|
152 |
-
document_infos = [{"
|
153 |
docs=ds.upload_documents(document_infos)
|
154 |
doc = docs[0]
|
155 |
ds.async_parse_documents([doc.id])
|
@@ -160,7 +160,7 @@ def test_upload_and_parse_html_documents_with_general_parse_method(get_api_key_f
|
|
160 |
ds = rag.create_dataset(name="test_html_document")
|
161 |
with open("test_data/test.html", "rb") as file:
|
162 |
blob=file.read()
|
163 |
-
document_infos = [{"
|
164 |
docs=ds.upload_documents(document_infos)
|
165 |
doc = docs[0]
|
166 |
ds.async_parse_documents([doc.id])
|
|
|
10 |
with open("test_data/ragflow.txt", "rb") as file:
|
11 |
blob_2=file.read()
|
12 |
document_infos = []
|
13 |
+
document_infos.append({"display_name": "test_1.txt","blob": blob})
|
14 |
+
document_infos.append({"display_name": "test_2.txt","blob": blob_2})
|
15 |
ds.upload_documents(document_infos)
|
16 |
|
17 |
|
|
|
20 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
21 |
ds = rag.create_dataset(name="test_update_document")
|
22 |
blob = b"Sample document content for test."
|
23 |
+
document_infos=[{"display_name":"test.txt","blob":blob}]
|
24 |
docs=ds.upload_documents(document_infos)
|
25 |
doc = docs[0]
|
26 |
doc.update({"chunk_method": "manual", "name": "manual.txt"})
|
|
|
31 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
32 |
ds = rag.create_dataset(name="test_download_document")
|
33 |
blob = b"Sample document content for test."
|
34 |
+
document_infos=[{"display_name": "test_1.txt","blob": blob}]
|
35 |
docs=ds.upload_documents(document_infos)
|
36 |
doc = docs[0]
|
37 |
with open("test_download.txt","wb+") as file:
|
|
|
43 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
44 |
ds = rag.create_dataset(name="test_list_documents")
|
45 |
blob = b"Sample document content for test."
|
46 |
+
document_infos = [{"display_name": "test.txt","blob":blob}]
|
47 |
ds.upload_documents(document_infos)
|
48 |
ds.list_documents(keywords="test", page=1, page_size=12)
|
49 |
|
|
|
54 |
ds = rag.create_dataset(name="test_delete_documents")
|
55 |
name = "test_delete_documents.txt"
|
56 |
blob = b"Sample document content for test."
|
57 |
+
document_infos=[{"display_name": name, "blob": blob}]
|
58 |
docs = ds.upload_documents(document_infos)
|
59 |
ds.delete_documents([docs[0].id])
|
60 |
|
|
|
65 |
ds = rag.create_dataset(name="test_pdf_document")
|
66 |
with open("test_data/test.pdf", "rb") as file:
|
67 |
blob=file.read()
|
68 |
+
document_infos = [{"display_name": "test.pdf","blob": blob}]
|
69 |
docs=ds.upload_documents(document_infos)
|
70 |
doc = docs[0]
|
71 |
ds.async_parse_documents([doc.id])
|
|
|
76 |
ds = rag.create_dataset(name="test_docx_document")
|
77 |
with open("test_data/test.docx", "rb") as file:
|
78 |
blob=file.read()
|
79 |
+
document_infos = [{"display_name": "test.docx","blob": blob}]
|
80 |
docs=ds.upload_documents(document_infos)
|
81 |
doc = docs[0]
|
82 |
ds.async_parse_documents([doc.id])
|
|
|
86 |
ds = rag.create_dataset(name="test_excel_document")
|
87 |
with open("test_data/test.xlsx", "rb") as file:
|
88 |
blob=file.read()
|
89 |
+
document_infos = [{"display_name": "test.xlsx","blob": blob}]
|
90 |
docs=ds.upload_documents(document_infos)
|
91 |
doc = docs[0]
|
92 |
ds.async_parse_documents([doc.id])
|
|
|
96 |
ds = rag.create_dataset(name="test_ppt_document")
|
97 |
with open("test_data/test.ppt", "rb") as file:
|
98 |
blob=file.read()
|
99 |
+
document_infos = [{"display_name": "test.ppt","blob": blob}]
|
100 |
docs=ds.upload_documents(document_infos)
|
101 |
doc = docs[0]
|
102 |
ds.async_parse_documents([doc.id])
|
|
|
106 |
ds = rag.create_dataset(name="test_image_document")
|
107 |
with open("test_data/test.jpg", "rb") as file:
|
108 |
blob=file.read()
|
109 |
+
document_infos = [{"display_name": "test.jpg","blob": blob}]
|
110 |
docs=ds.upload_documents(document_infos)
|
111 |
doc = docs[0]
|
112 |
ds.async_parse_documents([doc.id])
|
|
|
116 |
ds = rag.create_dataset(name="test_txt_document")
|
117 |
with open("test_data/test.txt", "rb") as file:
|
118 |
blob=file.read()
|
119 |
+
document_infos = [{"display_name": "test.txt","blob": blob}]
|
120 |
docs=ds.upload_documents(document_infos)
|
121 |
doc = docs[0]
|
122 |
ds.async_parse_documents([doc.id])
|
|
|
126 |
ds = rag.create_dataset(name="test_md_document")
|
127 |
with open("test_data/test.md", "rb") as file:
|
128 |
blob=file.read()
|
129 |
+
document_infos = [{"display_name": "test.md","blob": blob}]
|
130 |
docs=ds.upload_documents(document_infos)
|
131 |
doc = docs[0]
|
132 |
ds.async_parse_documents([doc.id])
|
|
|
137 |
ds = rag.create_dataset(name="test_json_document")
|
138 |
with open("test_data/test.json", "rb") as file:
|
139 |
blob=file.read()
|
140 |
+
document_infos = [{"display_name": "test.json","blob": blob}]
|
141 |
docs=ds.upload_documents(document_infos)
|
142 |
doc = docs[0]
|
143 |
ds.async_parse_documents([doc.id])
|
|
|
149 |
ds = rag.create_dataset(name="test_eml_document")
|
150 |
with open("test_data/test.eml", "rb") as file:
|
151 |
blob=file.read()
|
152 |
+
document_infos = [{"display_name": "test.eml","blob": blob}]
|
153 |
docs=ds.upload_documents(document_infos)
|
154 |
doc = docs[0]
|
155 |
ds.async_parse_documents([doc.id])
|
|
|
160 |
ds = rag.create_dataset(name="test_html_document")
|
161 |
with open("test_data/test.html", "rb") as file:
|
162 |
blob=file.read()
|
163 |
+
document_infos = [{"display_name": "test.html","blob": blob}]
|
164 |
docs=ds.upload_documents(document_infos)
|
165 |
doc = docs[0]
|
166 |
ds.async_parse_documents([doc.id])
|
sdk/python/test/test_sdk_api/t_session.py
CHANGED
@@ -7,10 +7,10 @@ def test_create_session_with_success(get_api_key_fixture):
|
|
7 |
API_KEY = get_api_key_fixture
|
8 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
9 |
kb = rag.create_dataset(name="test_create_session")
|
10 |
-
|
11 |
with open("test_data/ragflow.txt", "rb") as file:
|
12 |
blob = file.read()
|
13 |
-
document = {"
|
14 |
documents = []
|
15 |
documents.append(document)
|
16 |
docs= kb.upload_documents(documents)
|
@@ -24,10 +24,10 @@ def test_create_conversation_with_success(get_api_key_fixture):
|
|
24 |
API_KEY = get_api_key_fixture
|
25 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
26 |
kb = rag.create_dataset(name="test_create_conversation")
|
27 |
-
|
28 |
with open("test_data/ragflow.txt", "rb") as file:
|
29 |
blob = file.read()
|
30 |
-
document = {"
|
31 |
documents = []
|
32 |
documents.append(document)
|
33 |
docs = kb.upload_documents(documents)
|
@@ -46,10 +46,10 @@ def test_delete_sessions_with_success(get_api_key_fixture):
|
|
46 |
API_KEY = get_api_key_fixture
|
47 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
48 |
kb = rag.create_dataset(name="test_delete_session")
|
49 |
-
|
50 |
with open("test_data/ragflow.txt", "rb") as file:
|
51 |
blob = file.read()
|
52 |
-
document = {"
|
53 |
documents = []
|
54 |
documents.append(document)
|
55 |
docs= kb.upload_documents(documents)
|
@@ -64,10 +64,10 @@ def test_update_session_with_name(get_api_key_fixture):
|
|
64 |
API_KEY = get_api_key_fixture
|
65 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
66 |
kb = rag.create_dataset(name="test_update_session")
|
67 |
-
|
68 |
with open("test_data/ragflow.txt", "rb") as file:
|
69 |
blob = file.read()
|
70 |
-
document = {"
|
71 |
documents = []
|
72 |
documents.append(document)
|
73 |
docs = kb.upload_documents(documents)
|
@@ -82,10 +82,10 @@ def test_list_sessions_with_success(get_api_key_fixture):
|
|
82 |
API_KEY = get_api_key_fixture
|
83 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
84 |
kb = rag.create_dataset(name="test_list_session")
|
85 |
-
|
86 |
with open("test_data/ragflow.txt", "rb") as file:
|
87 |
blob = file.read()
|
88 |
-
document = {"
|
89 |
documents = []
|
90 |
documents.append(document)
|
91 |
docs= kb.upload_documents(documents)
|
|
|
7 |
API_KEY = get_api_key_fixture
|
8 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
9 |
kb = rag.create_dataset(name="test_create_session")
|
10 |
+
display_name = "ragflow.txt"
|
11 |
with open("test_data/ragflow.txt", "rb") as file:
|
12 |
blob = file.read()
|
13 |
+
document = {"display_name":display_name,"blob":blob}
|
14 |
documents = []
|
15 |
documents.append(document)
|
16 |
docs= kb.upload_documents(documents)
|
|
|
24 |
API_KEY = get_api_key_fixture
|
25 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
26 |
kb = rag.create_dataset(name="test_create_conversation")
|
27 |
+
display_name = "ragflow.txt"
|
28 |
with open("test_data/ragflow.txt", "rb") as file:
|
29 |
blob = file.read()
|
30 |
+
document = {"display_name": display_name, "blob": blob}
|
31 |
documents = []
|
32 |
documents.append(document)
|
33 |
docs = kb.upload_documents(documents)
|
|
|
46 |
API_KEY = get_api_key_fixture
|
47 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
48 |
kb = rag.create_dataset(name="test_delete_session")
|
49 |
+
display_name = "ragflow.txt"
|
50 |
with open("test_data/ragflow.txt", "rb") as file:
|
51 |
blob = file.read()
|
52 |
+
document = {"display_name":display_name,"blob":blob}
|
53 |
documents = []
|
54 |
documents.append(document)
|
55 |
docs= kb.upload_documents(documents)
|
|
|
64 |
API_KEY = get_api_key_fixture
|
65 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
66 |
kb = rag.create_dataset(name="test_update_session")
|
67 |
+
display_name = "ragflow.txt"
|
68 |
with open("test_data/ragflow.txt", "rb") as file:
|
69 |
blob = file.read()
|
70 |
+
document = {"display_name": display_name, "blob": blob}
|
71 |
documents = []
|
72 |
documents.append(document)
|
73 |
docs = kb.upload_documents(documents)
|
|
|
82 |
API_KEY = get_api_key_fixture
|
83 |
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
84 |
kb = rag.create_dataset(name="test_list_session")
|
85 |
+
display_name = "ragflow.txt"
|
86 |
with open("test_data/ragflow.txt", "rb") as file:
|
87 |
blob = file.read()
|
88 |
+
document = {"display_name":display_name,"blob":blob}
|
89 |
documents = []
|
90 |
documents.append(document)
|
91 |
docs= kb.upload_documents(documents)
|