Jovynne commited on
Commit
952ef9b
·
verified ·
1 Parent(s): 72ef6a4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from agent import MyHuggingFaceAgent
3
+
4
+ print("=" * 50)
5
+ print("🤖 AI Agent Framework Demo - Unit 2: smolagents")
6
+ print("=" * 50)
7
+
8
+ # Initialize agent with mock (for demonstration)
9
+ agent = MyHuggingFaceAgent()
10
+
11
+ def chat_response(message, history):
12
+ """Handle chat messages with the agent."""
13
+ try:
14
+ response = agent.run(message)
15
+ return response
16
+ except Exception as e:
17
+ return f"❌ **System Error:** {str(e)}\n\nPlease try a simpler query or contact support."
18
+
19
+ # Create Gradio interface
20
+ demo = gr.ChatInterface(
21
+ fn=chat_response,
22
+ title="🤖 Unit 2: AI Agent Framework (smolagents)",
23
+ description="""This demonstrates the **smolagents framework** from Hugging Face.
24
+ **Features:**
25
+ • Tool-calling agent architecture
26
+ • Multiple specialized tools
27
+ • Framework abstraction layer
28
+ **Available Tools:**
29
+ 1. 🧮 Calculator
30
+ 2. 🌐 Web Search
31
+ 3. 📊 Dataset Info
32
+ 4. 🌍 Translator
33
+ """,
34
+ examples=[
35
+ ["calculate 15 * 3 + 10"],
36
+ ["search for latest AI developments"],
37
+ ["tell me about the mnist dataset"],
38
+ ["translate hello to French"],
39
+ ["what is 45 + 67?"],
40
+ ["find information about machine learning"],
41
+ ],
42
+ )
43
+
44
+ if __name__ == "__main__":
45
+ demo.launch(
46
+ share=False,
47
+ server_name="0.0.0.0",
48
+ server_port=7860
49
+ )