Update app.py
Browse files142 unmodified lines1431441451461471481491 unmodified line151152153154155156157142 unmodified lines# --- Build Gradio Interface using Blocks ---with gr.Blocks() as demo:gr.Markdown("# Basic Agent Evaluation Runner")gr.Markdown("""**Instructions:**1 unmodified line2. 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.142 unmodified lines1431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881 unmodified line190191192193194195142 unmodified lines# --- Build Gradio Interface using Blocks ---with gr.Blocks() as demo:gr.Markdown("# Basic Agent Evaluation Runner")gr.Markdown(# ==========================================# SECTION 1: IMPORTS & TOOL DEFINITIONS# ==========================================from smolagents import CodeAgent, LiteLLMModel, toolimport pandas as pdimport requestsfrom bs4 import BeautifulSoup# Paste your custom high-yield tools here@tooldef inspect_dataframe(file_path: str, operation: str, query_code: str = None) -> str:# (Your dataframe tool logic here...)pass@tooldef fetch_webpage_content(url: str) -> str:# (Your scraper tool logic here...)pass# ==========================================# SECTION 2: INITIALIZE THE INTENT ENGINE# ==========================================# Ensure you have set your HF_TOKEN secret in Space Settings!model = LiteLLMModel(model_id="huggingface/Qwen/Qwen2.5-Coder-32B-Instruct")# Instantiate your agent with the tools attachedagent = CodeAgent(tools=[inspect_dataframe, fetch_webpage_content],model=model,additional_authorized_imports=["pandas", "numpy", "json", "datetime", "re", "bs4"])# ==========================================# SECTION 3: CONNECT TO THE TEMPLATE RUNNER# ==========================================# The original template space comes with a Gradio UI block or a loop# that cycles through questions. Leave that layout block intact at the bottom.# Inside that function block where it evaluates user questions, change it to call your agent:# e.g., raw_output = agent.run(evaluation_question)"""**Instructions:**1 unmodified line2. 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.
app.py+40-2