File size: 1,639 Bytes
c45dff0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | from utils.config_handler import prompts_conf
from utils.path_tool import get_abs_path
from utils.logger_handler import logger
def load_system_prompts():
try:
system_prompt_path = get_abs_path(prompts_conf["main_prompt_path"])
except KeyError as e:
logger.error(f"[load_system_prompts]在yaml配置项中没有main_prompt_path配置项")
raise e
try:
return open(system_prompt_path, "r", encoding="utf-8").read()
except Exception as e:
logger.error(f"[load_system_prompts]解析系统提示词出错,{str(e)}")
raise e
def load_rag_prompts():
try:
rag_prompt_path = get_abs_path(prompts_conf["rag_summarize_prompt_path"])
except KeyError as e:
logger.error(f"[load_rag_prompts]在yaml配置项中没有rag_summarize_prompt_path配置项")
raise e
try:
return open(rag_prompt_path, "r", encoding="utf-8").read()
except Exception as e:
logger.error(f"[load_rag_prompts]解析RAG总结提示词出错,{str(e)}")
raise e
def load_report_prompts():
try:
report_prompt_path = get_abs_path(prompts_conf["report_prompt_path"])
except KeyError as e:
logger.error(f"[load_report_prompts]在yaml配置项中没有report_prompt_path配置项")
raise e
try:
return open(report_prompt_path, "r", encoding="utf-8").read()
except Exception as e:
logger.error(f"[load_report_prompts]解析报告生成提示词出错,{str(e)}")
raise e
if __name__ == '__main__':
print(load_report_prompts())
|