michelpadron's picture
fix small errors
056ecbf
|
Raw History Blame Contribute Delete
3.65 kB
---
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.