Spaces:
Build error
Build error
Update app.py
Browse files2 unmodified lines345678910111213141516171819202122232425122 unmodified lines1481491501511521531541551561571581591602 unmodified linesimport requestsimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")fixed_answer = "This is a default answer."print(f"Agent returning fixed answer: {fixed_answer}")return fixed_answer#Carlitos was heredef run_and_submit_all( profile: gr.OAuthProfile | None):"""122 unmodified linesgr.Markdown("""**Instructions:**1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.---**Disclaimers:**Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.""")2 unmodified lines3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051122 unmodified lines1741751761771781791801811821831841851861871881892 unmodified linesimport requestsimport inspectimport pandas as pdfrom langchain_core.prompts import ChatPromptTemplatefrom smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, WikipediaSearchTool# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"SYSTEM_PROMPT = """You are GAIA-Bot, a fully-autonomous problem-solver.• For each question, THINK step-by-step before answering.• When outside knowledge or calculations are needed, CALL an appropriate tool.• Explain your reasoning only to yourself (in “Thought” messages); do NOT reveal it to the user.• After finishing all reasoning, RESPOND with **only** the final answer string—no pre-amble, no labels, no extra text.You have access to these tools:- gaia_file_fetch – download the file attached to the current task_id.- duckduckgo_search – look up current facts on the public web.If you require a file attached to the current task, download it with`requests_get("https://agents-course-unit4-scoring.hf.space/files/{task_id}")`and parse it inside Python.Adhere strictly to these rules:1. Use tools whenever they can reduce hallucination.2. Never mention tool names or JSON in your final answer.3. If you cannot find an answer, return “unknown”.Begin."""# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):model = OpenAIServerModel(model_id="deepseek-chat",api_key="sk-04da63f756c9468182d278f52e33ad15", api_base="https://api.deepseek.com")search_tool = DuckDuckGoSearchTool()wiki_search = WikipediaSearchTool()self.agent = CodeAgent(model = model,tools=[search_tool,wiki_search],prompt=SYSTEM_PROMPT,)def __call__(self, question: str) -> str:return self.agent.run(question) # type: ignoredef run_and_submit_all( profile: gr.OAuthProfile | None):"""122 unmodified linesgr.Markdown("""**Instructions:**1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.---**Disclaimers:**Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.Please note that this version requires an OpenAI Key to run.""")
app.py+36-7