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 )