cecilia-uu commited on
Commit
b802ae5
·
1 Parent(s): 3458ce6

delete SDK repo and edit readme (#1054)

Browse files

### What problem does this PR solve?

delete SDK repo and edit readme

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

SDK/python/README.md DELETED
@@ -1 +0,0 @@
1
- # infinity
 
 
SDK/python/hello_ragflow.py DELETED
@@ -1,3 +0,0 @@
1
- import ragflow
2
-
3
- print(ragflow.__version__)
 
 
 
 
SDK/python/pyproject.toml DELETED
@@ -1,24 +0,0 @@
1
- [project]
2
- name = "ragflow"
3
- version = "0.8.0.dev1"
4
- authors = [
5
- { name = "The RAGFlow Development Team", email = "author@example.com" },
6
- ] # TODO: email
7
- dependencies = ["pytest~=8.2.0"]
8
- description = "ragflow"
9
- readme = "README.md"
10
- requires-python = ">=3.10"
11
- classifiers = [
12
- "Programming Language :: Python :: 3",
13
- "License :: OSI Approved :: Apache License2",
14
- "Operating System :: OS Independent",
15
- ]
16
-
17
- [build-system]
18
- requires = ["setuptools>=61.0", "wheel"]
19
- build-backend = "setuptools.build_meta"
20
-
21
- [project.urls]
22
- "Homepage" = "https://github.com/pypa/sampleproject"
23
- "Bug Tracker" = "https://github.com/pypa/sampleproject/issues"
24
- # TODO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SDK/python/ragflow/__init__.py DELETED
@@ -1,3 +0,0 @@
1
- import importlib.metadata
2
-
3
- __version__ = importlib.metadata.version("ragflow")
 
 
 
 
SDK/python/ragflow/ragflow.py DELETED
@@ -1,28 +0,0 @@
1
- #
2
- # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- import os
17
- import dotenv
18
- import typing
19
- from api.utils.file_utils import get_project_base_directory
20
-
21
-
22
- def get_versions() -> typing.Mapping[str, typing.Any]:
23
- dotenv.load_dotenv(dotenv.find_dotenv())
24
- return dotenv.dotenv_values()
25
-
26
-
27
- def get_rag_version() -> typing.Optional[str]:
28
- return get_versions().get("RAGFLOW_VERSION", "dev")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SDK/python/setup.py DELETED
@@ -1,19 +0,0 @@
1
- # Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- import setuptools
16
-
17
- if __name__ == "__main__":
18
- setuptools.setup(packages=['ragflow'])
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SDK/python/test/test_basic.py DELETED
@@ -1,8 +0,0 @@
1
- from test_sdkbase import TestSdk
2
- import ragflow
3
- import pytest
4
-
5
-
6
- class TestCase(TestSdk):
7
- def test_version(self):
8
- print(ragflow.__version__)
 
 
 
 
 
 
 
 
 
SDK/python/test/test_sdkbase.py DELETED
@@ -1,3 +0,0 @@
1
- class TestSdk():
2
- def test_version(self):
3
- print("test_sdk")
 
 
 
 
sdk/python/README.md CHANGED
@@ -1 +1 @@
1
- # infinity
 
1
+ # ragflow
sdk/python/ragflow/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
  import importlib.metadata
2
 
3
- __version__ = importlib.metadata.version("ragflow")
 
1
  import importlib.metadata
2
 
3
+ __version__ = importlib.metadata.version("ragflow")
sdk/python/ragflow/ragflow.py CHANGED
@@ -15,6 +15,7 @@
15
  #
16
  import os
17
  from abc import ABC
 
18
 
19
 
20
  class RAGFLow(ABC):
@@ -26,4 +27,28 @@ class RAGFLow(ABC):
26
  return name
27
 
28
  def delete_dataset(self, name):
29
- return name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  #
16
  import os
17
  from abc import ABC
18
+ import requests
19
 
20
 
21
  class RAGFLow(ABC):
 
27
  return name
28
 
29
  def delete_dataset(self, name):
30
+ return name
31
+
32
+ def list_dataset(self):
33
+ endpoint = f"{self.base_url}/api/v1/dataset"
34
+ response = requests.get(endpoint)
35
+ if response.status_code == 200:
36
+ return response.json()['datasets']
37
+ else:
38
+ return None
39
+
40
+ def get_dataset(self, dataset_id):
41
+ endpoint = f"{self.base_url}/api/v1/dataset/{dataset_id}"
42
+ response = requests.get(endpoint)
43
+ if response.status_code == 200:
44
+ return response.json()
45
+ else:
46
+ return None
47
+
48
+ def update_dataset(self, dataset_id, params):
49
+ endpoint = f"{self.base_url}/api/v1/dataset/{dataset_id}"
50
+ response = requests.put(endpoint, json=params)
51
+ if response.status_code == 200:
52
+ return True
53
+ else:
54
+ return False
sdk/python/test/test_basic.py CHANGED
@@ -2,9 +2,16 @@ from test_sdkbase import TestSdk
2
  import ragflow
3
  from ragflow.ragflow import RAGFLow
4
  import pytest
 
5
 
6
 
7
  class TestCase(TestSdk):
 
 
 
 
 
 
8
  def test_version(self):
9
  print(ragflow.__version__)
10
 
@@ -12,4 +19,33 @@ class TestCase(TestSdk):
12
  assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
13
 
14
  def test_delete_dataset(self):
15
- assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import ragflow
3
  from ragflow.ragflow import RAGFLow
4
  import pytest
5
+ from unittest.mock import MagicMock
6
 
7
 
8
  class TestCase(TestSdk):
9
+
10
+ @pytest.fixture
11
+ def ragflow_instance(self):
12
+ # Here we create a mock instance of RAGFlow for testing
13
+ return ragflow.ragflow.RAGFLow('123', 'url')
14
+
15
  def test_version(self):
16
  print(ragflow.__version__)
17
 
 
19
  assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
20
 
21
  def test_delete_dataset(self):
22
+ assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
23
+
24
+ def test_list_dataset_success(self, ragflow_instance, monkeypatch):
25
+ # Mocking the response of requests.get method
26
+ mock_response = MagicMock()
27
+ mock_response.status_code = 200
28
+ mock_response.json.return_value = {'datasets': [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]}
29
+
30
+ # Patching requests.get to return the mock_response
31
+ monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
32
+
33
+ # Call the method under test
34
+ result = ragflow_instance.list_dataset()
35
+
36
+ # Assertion
37
+ assert result == [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]
38
+
39
+ def test_list_dataset_failure(self, ragflow_instance, monkeypatch):
40
+ # Mocking the response of requests.get method
41
+ mock_response = MagicMock()
42
+ mock_response.status_code = 404 # Simulating a failed request
43
+
44
+ # Patching requests.get to return the mock_response
45
+ monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
46
+
47
+ # Call the method under test
48
+ result = ragflow_instance.list_dataset()
49
+
50
+ # Assertion
51
+ assert result is None