liuxiaocs7 commented on code in PR #27:
URL:
https://github.com/apache/incubator-hugegraph-ai/pull/27#discussion_r1461745997
##########
hugegraph-llm/examples/graph_rag_test.py:
##########
@@ -70,45 +89,45 @@ def prepare_data():
"user": "admin", # default to "admin" if not set
"pwd": "admin", # default to "admin" if not set
"graph": "hugegraph", # default to "hugegraph" if not set
-
# query question
"query": "Tell me about Al Pacino.", # must be set
-
# keywords extraction
"max_keywords": 5, # default to 5 if not set
"language": "english", # default to "english" if not set
-
# graph rag query
"prop_to_match": "name", # default to None if not set
"max_deep": 2, # default to 2 if not set
"max_items": 30, # default to 30 if not set
-
# print intermediate processes result
"verbose": True, # default to False if not set
}
- result = graph_rag \
- .extract_keyword() \
- .query_graph_for_rag() \
- .synthesize_answer() \
+ result = (
+ graph_rag.extract_keyword()
+ .query_graph_for_rag()
+ .synthesize_answer()
.run(**context)
+ )
print(f"Query:\n- {context['query']}")
print(f"Answer:\n- {result['answer']}")
print("--------------------------------------------------------")
# configure operator with parameters
- graph_client = PyHugeClient(
- "127.0.0.1", 18080, "hugegraph", "admin", "admin"
+ graph_client = PyHugeClient("127.0.0.1", 18080, "hugegraph", "admin",
"admin")
Review Comment:
```suggestion
graph_client = PyHugeClient("127.0.0.1", 8080, "hugegraph", "admin",
"admin")
```
same above
##########
hugegraph-llm/examples/graph_rag_test.py:
##########
@@ -18,42 +18,61 @@
import os
-from hugegraph_llm.operators.graph_rag_operator import GraphRAG
+from hugegraph_llm.operators.graph_rag_task import GraphRAG
from pyhugegraph.client import PyHugeClient
def prepare_data():
- client = PyHugeClient(
- "127.0.0.1", 18080, "hugegraph", "admin", "admin"
- )
+ client = PyHugeClient("127.0.0.1", 18080, "hugegraph", "admin", "admin")
Review Comment:
```suggestion
client = PyHugeClient("127.0.0.1", 8080, "hugegraph", "admin", "admin")
```
better to use default `8080` as example? because docker hubble doc use this
as default now: https://hub.docker.com/r/hugegraph/hubble
##########
hugegraph-llm/examples/build_kg_test.py:
##########
@@ -40,10 +31,13 @@
" their distinctive digital presence through their respective
webpages, showcasing their"
" varied interests and experiences."
)
- builder = KgBuilder(default_llm)
+ builder = KgConstructionTask(default_llm)
+
+ # spo triple extract
+
builder.spo_triple_extract(TEXT).print_result().commit_to_hugegraph(spo=True).run()
# build kg with only text
-
builder.parse_text_to_data(TEXT).disambiguate_data().commit_data_to_kg().run()
- # build kg with text and schemas
+
builder.info_extract(TEXT).word_sense_disambiguation().commit_to_hugegraph().run()
+ # # build kg with text and schemas
Review Comment:
```suggestion
# build kg with text and schemas
```
##########
hugegraph-llm/src/hugegraph_llm/operators/kg_construction_task.py:
##########
@@ -0,0 +1,63 @@
+# 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.
+
+
+from hugegraph_llm.llms.base import BaseLLM
+from hugegraph_llm.operators.common_op.print_result import PrintResult
+from hugegraph_llm.operators.hugegraph_op.commit_to_hugegraph import
CommitDataToKg, CommitSPOToKg
+from hugegraph_llm.operators.llm_op.disambiguate_data import DisambiguateData
+from hugegraph_llm.operators.llm_op.info_extract import (
+ InfoExtract,
+)
Review Comment:
extra `()`?
##########
hugegraph-llm/src/hugegraph_llm/llms/init_llm.py:
##########
@@ -0,0 +1,49 @@
+# 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.
+
+from hugegraph_llm.llms.openai import OpenAIChat
+from hugegraph_llm.llms.wenxinyiyan import WenXinYiYanClient
+from hugegraph_llm.utils.config import Config
+from hugegraph_llm.utils.constants import Constants
+
+
+class LLMs:
+ def __init__(self):
+ self.config = Config(section=Constants.LLM_CONFIG)
+ self.config.get_llm_type()
+
+ def get_llm(self):
+ if self.config.get_llm_type() == "wenxinyiyan":
+ return WenXinYiYanClient()
+ if self.config.get_llm_type() == "openai":
+ return OpenAIChat(
+ api_key=self.config.get_llm_api_key(),
+ model_name="gpt-3.5-turbo-16k",
+ max_tokens=4000,
Review Comment:
Does these need to be made configurable?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]