Jovynne commited on
Commit
f651953
·
verified ·
1 Parent(s): 13e58c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -10
app.py CHANGED
@@ -1,22 +1,49 @@
1
  import gradio as gr
2
  from agent import MyHuggingFaceAgent
3
 
4
- agent_instance = MyHuggingFaceAgent()
 
 
 
 
 
5
 
6
  def chat_response(message, history):
7
- return agent_instance.run(message)
 
 
 
 
 
8
 
 
9
  demo = gr.ChatInterface(
10
  fn=chat_response,
11
- title="🚀 Final Project: Agentic RAG Assistant",
12
- description="This agent uses **smolagents** and Agentic RAG to answer questions about the HF course.",
 
 
 
 
 
 
 
 
 
 
13
  examples=[
14
- ["How many bonus marks can I get?"],
15
- ["Search for the latest news on AI agents"],
16
- ["What is 15% of 450?"],
17
- ["How do I submit the final project?"]
18
- ]
 
 
19
  )
20
 
21
  if __name__ == "__main__":
22
- demo.launch()
 
 
 
 
 
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
+ )