Spaces:
Sleeping
Sleeping
File size: 1,344 Bytes
952ef9b f651953 952ef9b f651953 952ef9b f651953 952ef9b f651953 952ef9b f651953 952ef9b f651953 | 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 47 48 49 | 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
) |