Spaces:
Sleeping
Sleeping
File size: 3,648 Bytes
0128def e3d7fcc 0128def 9f39c86 0128def 3ce50c4 e0cc0af e8d4494 e3d7fcc 0128def 056ecbf 0128def 056ecbf | 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | ---
title: First Agent Template
emoji: ⚡
colorFrom: pink
colorTo: yellow
sdk: gradio
sdk_version: 5.23.1
app_file: app.py
pinned: false
tags:
- smolagents
- agent
- smolagent
- tool
- agent-course
---
# First Agent Template
A customizable AI agent template built with smolagents framework, featuring web search capabilities, custom tools, and a Gradio-based user interface.
## 🚀 Quick Start
### Prerequisites
- Python 3.8 or higher
- pip (Python package installer)
### Setup Instructions
1. **Clone the repository** (if not already done):
```bash
git clone <repository-url>
cd First_agent_template
```
2. **Create and activate virtual environment**:
```bash
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
```
3. **Install dependencies**:
```bash
pip install -r requirements.txt
```
4. **Run the application**:
```bash
python app.py
```
## 🛠️ Project Structure
```
First_agent_template/
├── app.py # Main application entry point
├── Gradio_UI.py # Gradio user interface
├── prompts.yaml # Agent prompt templates
├── requirements.txt # Python dependencies
├── tools/ # Custom agent tools
│ ├── final_answer.py
│ ├── visit_webpage.py
│ └── web_search.py
└── README.md
```
## 🔧 Features
- **AI Agent**: Powered by Qwen2.5-Coder-32B-Instruct model
- **Web Search**: DuckDuckGo search integration
- **Custom Tools**: Extensible tool system for agent capabilities
- **Gradio UI**: User-friendly web interface
- **Timezone Support**: Get current time in any timezone
- **Image Generation**: Text-to-image capabilities
## 🎯 Business Logic
This agent template provides a foundation for building AI-powered applications with the following core capabilities:
1. **Code Generation**: The agent can generate and execute code based on user requests
2. **Web Research**: Search the internet for real-time information
3. **Tool Integration**: Extensible system for adding custom functionality
4. **User Interface**: Web-based interface for easy interaction
## 📝 Development
### Adding New Tools
To add a new tool to the agent:
1. Create a new Python file in the `tools/` directory
2. Define your tool function with proper type hints
3. Add the tool to the agent's tools list in `app.py`
Example tool structure:
```python
@tool
def my_custom_tool(arg1: str, arg2: int) -> str:
"""Tool description
Args:
arg1: Description of first argument
arg2: Description of second argument
"""
# Tool implementation
return "Tool result"
```
### Configuration
- **Model Settings**: Configure the AI model in `app.py`
- **Prompts**: Customize agent behavior in `prompts.yaml`
- **Dependencies**: Manage packages in `requirements.txt`
## 🔍 Troubleshooting
- **Model Overload**: If the default model is overloaded, try alternative models or endpoints
- **Dependencies**: Ensure all requirements are installed in the virtual environment
- **Activation**: Always activate the virtual environment before running the application
## 📚 Documentation
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
## 🤝 Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test thoroughly
5. Submit a pull request
---
**Note**: This template is designed for educational purposes and can be extended for various AI agent applications.
|