Files
ragflow/rag/prompts/template.py
Jin Hai 4eb7659499 Fix bug: broken import from rag.prompts.prompts (#10217)
### What problem does this PR solve?

Fix broken imports

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: jinhai <haijin.chn@gmail.com>
2025-09-23 10:19:25 +08:00

21 lines
504 B
Python

import os
PROMPT_DIR = os.path.dirname(__file__)
_loaded_prompts = {}
def load_prompt(name: str) -> str:
if name in _loaded_prompts:
return _loaded_prompts[name]
path = os.path.join(PROMPT_DIR, f"{name}.md")
if not os.path.isfile(path):
raise FileNotFoundError(f"Prompt file '{name}.md' not found in prompts/ directory.")
with open(path, "r", encoding="utf-8") as f:
content = f.read().strip()
_loaded_prompts[name] = content
return content