Owadokun Tosin Tobi commited on
Create prompt_loader.py
Browse files- utils/prompt_loader.py +17 -0
utils/prompt_loader.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
def load_prompt(filename):
|
| 4 |
+
"""
|
| 5 |
+
Reads a prompt file from the ../prompts directory.
|
| 6 |
+
"""
|
| 7 |
+
# Get current directory (src/utils)
|
| 8 |
+
current_dir = os.path.dirname(__file__)
|
| 9 |
+
# Go up one level to src, then into prompts
|
| 10 |
+
prompts_dir = os.path.join(os.path.dirname(current_dir), 'prompts')
|
| 11 |
+
file_path = os.path.join(prompts_dir, filename)
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
| 15 |
+
return f.read()
|
| 16 |
+
except FileNotFoundError:
|
| 17 |
+
raise FileNotFoundError(f"❌ Critical: Prompt file '{filename}' missing at {file_path}")
|