Spaces:
Runtime error
Runtime error
Refactor SYSTEM_PROMPT in SmolAgent to enforce strict answer formatting and remove unnecessary instructions.
Browse files8 unmodified lines910111213141514 unmodified lines30313233343536373839408 unmodified lines# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"HF_TOKEN = os.getenv("HF_TOKEN")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."""# --- Smol Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------14 unmodified lines# 4. Replace your current BasicAgent with a smolagents.CodeAgentself._agent = CodeAgent(tools=[search_tool],model=model,instructions=SYSTEM_PROMPT,)print("SmolAgent initialized with DuckDuckGoSearchTool.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")8 unmodified lines91011121314151617181920212223242526272814 unmodified lines43444546474849505152538 unmodified lines# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"HF_TOKEN = os.getenv("HF_TOKEN")SYSTEM_PROMPT = """You are an expert assistant answering questions for evaluation where answers are checked using exact string match.Rules:- Return ONLY the final answer on a single line.- Do NOT include reasoning or extra text.- If the answer is a number, return the plain number with no commas, no currency symbols, and no units unless explicitly required.- If the answer is a string, use lowercase, no articles, no abbreviations, and digits written in plain text unless specified.- If the answer is a comma-separated list, follow the above rules for each element, with no spaces after commas.- Do NOT write "Answer:" or "FINAL ANSWER:" before your response.- If unsure, guess concisely.Always strictly follow these instructions to ensure exact match."""# --- Smol Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------14 unmodified lines# 4. Replace your current BasicAgent with a smolagents.CodeAgentself._agent = CodeAgent(tools=[],model=model,instructions=SYSTEM_PROMPT,)print("SmolAgent initialized")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")
app.py+16-3