Smolagents / app.py
Jovynne's picture
Update app.py
f651953 verified
Raw History Blame Contribute Delete
1.34 kB
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
)