imbajin commented on code in PR #27:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/27#discussion_r1464318272


##########
hugegraph-llm/src/hugegraph_llm/operators/llm_op/info_extract.py:
##########
@@ -0,0 +1,274 @@
+# 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.
+
+import re
+from typing import List, Any, Dict
+
+from hugegraph_llm.llms.base import BaseLLM
+from hugegraph_llm.operators.llm_op.unstructured_data_utils import (
+    nodes_text_to_list_of_dict,
+    nodes_schemas_text_to_list_of_dict,
+    relationships_schemas_text_to_list_of_dict,
+    relationships_text_to_list_of_dict,
+)
+
+
+def generate_system_message() -> str:
+    return """You are a data scientist working for a company that is building 
a graph database.
+    Your task is to extract information from data and convert it into a graph 
database. Provide a 
+    set of Nodes in the form [ENTITY_ID, TYPE, PROPERTIES] and a set of 
relationships in the form 
+    [ENTITY_ID_1, RELATIONSHIP, ENTITY_ID_2, PROPERTIES] and a set of 
NodesSchemas in the form [
+    ENTITY_TYPE, PRIMARY_KEY, PROPERTIES] and a set of RelationshipsSchemas in 
the form [
+    ENTITY_TYPE_1, RELATIONSHIP, ENTITY_TYPE_2, PROPERTIES] It is important 
that the ENTITY_ID_1 
+    and ENTITY_ID_2 exists as nodes with a matching ENTITY_ID. If you can't 
pair a relationship 
+    with a pair of nodes don't add it. When you find a node or relationship 
you want to add try 
+    to create a generic TYPE for it that  describes the entity you can also 
think of it as a label.
+
+    Here is an example The input you will be given: Data: Alice lawyer and is 
25 years old and Bob 
+    is her roommate since 2001. Bob works as a journalist. Alice owns a the 
webpage www.alice.com 
+    and Bob owns the webpage www.bob.com. The output you need to provide: 
Nodes: ["Alice", "Person", 
+    {"age": 25, "occupation": "lawyer", "name": "Alice"}], ["Bob", "Person", 
{"occupation": 
+    "journalist", "name": "Bob"}], ["alice.com", "Webpage", {"name": 
"alice.com", 
+    "url": "www.alice.com"}], ["bob.com", "Webpage", {"name": "bob.com", 
"url": "www.bob.com"}] 
+    Relationships: [{"Person": "Alice"}, "roommate", {"Person": "Bob"}, 
{"start": 2021}], 
+    [{"Person": "Alice"}, "owns", {"Webpage": "alice.com"}, {}], [{"Person": 
"Bob"}, "owns",
+     {"Webpage": "bob.com"}, {}] NodesSchemas: ["Person", "name",  {"age": 
"int", 
+     "name": "text", "occupation": 
+    "text"}],  ["Webpage", "name", {"name": "text", "url": "text"}] 
RelationshipsSchemas :["Person", 
+    "roommate", "Person", {"start": "int"}], ["Person", "owns", "Webpage", 
{}]"""

Review Comment:
   Do we have a better way to maintain the default prompt if we make subsequent 
modifications and adjustments



##########
README.md:
##########
@@ -19,6 +19,11 @@ to seamlessly connect with third-party graph-related ML 
frameworks.
 It is used to define graph structures and perform CRUD operations on graph 
data. Both the `hugegraph-llm` and `hugegraph-ml` 
 modules will depend on this foundational library. 
 
+## Contributing
+- Welcome to contribute to HugeGraph, please see 
[Guidelines](https://hugegraph.apache.org/docs/contribution-guidelines/) for 
more information.  
+- Note: It's recommended to use [GitHub Desktop](https://desktop.github.com/) 
to greatly simplify the PR and commit process.  
+- Code format: Please run 
[`./style/code_format_and_analysis.sh`](style/code_format_and_analysis.sh) to 
format your code before submitting a PR.
+

Review Comment:
   ```suggestion
   
   [![contributors 
graph](https://contrib.rocks/image?repo=apache/incubator-hugegraph-ai)](https://github.com/apache/incubator-hugegraph-ai/graphs/contributors)
   ```



-- 
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]

Reply via email to