cecilia-uu
cecilia-uu
commited on
Commit
·
c881efa
1
Parent(s):
48dcb0f
create the python sdk to return version (#1039)
Browse files### What problem does this PR solve?
Create python SDK to return the version of RAGFlow.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
---------
Co-authored-by: cecilia-uu <konghui1996@163.com>
- .gitignore +7 -1
- SDK/python/README.md +1 -0
- SDK/python/hello_ragflow.py +3 -0
- SDK/python/pyproject.toml +24 -0
- SDK/python/ragflow/__init__.py +3 -0
- SDK/python/ragflow/ragflow.py +28 -0
- SDK/python/setup.py +19 -0
- SDK/python/test/test_basic.py +8 -0
- SDK/python/test/test_sdkbase.py +3 -0
.gitignore
CHANGED
@@ -29,4 +29,10 @@ Cargo.lock
|
|
29 |
docker/ragflow-logs/
|
30 |
/flask_session
|
31 |
/logs
|
32 |
-
rag/res/deepdoc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
docker/ragflow-logs/
|
30 |
/flask_session
|
31 |
/logs
|
32 |
+
rag/res/deepdoc
|
33 |
+
|
34 |
+
# Exclude sdk generated files
|
35 |
+
SDK/python/ragflow.egg-info/
|
36 |
+
SDK/python/build/
|
37 |
+
SDK/python/dist/
|
38 |
+
SDK/python/ragflow_sdk.egg-info/
|
SDK/python/README.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# infinity
|
SDK/python/hello_ragflow.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import ragflow
|
2 |
+
|
3 |
+
print(ragflow.__version__)
|
SDK/python/pyproject.toml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import importlib.metadata
|
2 |
+
|
3 |
+
__version__ = importlib.metadata.version("ragflow")
|
SDK/python/ragflow/ragflow.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
class TestSdk():
|
2 |
+
def test_version(self):
|
3 |
+
print("test_sdk")
|