Spaces:
Runtime error
Runtime error
Refactor SYSTEM_PROMPT in SmolAgent to enforce strict answer formatting and remove unnecessary instructions.
Browse files
app.py
CHANGED
|
@@ -9,7 +9,20 @@ from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
|
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 12 |
-
SYSTEM_PROMPT = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# --- Smol Agent Definition ---
|
| 15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
@@ -30,11 +43,11 @@ class SmolAgent:
|
|
| 30 |
|
| 31 |
# 4. Replace your current BasicAgent with a smolagents.CodeAgent
|
| 32 |
self._agent = CodeAgent(
|
| 33 |
-
tools=[
|
| 34 |
model=model,
|
| 35 |
instructions=SYSTEM_PROMPT,
|
| 36 |
)
|
| 37 |
-
print("SmolAgent initialized
|
| 38 |
|
| 39 |
def __call__(self, question: str) -> str:
|
| 40 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 12 |
+
SYSTEM_PROMPT = """
|
| 13 |
+
You are an expert assistant answering questions for evaluation where answers are checked using exact string match.
|
| 14 |
+
|
| 15 |
+
Rules:
|
| 16 |
+
- Return ONLY the final answer on a single line.
|
| 17 |
+
- Do NOT include reasoning or extra text.
|
| 18 |
+
- If the answer is a number, return the plain number with no commas, no currency symbols, and no units unless explicitly required.
|
| 19 |
+
- If the answer is a string, use lowercase, no articles, no abbreviations, and digits written in plain text unless specified.
|
| 20 |
+
- If the answer is a comma-separated list, follow the above rules for each element, with no spaces after commas.
|
| 21 |
+
- Do NOT write "Answer:" or "FINAL ANSWER:" before your response.
|
| 22 |
+
- If unsure, guess concisely.
|
| 23 |
+
|
| 24 |
+
Always strictly follow these instructions to ensure exact match.
|
| 25 |
+
"""
|
| 26 |
|
| 27 |
# --- Smol Agent Definition ---
|
| 28 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
| 43 |
|
| 44 |
# 4. Replace your current BasicAgent with a smolagents.CodeAgent
|
| 45 |
self._agent = CodeAgent(
|
| 46 |
+
tools=[],
|
| 47 |
model=model,
|
| 48 |
instructions=SYSTEM_PROMPT,
|
| 49 |
)
|
| 50 |
+
print("SmolAgent initialized")
|
| 51 |
|
| 52 |
def __call__(self, question: str) -> str:
|
| 53 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|