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


##########
hugegraph-llm/src/hugegraph_llm/config/config_data.py:
##########
@@ -0,0 +1,176 @@
+# 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 os
+from dataclasses import dataclass
+from typing import Literal, Optional
+
+
+@dataclass
+class ConfigData:
+    """LLM settings"""
+
+    # env_path: Optional[str] = ".env"
+    llm_type: Literal["openai", "ollama", "qianfan_wenxin", "zhipu"] = "openai"
+    embedding_type: Optional[Literal["openai", "ollama", "qianfan_wenxin", 
"zhipu"]] = "openai"
+    reranker_type: Optional[Literal["cohere", "siliconflow"]] = None
+    # 1. OpenAI settings
+    openai_api_base: Optional[str] = os.environ.get("OPENAI_BASE_URL", 
"https://api.openai.com/v1";)
+    openai_api_key: Optional[str] = os.environ.get("OPENAI_API_KEY")
+    openai_language_model: Optional[str] = "gpt-4o-mini"
+    openai_embedding_model: Optional[str] = "text-embedding-3-small"
+    openai_max_tokens: int = 4096
+    # 2. Rerank settings
+    cohere_base_url: Optional[str] = os.environ.get("CO_API_URL", 
"https://api.cohere.com/v1/rerank";)
+    reranker_api_key: Optional[str] = None
+    reranker_model: Optional[str] = None
+    # 3. Ollama settings
+    ollama_host: Optional[str] = "127.0.0.1"
+    ollama_port: Optional[int] = 11434
+    ollama_language_model: Optional[str] = None
+    ollama_embedding_model: Optional[str] = None
+    # 4. QianFan/WenXin settings
+    qianfan_api_key: Optional[str] = None
+    qianfan_secret_key: Optional[str] = None
+    qianfan_access_token: Optional[str] = None
+    # 4.1 URL settings
+    qianfan_url_prefix: Optional[str] = 
"https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop";
+    qianfan_chat_url: Optional[str] = qianfan_url_prefix + "/chat/"
+    qianfan_language_model: Optional[str] = "ERNIE-4.0-Turbo-8K"
+    qianfan_embed_url: Optional[str] = qianfan_url_prefix + "/embeddings/"
+    # refer https://cloud.baidu.com/doc/WENXINWORKSHOP/s/alj562vvu to get more 
details
+    qianfan_embedding_model: Optional[str] = "embedding-v1"
+    # TODO: To be confirmed, whether to configure
+    # 5. ZhiPu(GLM) settings
+    zhipu_api_key: Optional[str] = None
+    zhipu_language_model: Optional[str] = "glm-4"
+    zhipu_embedding_model: Optional[str] = "embedding-2"
+
+    """HugeGraph settings"""
+    graph_ip: Optional[str] = "127.0.0.1"
+    graph_port: Optional[str] = "8080"
+    graph_name: Optional[str] = "hugegraph"
+    graph_user: Optional[str] = "admin"
+    graph_pwd: Optional[str] = "xxx"
+    graph_space: Optional[str] = None
+    
+
+# Additional static content like PromptConfig
+class PromptData:
+
+    custom_related_information = """just for test
+hello!"""
+
+    question = """Tell me about Sarah."""
+
+    # Data is detached from 
hugegraph-llm/src/hugegraph_llm/operators/llm_op/property_graph_extract.py
+    schema_example_prompt = """## Main Task
+Given the following graph schema and a piece of text, your task is to analyze 
the text and extract information that fits into the schema's structure, 
formatting the information into vertices and edges as specified.
+## Basic Rules
+### Schema Format
+Graph Schema:
+- Vertices: [List of vertex labels and their properties]
+- Edges: [List of edge labels, their source and target vertex labels, and 
properties]
+### Content Rule
+Please read the provided text carefully and identify any information that 
corresponds to the vertices and edges defined in the schema. For each piece of 
information that matches a vertex or edge, format it according to the following 
JSON structures:
+#### Vertex Format:
+{"id":"vertexLabelID:entityName","label":"vertexLabel","type":"vertex","properties":{"propertyName":"propertyValue",
 ...}}
+#### Edge Format:
+{"label":"edgeLabel","type":"edge","outV":"sourceVertexId","outVLabel":"sourceVertexLabel","inV":"targetVertexId","inVLabel":"targetVertexLabel","properties":{"propertyName":"propertyValue",...}}
+Also follow the rules: 
+1. Don't extract property fields that do not exist in the given schema
+2. Ensure the extracted property is in the same type as the schema (like 'age' 
should be a number)
+3. If there are multiple primary keys, the strategy for generating VID is: 
vertexlabelID:pk1!pk2!pk3 (pk means primary key, and '!' is the separator)

Review Comment:
   read the config/str from `config_prompt.yaml` directly?
   
   (seems no need to store them again)



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