AlexDGenu commited on
Commit
8e83fd8
·
1 Parent(s): 79df835

Refactor SYSTEM_PROMPT in SmolAgent to enforce strict answer formatting and remove unnecessary instructions.

Browse files
Files changed (1) hide show
  1. app.py +16 -3
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 = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."""
 
 
 
 
 
 
 
 
 
 
 
 
 
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=[search_tool],
34
  model=model,
35
  instructions=SYSTEM_PROMPT,
36
  )
37
- print("SmolAgent initialized with DuckDuckGoSearchTool.")
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]}...")