Spaces:
Sleeping
Sleeping
Update prompts/prompts.py
Browse files- prompts/prompts.py +26 -0
prompts/prompts.py
CHANGED
|
@@ -1,6 +1,32 @@
|
|
| 1 |
import yaml
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def load_prompts():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
system_prompt_override = "prompts/code_agent.yaml"
|
| 5 |
|
| 6 |
try:
|
|
|
|
| 1 |
import yaml
|
| 2 |
|
| 3 |
+
from smolagents import (
|
| 4 |
+
PromptTemplates,
|
| 5 |
+
PlanningPromptTemplate,
|
| 6 |
+
FinalAnswerPromptTemplate,
|
| 7 |
+
ManagedAgentPromptTemplate,
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
def load_prompts():
|
| 11 |
+
|
| 12 |
+
"""Builds a CodeAgent using the custom system and planning prompts from code_agent.yaml."""
|
| 13 |
+
|
| 14 |
+
# 1) Load YAML
|
| 15 |
+
with open("code_agent.yaml", "r", encoding="utf-8") as f:
|
| 16 |
+
y = yaml.safe_load(f)
|
| 17 |
+
|
| 18 |
+
# 2) Build PromptTemplates
|
| 19 |
+
templates = PromptTemplates(
|
| 20 |
+
system_prompt=y.get("system_prompt", ""),
|
| 21 |
+
planning=PlanningPromptTemplate(**y.get("planning", {})),
|
| 22 |
+
managed_agent=ManagedAgentPromptTemplate(**y.get("managed_agent", {})),
|
| 23 |
+
final_answer=FinalAnswerPromptTemplate(**y.get("final_answer", {})),
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
return templates
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def load_prompts2():
|
| 30 |
system_prompt_override = "prompts/code_agent.yaml"
|
| 31 |
|
| 32 |
try:
|