Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,49 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from agent import MyHuggingFaceAgent
|
| 3 |
|
| 4 |
-
|
| 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 |
-
|
| 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="
|
| 23 |
-
description="
|
| 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 |
-
["
|
| 36 |
-
["
|
| 37 |
-
["
|
| 38 |
-
["
|
| 39 |
-
|
| 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 |
-
)
|
|
|
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|