in hugegraph-llm/src/hugegraph_llm/config/models/base_prompt_config.py [0:0]
def save_to_yaml(self):
indented_schema = "\n".join([f" {line}" for line in self.graph_schema.splitlines()])
indented_text2gql_schema = "\n".join([f" {line}" for line in self.text2gql_graph_schema.splitlines()])
indented_gremlin_prompt = "\n".join([f" {line}" for line in self.gremlin_generate_prompt.splitlines()])
indented_example_prompt = "\n".join([f" {line}" for line in self.extract_graph_prompt.splitlines()])
indented_question = "\n".join([f" {line}" for line in self.default_question.splitlines()])
indented_custom_related_information = (
"\n".join([f" {line}" for line in self.custom_rerank_info.splitlines()])
)
indented_default_answer_template = "\n".join([f" {line}" for line in self.answer_prompt.splitlines()])
indented_keywords_extract_template = (
"\n".join([f" {line}" for line in self.keywords_extract_prompt.splitlines()])
)
indented_doc_input_text = "\n".join([f" {line}" for line in self.doc_input_text.splitlines()])
# This can be extended to add storage fields according to the data needs to be stored
yaml_content = f"""graph_schema: |
{indented_schema}
text2gql_graph_schema: |
{indented_text2gql_schema}
extract_graph_prompt: |
{indented_example_prompt}
default_question: |
{indented_question}
custom_rerank_info: |
{indented_custom_related_information}
answer_prompt: |
{indented_default_answer_template}
keywords_extract_prompt: |
{indented_keywords_extract_template}
gremlin_generate_prompt: |
{indented_gremlin_prompt}
doc_input_text: |
{indented_doc_input_text}
"""
with open(yaml_file_path, "w", encoding="utf-8") as file:
file.write(yaml_content)