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


##########
hugegraph-llm/src/hugegraph_llm/config/config.py:
##########
@@ -125,3 +85,46 @@ def read_dotenv() -> dict[str, Optional[str]]:
         if key not in os.environ:
             os.environ[key] = value or ""
     return env_config
+
+
+class PromptConfig(PromptData):
+
+    def __init__(self):
+        self.ensure_yaml_file_exists()
+
+    def ensure_yaml_file_exists(self):
+        if os.path.exists(yaml_file_path):
+            print(f"File '{yaml_file_path}' exists, reading content.")
+            with open(yaml_file_path, "r") as file:
+                data = yaml.safe_load(file)
+                # Load existing values from the YAML file into the class 
attributes
+                for key, value in data.items():
+                    setattr(self, key, value)
+        else:
+            print(f"File '{yaml_file_path}' does not exist, creating it.")
+            self.save_to_yaml()
+
+    def save_to_yaml(self):
+        indented_schema = "\n".join([f"  {line}" for line in 
self.rag_schema.splitlines()])
+        indented_example_prompt = "\n".join([f"    {line}" for line in 
self.schema_example_prompt.splitlines()])
+        indented_docs_build_rag = "\n".join([f"    {line}" for line in 
self.docs_build_rag.splitlines()])
+        
+        # This can be extended to add storage fields according to the data 
needs to be stored
+        yaml_content = f"""{self.apache_license_header}
+
+rag_schema: |
+{indented_schema}
+
+schema_example_prompt: |
+{indented_example_prompt}
+
+docs_build_rag: |
+{indented_docs_build_rag}
+        """
+        with open(yaml_file_path, 'w') as file:
+            file.write(yaml_content)
+        print(f"YAML file '{yaml_file_path}' updated successfully.")
+
+    def update_yaml_file(self):
+        print(f"Updating '{yaml_file_path}' with the latest attributes.")
+        self.save_to_yaml()

Review Comment:
   a new line is needed



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