mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
create and update dataset (#2110)
### What problem does this PR solve? Added the ability to create and update dataset for SDK ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: root <root@xwg> Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from ragflow import RAGFlow
|
||||
from ragflow import RAGFlow, DataSet
|
||||
|
||||
from common import API_KEY, HOST_ADDRESS
|
||||
from test_sdkbase import TestSdk
|
||||
@ -6,18 +6,27 @@ from test_sdkbase import TestSdk
|
||||
|
||||
class TestDataset(TestSdk):
|
||||
def test_create_dataset_with_success(self):
|
||||
"""
|
||||
Test creating dataset with success
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("God")
|
||||
assert ds is not None, "The dataset creation failed, returned None."
|
||||
assert ds.name == "God", "Dataset name does not match."
|
||||
if isinstance(ds, DataSet):
|
||||
assert ds.name == "God", "Name does not match."
|
||||
else:
|
||||
assert False, f"Failed to create dataset, error: {ds}"
|
||||
|
||||
def test_delete_one_file(self):
|
||||
def test_update_dataset_with_success(self):
|
||||
"""
|
||||
Test deleting one file with success.
|
||||
Test updating dataset with success.
|
||||
"""
|
||||
rag = RAGFlow(API_KEY, HOST_ADDRESS)
|
||||
ds = rag.create_dataset("ABC")
|
||||
assert ds is not None, "Failed to create dataset"
|
||||
assert ds.name == "ABC", "Dataset name mismatch"
|
||||
delete_result = ds.delete()
|
||||
assert delete_result is True, "Failed to delete dataset"
|
||||
if isinstance(ds, DataSet):
|
||||
assert ds.name == "ABC", "Name does not match."
|
||||
ds.name = 'DEF'
|
||||
res = ds.save()
|
||||
assert res is True, f"Failed to update dataset, error: {res}"
|
||||
|
||||
else:
|
||||
assert False, f"Failed to create dataset, error: {ds}"
|
||||
Reference in New Issue
Block a user