mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 19:49:02 +08:00
delete SDK repo and edit readme (#1054)
### What problem does this PR solve? delete SDK repo and edit readme ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
037657c1ce
commit
8295979bb2
@ -1 +0,0 @@
|
|||||||
# infinity
|
|
@ -1,3 +0,0 @@
|
|||||||
import ragflow
|
|
||||||
|
|
||||||
print(ragflow.__version__)
|
|
@ -1,24 +0,0 @@
|
|||||||
[project]
|
|
||||||
name = "ragflow"
|
|
||||||
version = "0.8.0.dev1"
|
|
||||||
authors = [
|
|
||||||
{ name = "The RAGFlow Development Team", email = "author@example.com" },
|
|
||||||
] # 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
|
|
@ -1,3 +0,0 @@
|
|||||||
import importlib.metadata
|
|
||||||
|
|
||||||
__version__ = importlib.metadata.version("ragflow")
|
|
@ -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")
|
|
@ -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'])
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
from test_sdkbase import TestSdk
|
|
||||||
import ragflow
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
class TestCase(TestSdk):
|
|
||||||
def test_version(self):
|
|
||||||
print(ragflow.__version__)
|
|
@ -1,3 +0,0 @@
|
|||||||
class TestSdk():
|
|
||||||
def test_version(self):
|
|
||||||
print("test_sdk")
|
|
@ -1 +1 @@
|
|||||||
# infinity
|
# ragflow
|
@ -1,3 +1,3 @@
|
|||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
|
|
||||||
__version__ = importlib.metadata.version("ragflow")
|
__version__ = importlib.metadata.version("ragflow")
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class RAGFLow(ABC):
|
class RAGFLow(ABC):
|
||||||
@ -26,4 +27,28 @@ class RAGFLow(ABC):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def delete_dataset(self, name):
|
def delete_dataset(self, name):
|
||||||
return name
|
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
|
@ -2,9 +2,16 @@ from test_sdkbase import TestSdk
|
|||||||
import ragflow
|
import ragflow
|
||||||
from ragflow.ragflow import RAGFLow
|
from ragflow.ragflow import RAGFLow
|
||||||
import pytest
|
import pytest
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
|
||||||
class TestCase(TestSdk):
|
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):
|
def test_version(self):
|
||||||
print(ragflow.__version__)
|
print(ragflow.__version__)
|
||||||
|
|
||||||
@ -12,4 +19,33 @@ class TestCase(TestSdk):
|
|||||||
assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
|
assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
|
||||||
|
|
||||||
def test_delete_dataset(self):
|
def test_delete_dataset(self):
|
||||||
assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user