Smolagents / app.py
Jovynne's picture
Update app.py
f651953 verified
import gradio as gr
from agent import MyHuggingFaceAgent
print("=" * 50)
print("๐Ÿค– AI Agent Framework Demo - Unit 2: smolagents")
print("=" * 50)
# Initialize agent with mock (for demonstration)
agent = MyHuggingFaceAgent()
def chat_response(message, history):
"""Handle chat messages with the agent."""
try:
response = agent.run(message)
return response
except Exception as e:
return f"โŒ **System Error:** {str(e)}\n\nPlease try a simpler query or contact support."
# Create Gradio interface
demo = gr.ChatInterface(
fn=chat_response,
title="๐Ÿค– Unit 2: AI Agent Framework (smolagents)",
description="""This demonstrates the **smolagents framework** from Hugging Face.
**Features:**
โ€ข Tool-calling agent architecture
โ€ข Multiple specialized tools
โ€ข Framework abstraction layer
**Available Tools:**
1. ๐Ÿงฎ Calculator
2. ๐ŸŒ Web Search
3. ๐Ÿ“Š Dataset Info
4. ๐ŸŒ Translator
""",
examples=[
["calculate 15 * 3 + 10"],
["search for latest AI developments"],
["tell me about the mnist dataset"],
["translate hello to French"],
["what is 45 + 67?"],
["find information about machine learning"],
],
)
if __name__ == "__main__":
demo.launch(
share=False,
server_name="0.0.0.0",
server_port=7860
)