michelpadron commited on
Commit
056ecbf
·
1 Parent(s): 8c5c24b

fix small errors

Browse files
Files changed (5) hide show
  1. .gitignore +106 -0
  2. README.md +122 -0
  3. app.py +4 -4
  4. requirements.txt +2 -1
  5. setup.sh +55 -0
.gitignore ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Virtual Environment
2
+ venv/
3
+ env/
4
+ ENV/
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.so
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *.cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Jupyter Notebook
50
+ .ipynb_checkpoints
51
+
52
+ # pyenv
53
+ .python-version
54
+
55
+ # celery beat schedule file
56
+ celerybeat-schedule
57
+
58
+ # SageMath parsed files
59
+ *.sage.py
60
+
61
+ # Environments
62
+ .env
63
+ .venv
64
+ env/
65
+ venv/
66
+ ENV/
67
+ env.bak/
68
+ venv.bak/
69
+
70
+ # Spyder project settings
71
+ .spyderproject
72
+ .spyproject
73
+
74
+ # Rope project settings
75
+ .ropeproject
76
+
77
+ # mkdocs documentation
78
+ /site
79
+
80
+ # mypy
81
+ .mypy_cache/
82
+ .dmypy.json
83
+ dmypy.json
84
+
85
+ # IDE
86
+ .vscode/
87
+ .idea/
88
+ *.swp
89
+ *.swo
90
+ *~
91
+
92
+ # OS
93
+ .DS_Store
94
+ .DS_Store?
95
+ ._*
96
+ .Spotlight-V100
97
+ .Trashes
98
+ ehthumbs.db
99
+ Thumbs.db
100
+
101
+ # Logs
102
+ *.log
103
+
104
+ # Temporary files
105
+ *.tmp
106
+ *.temp
README.md CHANGED
@@ -15,4 +15,126 @@ tags:
15
  - agent-course
16
  ---
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  - agent-course
16
  ---
17
 
18
+ # First Agent Template
19
+
20
+ A customizable AI agent template built with smolagents framework, featuring web search capabilities, custom tools, and a Gradio-based user interface.
21
+
22
+ ## 🚀 Quick Start
23
+
24
+ ### Prerequisites
25
+ - Python 3.8 or higher
26
+ - pip (Python package installer)
27
+
28
+ ### Setup Instructions
29
+
30
+ 1. **Clone the repository** (if not already done):
31
+ ```bash
32
+ git clone <repository-url>
33
+ cd First_agent_template
34
+ ```
35
+
36
+ 2. **Create and activate virtual environment**:
37
+ ```bash
38
+ # Create virtual environment
39
+ python3 -m venv venv
40
+
41
+ # Activate virtual environment
42
+ # On macOS/Linux:
43
+ source venv/bin/activate
44
+ # On Windows:
45
+ # venv\Scripts\activate
46
+ ```
47
+
48
+ 3. **Install dependencies**:
49
+ ```bash
50
+ pip install -r requirements.txt
51
+ ```
52
+
53
+ 4. **Run the application**:
54
+ ```bash
55
+ python app.py
56
+ ```
57
+
58
+ ## 🛠️ Project Structure
59
+
60
+ ```
61
+ First_agent_template/
62
+ ├── app.py # Main application entry point
63
+ ├── Gradio_UI.py # Gradio user interface
64
+ ├── prompts.yaml # Agent prompt templates
65
+ ├── requirements.txt # Python dependencies
66
+ ├── tools/ # Custom agent tools
67
+ │ ├── final_answer.py
68
+ │ ├── visit_webpage.py
69
+ │ └── web_search.py
70
+ └── README.md
71
+ ```
72
+
73
+ ## 🔧 Features
74
+
75
+ - **AI Agent**: Powered by Qwen2.5-Coder-32B-Instruct model
76
+ - **Web Search**: DuckDuckGo search integration
77
+ - **Custom Tools**: Extensible tool system for agent capabilities
78
+ - **Gradio UI**: User-friendly web interface
79
+ - **Timezone Support**: Get current time in any timezone
80
+ - **Image Generation**: Text-to-image capabilities
81
+
82
+ ## 🎯 Business Logic
83
+
84
+ This agent template provides a foundation for building AI-powered applications with the following core capabilities:
85
+
86
+ 1. **Code Generation**: The agent can generate and execute code based on user requests
87
+ 2. **Web Research**: Search the internet for real-time information
88
+ 3. **Tool Integration**: Extensible system for adding custom functionality
89
+ 4. **User Interface**: Web-based interface for easy interaction
90
+
91
+ ## 📝 Development
92
+
93
+ ### Adding New Tools
94
+
95
+ To add a new tool to the agent:
96
+
97
+ 1. Create a new Python file in the `tools/` directory
98
+ 2. Define your tool function with proper type hints
99
+ 3. Add the tool to the agent's tools list in `app.py`
100
+
101
+ Example tool structure:
102
+ ```python
103
+ @tool
104
+ def my_custom_tool(arg1: str, arg2: int) -> str:
105
+ """Tool description
106
+ Args:
107
+ arg1: Description of first argument
108
+ arg2: Description of second argument
109
+ """
110
+ # Tool implementation
111
+ return "Tool result"
112
+ ```
113
+
114
+ ### Configuration
115
+
116
+ - **Model Settings**: Configure the AI model in `app.py`
117
+ - **Prompts**: Customize agent behavior in `prompts.yaml`
118
+ - **Dependencies**: Manage packages in `requirements.txt`
119
+
120
+ ## 🔍 Troubleshooting
121
+
122
+ - **Model Overload**: If the default model is overloaded, try alternative models or endpoints
123
+ - **Dependencies**: Ensure all requirements are installed in the virtual environment
124
+ - **Activation**: Always activate the virtual environment before running the application
125
+
126
+ ## 📚 Documentation
127
+
128
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
129
+
130
+ ## 🤝 Contributing
131
+
132
+ 1. Fork the repository
133
+ 2. Create a feature branch
134
+ 3. Make your changes
135
+ 4. Test thoroughly
136
+ 5. Submit a pull request
137
+
138
+ ---
139
+
140
+ **Note**: This template is designed for educational purposes and can be extended for various AI agent applications.
app.py CHANGED
@@ -40,10 +40,10 @@ final_answer = FinalAnswerTool()
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
 
42
  model = HfApiModel(
43
- max_tokens=2096,
44
- temperature=0.5,
45
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
46
- custom_role_conversions=None,
47
  )
48
 
49
 
 
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
 
42
  model = HfApiModel(
43
+ max_tokens=2096,
44
+ temperature=0.5,
45
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
46
+ custom_role_conversions=None,
47
  )
48
 
49
 
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  markdownify
2
- smolagents==1.13.0
 
3
  requests
4
  duckduckgo_search
5
  pandas
 
1
  markdownify
2
+ # smolagents with Gradio UI support (includes core package + Gradio dependencies)
3
+ smolagents[gradio]==1.13.0
4
  requests
5
  duckduckgo_search
6
  pandas
setup.sh ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # First Agent Template Setup Script
4
+ # This script sets up the virtual environment and installs dependencies
5
+
6
+ echo "🚀 Setting up First Agent Template..."
7
+
8
+ # Check if Python 3 is installed
9
+ if ! command -v python3 &> /dev/null; then
10
+ echo "❌ Python 3 is not installed. Please install Python 3.8 or higher."
11
+ exit 1
12
+ fi
13
+
14
+ # Check if virtual environment already exists
15
+ if [ -d "venv" ]; then
16
+ echo "⚠️ Virtual environment already exists."
17
+ read -p "Do you want to recreate it? (y/N): " -n 1 -r
18
+ echo
19
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
20
+ echo "🗑️ Removing existing virtual environment..."
21
+ rm -rf venv
22
+ else
23
+ echo "✅ Using existing virtual environment."
24
+ echo "To activate: source venv/bin/activate"
25
+ exit 0
26
+ fi
27
+ fi
28
+
29
+ # Create virtual environment
30
+ echo "📦 Creating virtual environment..."
31
+ python3 -m venv venv
32
+
33
+ # Activate virtual environment
34
+ echo "🔧 Activating virtual environment..."
35
+ source venv/bin/activate
36
+
37
+ # Upgrade pip
38
+ echo "⬆️ Upgrading pip..."
39
+ pip install --upgrade pip
40
+
41
+ # Install dependencies
42
+ echo "📚 Installing dependencies..."
43
+ pip install -r requirements.txt
44
+
45
+ echo ""
46
+ echo "✅ Setup complete!"
47
+ echo ""
48
+ echo "To activate the virtual environment:"
49
+ echo " source venv/bin/activate"
50
+ echo ""
51
+ echo "To run the application:"
52
+ echo " python app.py"
53
+ echo ""
54
+ echo "To deactivate the virtual environment:"
55
+ echo " deactivate"