day0n commented on code in PR #269:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/269#discussion_r2228647951


##########
hugegraph-llm/src/hugegraph_llm/config/models/base_prompt_config.py:
##########
@@ -61,71 +69,74 @@ def ensure_yaml_file_exists(self):
                 # Load existing values from the YAML file into the class 
attributes
                 for key, value in data.items():
                     setattr(self, key, value)
+
+            # Check if the language in the .env file matches the language in 
the YAML file        
+            env_lang = self.llm_settings.language.lower() if hasattr(self, 
'llm_settings') and self.llm_settings.language else 'en'
+            yaml_lang = data.get('_language_generated', 'en').lower()
+            
+            if env_lang.strip() != yaml_lang.strip():
+                log.warning(
+                    f"Prompt was changed '.env' language is '{env_lang}', "
+                    f"but '{F_NAME}' was generated for '{yaml_lang}'. "
+                    f"Regenerating the prompt file..."
+                )
+                if self.llm_settings.language.lower() == "cn":
+                    self.answer_prompt = self.answer_prompt_CN
+                    self.extract_graph_prompt = self.extract_graph_prompt_CN
+                    self.gremlin_generate_prompt = 
self.gremlin_generate_prompt_CN
+                    self.keywords_extract_prompt = 
self.keywords_extract_prompt_CN
+                    self.doc_input_text = self.doc_input_text_CN
+                else:
+                    self.answer_prompt = self.answer_prompt_EN 
+                    self.extract_graph_prompt = self.extract_graph_prompt_EN
+                    self.gremlin_generate_prompt = 
self.gremlin_generate_prompt_EN
+                    self.keywords_extract_prompt = 
self.keywords_extract_prompt_EN
+                    self.doc_input_text = self.doc_input_text_EN
         else:
             self.generate_yaml_file()
             log.info("Prompt file '%s' doesn't exist, create it.", 
yaml_file_path)

Review Comment:
   Can but not necessary



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