This is an automated email from the ASF dual-hosted git repository.

ming pushed a commit to branch package
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git

commit 06f7de8eff09b8678f74b5eb35f06ee5d21ff137
Author: simon <[email protected]>
AuthorDate: Fri Mar 8 16:36:19 2024 +0800

    package
---
 hugegraph-llm/MANIFEST.in                          |  1 +
 hugegraph-llm/requirements.txt                     |  2 +-
 hugegraph-llm/setup.py                             | 29 ++++++++++++++++++++++
 .../hugegraph_llm/config}/__init__.py              |  0
 .../src/{ => hugegraph_llm}/config/config.ini      | 14 +++++------
 .../{ => src/hugegraph_llm}/examples/__init__.py   |  0
 .../hugegraph_llm}/examples/build_kg_test.py       |  0
 .../hugegraph_llm}/examples/graph_rag_test.py      |  0
 hugegraph-llm/src/hugegraph_llm/llms/ernie_bot.py  |  4 +--
 .../operators/common_op/nltk_helper.py             |  2 +-
 hugegraph-llm/src/hugegraph_llm/utils/config.py    | 18 +++++++++++---
 .../src/hugegraph_llm/utils/gradio_demo.py         |  4 +--
 hugegraph-python-client/__init__.py                |  0
 hugegraph-python-client/requirements.txt           |  8 +++---
 hugegraph-python-client/setup.py                   | 28 +++++++++++++++++++++
 .../{example => src/pyhugegraph}/__init__.py       |  0
 .../{ => src/pyhugegraph}/example/__init__.py      |  0
 .../pyhugegraph}/example/hugegraph_example.py      |  0
 .../pyhugegraph}/example/hugegraph_test.py         |  0
 19 files changed, 88 insertions(+), 22 deletions(-)

diff --git a/hugegraph-llm/MANIFEST.in b/hugegraph-llm/MANIFEST.in
new file mode 100644
index 0000000..8af6fff
--- /dev/null
+++ b/hugegraph-llm/MANIFEST.in
@@ -0,0 +1 @@
+recursive-include src/hugegraph_llm/config *
diff --git a/hugegraph-llm/requirements.txt b/hugegraph-llm/requirements.txt
index 47a2d23..0e994ef 100644
--- a/hugegraph-llm/requirements.txt
+++ b/hugegraph-llm/requirements.txt
@@ -1,4 +1,4 @@
-openai==0.28.1
+openai
 retry==0.9.2
 tiktoken==0.5.1
 nltk==3.8.1
diff --git a/hugegraph-llm/setup.py b/hugegraph-llm/setup.py
new file mode 100644
index 0000000..9d52b09
--- /dev/null
+++ b/hugegraph-llm/setup.py
@@ -0,0 +1,29 @@
+import setuptools
+from pkg_resources import parse_requirements
+
+with open("README.md", "r", encoding="utf-8") as fh:
+    long_description = fh.read()
+
+with open("requirements.txt", encoding="utf-8") as fp:
+    install_requires = [str(requirement) for requirement in 
parse_requirements(fp)]
+
+setuptools.setup(
+    name="hugegraph-llm",
+    version="1.3.0",
+    author="Apache HugeGraph Team",
+    author_email="[email protected]",
+    install_requires=install_requires,
+    include_package_data=True,
+    description="Integrating Apache HugeGraph with LLM.",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://github.com/incubator-hugegraph-ai";,
+    packages=setuptools.find_packages(where="src", exclude=["tests"]),
+    package_dir={"": "src"},
+    classifiers=[
+        "Programming Language :: Python :: 3",
+        "License :: OSI Approved :: Apache Software License",
+        "Operating System :: OS Independent",
+    ],
+    python_requires=">=3.9",
+)
diff --git a/hugegraph-llm/examples/__init__.py 
b/hugegraph-llm/src/hugegraph_llm/config/__init__.py
similarity index 100%
copy from hugegraph-llm/examples/__init__.py
copy to hugegraph-llm/src/hugegraph_llm/config/__init__.py
diff --git a/hugegraph-llm/src/config/config.ini 
b/hugegraph-llm/src/hugegraph_llm/config/config.ini
similarity index 92%
rename from hugegraph-llm/src/config/config.ini
rename to hugegraph-llm/src/hugegraph_llm/config/config.ini
index 7ff45c4..995d426 100644
--- a/hugegraph-llm/src/config/config.ini
+++ b/hugegraph-llm/src/hugegraph_llm/config/config.ini
@@ -15,6 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
+[llm]
+type = ernie
+api_key = 
+secret_key = 
+llm_url = 
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=
+model_name = wenxin
+max_token = 4000
 
 [hugegraph]
 ip = 127.0.0.1
@@ -23,10 +30,3 @@ user = admin
 pwd = admin
 graph = hugegraph
 
-[llm]
-type = openai
-api_key = xxx
-secret_key = xxx
-llm_url = 
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=
-model_name = gpt-3.5-turbo-16k
-max_token = 4000
diff --git a/hugegraph-llm/examples/__init__.py 
b/hugegraph-llm/src/hugegraph_llm/examples/__init__.py
similarity index 100%
rename from hugegraph-llm/examples/__init__.py
rename to hugegraph-llm/src/hugegraph_llm/examples/__init__.py
diff --git a/hugegraph-llm/examples/build_kg_test.py 
b/hugegraph-llm/src/hugegraph_llm/examples/build_kg_test.py
similarity index 100%
rename from hugegraph-llm/examples/build_kg_test.py
rename to hugegraph-llm/src/hugegraph_llm/examples/build_kg_test.py
diff --git a/hugegraph-llm/examples/graph_rag_test.py 
b/hugegraph-llm/src/hugegraph_llm/examples/graph_rag_test.py
similarity index 100%
rename from hugegraph-llm/examples/graph_rag_test.py
rename to hugegraph-llm/src/hugegraph_llm/examples/graph_rag_test.py
diff --git a/hugegraph-llm/src/hugegraph_llm/llms/ernie_bot.py 
b/hugegraph-llm/src/hugegraph_llm/llms/ernie_bot.py
index c4ec2f2..d0838aa 100644
--- a/hugegraph-llm/src/hugegraph_llm/llms/ernie_bot.py
+++ b/hugegraph-llm/src/hugegraph_llm/llms/ernie_bot.py
@@ -63,9 +63,7 @@ class ErnieBotClient(BaseLLM):
             )
         response_json = json.loads(response.text)
         if "error_code" in response_json:
-            raise Exception(
-                f"Error {response_json['error_code']}: 
{response_json['error_msg']}"
-            )
+            raise Exception(f"Error {response_json['error_code']}: 
{response_json['error_msg']}")
         return response_json["result"]
 
     def generate_streaming(
diff --git a/hugegraph-llm/src/hugegraph_llm/operators/common_op/nltk_helper.py 
b/hugegraph-llm/src/hugegraph_llm/operators/common_op/nltk_helper.py
index eb7b4d2..dc3b1dc 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/common_op/nltk_helper.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/common_op/nltk_helper.py
@@ -77,5 +77,5 @@ class NLTKHelper:
         return str(path)
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     NLTKHelper().stopwords()
diff --git a/hugegraph-llm/src/hugegraph_llm/utils/config.py 
b/hugegraph-llm/src/hugegraph_llm/utils/config.py
index b11585a..aa73fbb 100644
--- a/hugegraph-llm/src/hugegraph_llm/utils/config.py
+++ b/hugegraph-llm/src/hugegraph_llm/utils/config.py
@@ -21,16 +21,26 @@ import os
 
 class Config:
     def __init__(self, config_file=None, section=None):
-        if config_file is None:
-            root_dir = 
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-            config_file = os.path.join(root_dir, "config", "config.ini")
         if section is None:
             raise Exception("config section cannot be none !")
-        self.config_file = config_file
+        self.config_file = self.init_config_file(config_file)
         self.config = configparser.ConfigParser()
         self.config.read(self.config_file)
         self.section = section
 
+    def init_config_file(self, config_file):
+        if config_file is None:
+            root_dir = 
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+            config_file = os.path.join(root_dir, "hugegraph_llm", "config", 
"config.ini")
+
+        if not os.path.exists(config_file):
+            config = configparser.ConfigParser()
+            config.add_section("llm")
+            config.add_section("hugegraph")
+            with open(config_file, "w", encoding="utf-8") as file:
+                config.write(file)
+        return config_file
+
     def update_config(self, updates):
         for key, value in updates.items():
             self.config.set(self.section, key, value)
diff --git a/hugegraph-llm/src/hugegraph_llm/utils/gradio_demo.py 
b/hugegraph-llm/src/hugegraph_llm/utils/gradio_demo.py
index f6122eb..de97074 100644
--- a/hugegraph-llm/src/hugegraph_llm/utils/gradio_demo.py
+++ b/hugegraph-llm/src/hugegraph_llm/utils/gradio_demo.py
@@ -125,7 +125,7 @@ def init_config(
     ip, port, user, pwd, graph, type, api_key, secret_key, llm_url, 
model_name, max_token
 ):
     root_dir = 
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-    config_file = os.path.join(root_dir, "config", "config.ini")
+    config_file = os.path.join(root_dir, "hugegraph_llm", "config", 
"config.ini")
 
     config = Config(config_file=config_file, section="hugegraph")
     config.update_config({"ip": ip, "port": port, "user": user, "pwd": pwd, 
"graph": graph})
@@ -249,7 +249,7 @@ with gr.Blocks() as hugegraph_llm:
     btn = gr.Button("Run gremlin query on HugeGraph")
     btn.click(fn=run_gremlin_query, inputs=inp, outputs=out)  # pylint: 
disable=no-member
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     app = FastAPI()
     app = gr.mount_gradio_app(app, hugegraph_llm, path="/")
     uvicorn.run(app, host="0.0.0.0", port=8001)
diff --git a/hugegraph-python-client/__init__.py 
b/hugegraph-python-client/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/hugegraph-python-client/requirements.txt 
b/hugegraph-python-client/requirements.txt
index 469bab3..781c90c 100644
--- a/hugegraph-python-client/requirements.txt
+++ b/hugegraph-python-client/requirements.txt
@@ -1,4 +1,4 @@
-decorator==5.1.1
-requests==2.31.0
-setuptools==67.6.1
-urllib3==2.0.7
+decorator
+requests
+setuptools
+urllib3
diff --git a/hugegraph-python-client/setup.py b/hugegraph-python-client/setup.py
new file mode 100644
index 0000000..b4f6bbe
--- /dev/null
+++ b/hugegraph-python-client/setup.py
@@ -0,0 +1,28 @@
+import setuptools
+from pkg_resources import parse_requirements
+
+with open("README.md", "r", encoding="utf-8") as fh:
+    long_description = fh.read()
+
+with open("requirements.txt", encoding="utf-8") as fp:
+    install_requires = [str(requirement) for requirement in 
parse_requirements(fp)]
+
+setuptools.setup(
+    name="hugegraph-python",
+    version="1.3.0",
+    author="Apache HugeGraph Team",
+    author_email="[email protected]",
+    install_requires=install_requires,
+    description="A Python SDK for Apache HugeGraph",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://github.com/incubator-hugegraph-ai";,
+    packages=setuptools.find_packages(where="src", exclude=["tests"]),
+    package_dir={"": "src"},
+    classifiers=[
+        "Programming Language :: Python :: 3",
+        "License :: OSI Approved :: Apache Software License",
+        "Operating System :: OS Independent",
+    ],
+    python_requires=">=3.9",
+)
diff --git a/hugegraph-python-client/example/__init__.py 
b/hugegraph-python-client/src/pyhugegraph/__init__.py
similarity index 100%
copy from hugegraph-python-client/example/__init__.py
copy to hugegraph-python-client/src/pyhugegraph/__init__.py
diff --git a/hugegraph-python-client/example/__init__.py 
b/hugegraph-python-client/src/pyhugegraph/example/__init__.py
similarity index 100%
rename from hugegraph-python-client/example/__init__.py
rename to hugegraph-python-client/src/pyhugegraph/example/__init__.py
diff --git a/hugegraph-python-client/example/hugegraph_example.py 
b/hugegraph-python-client/src/pyhugegraph/example/hugegraph_example.py
similarity index 100%
rename from hugegraph-python-client/example/hugegraph_example.py
rename to hugegraph-python-client/src/pyhugegraph/example/hugegraph_example.py
diff --git a/hugegraph-python-client/example/hugegraph_test.py 
b/hugegraph-python-client/src/pyhugegraph/example/hugegraph_test.py
similarity index 100%
rename from hugegraph-python-client/example/hugegraph_test.py
rename to hugegraph-python-client/src/pyhugegraph/example/hugegraph_test.py

Reply via email to