cecilia-uu
		
	commited on
		
		
					Commit 
							
							·
						
						9d11681
	
1
								Parent(s):
							
							72605cf
								
Update SDK->sdk, and add create_dataset (#1047)
Browse files### What problem does this PR solve?
Add create_dataset method, test for it, and update SDK->sdk.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Signed-off-by: cecilia-uu <[email protected]>
- .gitignore +4 -4
- 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 +27 -0
- sdk/python/setup.py +19 -0
- sdk/python/test/test_basic.py +12 -0
- sdk/python/test/test_sdkbase.py +3 -0
    	
        .gitignore
    CHANGED
    
    | @@ -32,7 +32,7 @@ docker/ragflow-logs/ | |
| 32 | 
             
            rag/res/deepdoc
         | 
| 33 |  | 
| 34 | 
             
            # Exclude sdk generated files
         | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
|  | |
| 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 = "[email protected]" },
         | 
| 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,27 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 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 | 
            +
            from abc import ABC
         | 
| 18 | 
            +
             | 
| 19 | 
            +
             | 
| 20 | 
            +
            class RAGFLow(ABC):
         | 
| 21 | 
            +
                def __init__(self, user_key, base_url):
         | 
| 22 | 
            +
                    self.user_key = user_key
         | 
| 23 | 
            +
                    self.base_url = base_url
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def create_dataset(self, name):
         | 
| 26 | 
            +
                    return name
         | 
| 27 | 
            +
             | 
    	
        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,12 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            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 | 
            +
             | 
| 11 | 
            +
                def test_create_dataset(self):
         | 
| 12 | 
            +
                    assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
         | 
    	
        sdk/python/test/test_sdkbase.py
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            class TestSdk():
         | 
| 2 | 
            +
                def test_version(self):
         | 
| 3 | 
            +
                    print("test_sdk")
         |