Spaces:
Sleeping
Sleeping
File size: 1,475 Bytes
ca8c756 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import gradio as gr
from typing import Optional
class GradioUI:
"""Gradio UI wrapper for smolagents CodeAgent"""
def __init__(self, agent):
self.agent = agent
def run_agent(self, query: str) -> str:
"""Execute agent and return response"""
try:
result = self.agent.run(query)
return str(result)
except Exception as e:
return f"Error: {str(e)}"
def launch(self, server_name: str = "0.0.0.0", server_port: int = 7860, share: bool = False):
"""Launch Gradio interface"""
interface = gr.Interface(
fn=self.run_agent,
inputs=gr.Textbox(
label="Your Question",
lines=3,
placeholder="Ask me anything..."
),
outputs=gr.Textbox(
label="Agent Response",
lines=5
),
title="GAIA Agent - Smolagents",
description="🤖 AI Agent powered by smolagents | Solves complex tasks using web search and reasoning",
examples=[
["What is the capital of France?"],
["Find information about artificial intelligence"],
["How many days are in February 2025?"],
],
theme=gr.themes.Soft()
)
interface.launch(
server_name=server_name,
server_port=server_port,
share=share
)
|