rag-chatbot / app /utils /prompts.py
Abeshith's picture
RAG Chatbot with LangChain, FastAPI, and service layer architecture
64d7fdf
Raw
History Blame Contribute Delete
545 Bytes
from pathlib import Path
from functools import lru_cache
PROMPTS_DIR = Path(__file__).parent.parent.parent / "prompts"
@lru_cache()
def load_prompt(filename: str) -> str:
prompt_path = PROMPTS_DIR / filename
with open(prompt_path, "r", encoding="utf-8") as f:
return f.read().strip()
def get_system_prompt() -> str:
return load_prompt("system.txt")
def get_rag_template() -> str:
return load_prompt("rag_template.txt")
def get_conversation_template() -> str:
return load_prompt("conversation_template.txt")