Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

delete SDK repo and edit readme (#1054)

cecilia-uu8295979bb251
diff --git a/SDK/python/README.md b/SDK/python/README.md
deleted file mode 100644
index 9849363844..0000000000
--- a/SDK/python/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# infinity
\ No newline at end of file
diff --git a/SDK/python/hello_ragflow.py b/SDK/python/hello_ragflow.py
deleted file mode 100644
index d652da85da..0000000000
--- a/SDK/python/hello_ragflow.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import ragflow
-
-print(ragflow.__version__)
\ No newline at end of file
diff --git a/SDK/python/pyproject.toml b/SDK/python/pyproject.toml
deleted file mode 100644
index 54b44f4822..0000000000
--- a/SDK/python/pyproject.toml
+++ /dev/null
@@ -1,24 +0,0 @@
-[project]
-name = "ragflow"
-version = "0.8.0.dev1"
-authors = [
- { name = "The RAGFlow Development Team", email = "[email protected]" },
-] # TODO: email
-dependencies = ["pytest~=8.2.0"]
-description = "ragflow"
-readme = "README.md"
-requires-python = ">=3.10"
-classifiers = [
- "Programming Language :: Python :: 3",
- "License :: OSI Approved :: Apache License2",
- "Operating System :: OS Independent",
-]
-
-[build-system]
-requires = ["setuptools>=61.0", "wheel"]
-build-backend = "setuptools.build_meta"
-
-[project.urls]
-"Homepage" = "https://github.com/pypa/sampleproject"
-"Bug Tracker" = "https://github.com/pypa/sampleproject/issues"
-# TODO
\ No newline at end of file
diff --git a/SDK/python/ragflow/__init__.py b/SDK/python/ragflow/__init__.py
deleted file mode 100644
index 35019df131..0000000000
--- a/SDK/python/ragflow/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import importlib.metadata
-
-__version__ = importlib.metadata.version("ragflow")
\ No newline at end of file
diff --git a/SDK/python/ragflow/ragflow.py b/SDK/python/ragflow/ragflow.py
deleted file mode 100644
index 331a5ced13..0000000000
--- a/SDK/python/ragflow/ragflow.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-import dotenv
-import typing
-from api.utils.file_utils import get_project_base_directory
-
-
-def get_versions() -> typing.Mapping[str, typing.Any]:
- dotenv.load_dotenv(dotenv.find_dotenv())
- return dotenv.dotenv_values()
-
-
-def get_rag_version() -> typing.Optional[str]:
- return get_versions().get("RAGFLOW_VERSION", "dev")
\ No newline at end of file
diff --git a/SDK/python/setup.py b/SDK/python/setup.py
deleted file mode 100644
index 1ce9854c43..0000000000
--- a/SDK/python/setup.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import setuptools
-
-if __name__ == "__main__":
- setuptools.setup(packages=['ragflow'])
-
diff --git a/SDK/python/test/test_basic.py b/SDK/python/test/test_basic.py
deleted file mode 100644
index 1673e389e9..0000000000
--- a/SDK/python/test/test_basic.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from test_sdkbase import TestSdk
-import ragflow
-import pytest
-
-
-class TestCase(TestSdk):
- def test_version(self):
- print(ragflow.__version__)
\ No newline at end of file
diff --git a/SDK/python/test/test_sdkbase.py b/SDK/python/test/test_sdkbase.py
deleted file mode 100644
index 584dbbc4f1..0000000000
--- a/SDK/python/test/test_sdkbase.py
+++ /dev/null
@@ -1,3 +0,0 @@
-class TestSdk():
- def test_version(self):
- print("test_sdk")
diff --git a/sdk/python/README.md b/sdk/python/README.md
index 9849363844..d4964be692 100644
--- a/sdk/python/README.md
+++ b/sdk/python/README.md
@@ -1 +1 @@
-# infinity
\ No newline at end of file
+# ragflow
\ No newline at end of file
diff --git a/sdk/python/ragflow/__init__.py b/sdk/python/ragflow/__init__.py
index 35019df131..889b8322de 100644
--- a/sdk/python/ragflow/__init__.py
+++ b/sdk/python/ragflow/__init__.py
@@ -1,3 +1,3 @@
import importlib.metadata
-__version__ = importlib.metadata.version("ragflow")
\ No newline at end of file
+__version__ = importlib.metadata.version("ragflow")
diff --git a/sdk/python/ragflow/ragflow.py b/sdk/python/ragflow/ragflow.py
index 4aefaf3b6c..f25ca3fac2 100644
--- a/sdk/python/ragflow/ragflow.py
+++ b/sdk/python/ragflow/ragflow.py
@@ -15,6 +15,7 @@
#
import os
from abc import ABC
+import requests
class RAGFLow(ABC):
@@ -26,4 +27,28 @@ class RAGFLow(ABC):
return name
def delete_dataset(self, name):
- return name
\ No newline at end of file
+ return name
+
+ def list_dataset(self):
+ endpoint = f"{self.base_url}/api/v1/dataset"
+ response = requests.get(endpoint)
+ if response.status_code == 200:
+ return response.json()['datasets']
+ else:
+ return None
+
+ def get_dataset(self, dataset_id):
+ endpoint = f"{self.base_url}/api/v1/dataset/{dataset_id}"
+ response = requests.get(endpoint)
+ if response.status_code == 200:
+ return response.json()
+ else:
+ return None
+
+ def update_dataset(self, dataset_id, params):
+ endpoint = f"{self.base_url}/api/v1/dataset/{dataset_id}"
+ response = requests.put(endpoint, json=params)
+ if response.status_code == 200:
+ return True
+ else:
+ return False
\ No newline at end of file
diff --git a/sdk/python/test/test_basic.py b/sdk/python/test/test_basic.py
index 9bae8e4cf7..8774c5c38e 100644
--- a/sdk/python/test/test_basic.py
+++ b/sdk/python/test/test_basic.py
@@ -2,9 +2,16 @@ from test_sdkbase import TestSdk
import ragflow
from ragflow.ragflow import RAGFLow
import pytest
+from unittest.mock import MagicMock
class TestCase(TestSdk):
+
+ @pytest.fixture
+ def ragflow_instance(self):
+ # Here we create a mock instance of RAGFlow for testing
+ return ragflow.ragflow.RAGFLow('123', 'url')
+
def test_version(self):
print(ragflow.__version__)
@@ -12,4 +19,33 @@ class TestCase(TestSdk):
assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
def test_delete_dataset(self):
- assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
\ No newline at end of file
+ assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
+
+ def test_list_dataset_success(self, ragflow_instance, monkeypatch):
+ # Mocking the response of requests.get method
+ mock_response = MagicMock()
+ mock_response.status_code = 200
+ mock_response.json.return_value = {'datasets': [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]}
+
+ # Patching requests.get to return the mock_response
+ monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
+
+ # Call the method under test
+ result = ragflow_instance.list_dataset()
+
+ # Assertion
+ assert result == [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]
+
+ def test_list_dataset_failure(self, ragflow_instance, monkeypatch):
+ # Mocking the response of requests.get method
+ mock_response = MagicMock()
+ mock_response.status_code = 404 # Simulating a failed request
+
+ # Patching requests.get to return the mock_response
+ monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
+
+ # Call the method under test
+ result = ragflow_instance.list_dataset()
+
+ # Assertion
+ assert result is None