Spaces:
Runtime error
Runtime error
Update app.py
Browse files2 unmodified lines3456678910111213141516171819202122232425262728293031323334173536373839404124252627424344454647125 unmodified lines1731741751591761771784 unmodified lines1831841851861871881892 unmodified linesimport requestsimport inspectimport pandas as pd
from 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="gpt-4o") 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 ] tools=[search_tool,wiki_search], prompt=SYSTEM_PROMPT,
)
def __call__(self, question: str) -> str:125 unmodified lines gr.Markdown("# Basic Agent Evaluation Runner") gr.Markdown( """ Modified by niku.... **Instructions:**
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...4 unmodified lines **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+24-7