Spaces:
Sleeping
Sleeping
| 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 | |
| ) |