Logo
Explore Help
Register Sign In
yujunjun/ragflow
1
0
Fork 0
You've already forked ragflow
mirror of https://github.com/infiniflow/ragflow.git synced 2025-12-16 17:48:33 +00:00
Code Issues Packages Projects Releases Wiki Activity
ragflow/rag/prompts/template.py

21 lines
504 B
Python
Raw Normal View History

Refa: refactor prompts into markdown-style structure using Jinja2 (#8667) ### What problem does this PR solve? Refactor prompts into markdown-style structure using Jinja2. ### Type of change - [x] Refactoring
2025-07-04 15:59:41 +08:00
import os
Feat: Redesign and refactor agent module (#9113) ### What problem does this PR solve? #9082 #6365 <u> **WARNING: it's not compatible with the older version of `Agent` module, which means that `Agent` from older versions can not work anymore.**</u> ### Type of change - [x] New Feature (non-breaking change which adds functionality)
2025-07-30 19:41:09 +08:00
PROMPT_DIR = os.path.dirname(__file__)
Refa: refactor prompts into markdown-style structure using Jinja2 (#8667) ### What problem does this PR solve? Refactor prompts into markdown-style structure using Jinja2. ### Type of change - [x] Refactoring
2025-07-04 15:59:41 +08:00
_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
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.5 Page: 1476ms Template: 31ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API