LamiaYT's picture
Complete GAIA agent implementation with local LLM
8ac5ef4
raw
history blame
1.92 kB
import gradio as gr
from agent.local_llm import LocalLLM
from agent.tools import gaia_tools
from llama_index.core.agent import ReActAgent
from utils.gaia_api import GaiaAPI
# Initialize components
llm = LocalLLM()
agent = ReActAgent.from_tools(gaia_tools, llm=llm.pipeline)
def process_question(question_text: str) -> str:
"""Process GAIA question through agent"""
try:
response = agent.query(question_text)
return str(response)
except Exception as e:
return f"Error: {str(e)}"
def submit_to_gaia(username: str, code_url: str) -> str:
"""Submit all answers to GAIA"""
try:
questions = GaiaAPI.get_questions()
answers = []
for q in questions:
answer = process_question(q['question'])
answers.append({
"task_id": q['task_id'],
"submitted_answer": answer
})
result = GaiaAPI.submit_answers(username, code_url, answers)
return f"Submitted! Score: {result.get('score', 'N/A')}"
except Exception as e:
return f"Submission failed: {str(e)}"
with gr.Blocks() as demo:
gr.Markdown("# GAIA Benchmark Agent")
with gr.Tab("Question Processing"):
question_input = gr.Textbox(label="Enter GAIA Question")
answer_output = gr.Textbox(label="Agent Answer")
process_btn = gr.Button("Process Question")
process_btn.click(process_question, inputs=question_input, outputs=answer_output)
with gr.Tab("GAIA Submission"):
username_input = gr.Textbox(label="HF Username")
code_url_input = gr.Textbox(label="Space Code URL")
submit_btn = gr.Button("Submit to GAIA")
submission_output = gr.Textbox(label="Submission Result")
submit_btn.click(
submit_to_gaia,
inputs=[username_input, code_url_input],
outputs=submission_output
)
demo.launch()