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

jin pushed a commit to branch py-client-new
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git

commit 4d8ee0842be6436ada8192b856d4e1ec242bb013
Author: imbajin <[email protected]>
AuthorDate: Wed Aug 7 19:05:05 2024 +0800

    chore(llm): prepare for the new py-client & api
---
 hugegraph-llm/src/hugegraph_llm/api/__init__.py      | 16 ++++++++++++++++
 hugegraph-llm/src/hugegraph_llm/api/rag_api.py       | 16 ++++++++++++++++
 hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py | 10 ++++++----
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/hugegraph-llm/src/hugegraph_llm/api/__init__.py 
b/hugegraph-llm/src/hugegraph_llm/api/__init__.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/hugegraph-llm/src/hugegraph_llm/api/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
diff --git a/hugegraph-llm/src/hugegraph_llm/api/rag_api.py 
b/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
diff --git a/hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py 
b/hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py
index 08a0d2d..82ea5ea 100644
--- a/hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py
+++ b/hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py
@@ -50,6 +50,7 @@ def convert_bool_str(string):
     raise gr.Error(f"Invalid boolean string: {string}")
 
 
+# TODO: support rest api for the functions below (Later -> function_call)
 def graph_rag(text: str, raw_answer: str, vector_only_answer: str,
               graph_only_answer: str, graph_vector_answer):
     vector_search = convert_bool_str(vector_only_answer) or 
convert_bool_str(graph_vector_answer)
@@ -319,7 +320,7 @@ if __name__ == "__main__":
 
 
         gr.Markdown(
-            """## 1. build knowledge graph
+            """## 1. Build KG(graph) & vector/index
 - Document: Input document file which should be TXT or DOCX.
 - Schema: Accepts two types of text as below:
     - User-defined JSON format Schema.
@@ -392,7 +393,7 @@ if __name__ == "__main__":
             outputs=out
         )
 
-        gr.Markdown("""## 2. Retrieval augmented generation by hugegraph""")
+        gr.Markdown("""## 2. RAG Answer by HugeGraph""")
         with gr.Row():
             with gr.Column(scale=2):
                 inp = gr.Textbox(value="Tell me about Sarah.", 
label="Question")
@@ -410,11 +411,12 @@ if __name__ == "__main__":
                 graph_vector_radio = gr.Radio(choices=["true", "false"], 
value="false",
                                               label="Graph-Vector answer")
                 btn = gr.Button("Retrieval augmented generation")
-        btn.click(fn=graph_rag, inputs=[inp, raw_radio, vector_only_radio, 
graph_only_radio,  # pylint: disable=no-member
+        btn.click(fn=graph_rag, inputs=[inp, raw_radio,
+                                        vector_only_radio, graph_only_radio,  
# pylint: disable=no-member
                                         graph_vector_radio],
                   outputs=[raw_out, vector_only_out, graph_only_out, 
graph_vector_out])
 
-        gr.Markdown("""## 3. Others """)
+        gr.Markdown("""## 3. Other function """)
         with gr.Row():
             inp = []
             out = gr.Textbox(label="Output", show_copy_button=True)

Reply via email to