您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

prompt_template.py 504B

1234567891011121314151617181920
  1. import os
  2. PROMPT_DIR = os.path.dirname(__file__)
  3. _loaded_prompts = {}
  4. def load_prompt(name: str) -> str:
  5. if name in _loaded_prompts:
  6. return _loaded_prompts[name]
  7. path = os.path.join(PROMPT_DIR, f"{name}.md")
  8. if not os.path.isfile(path):
  9. raise FileNotFoundError(f"Prompt file '{name}.md' not found in prompts/ directory.")
  10. with open(path, "r", encoding="utf-8") as f:
  11. content = f.read().strip()
  12. _loaded_prompts[name] = content
  13. return content