File size: 7,402 Bytes
2705160 a6998ef 8f96238 2705160 a6998ef 2705160 d123508 2705160 a6998ef |
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
---
title: GAgent
emoji: π₯
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.27.0
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_expiration_minutes: 480
---
# Agentic AI
This project implements multiple agentic systems including:
1. LangGraph-based agents with various tools
2. Gemini-powered agents with multimedia analysis capabilities
3. GAIA agents built with smolagents for flexible deployment
## Project Structure
```text
.
βββ gagent/ # Main package
β βββ __init__.py # Package initialization
β βββ agents/ # Agent implementations
β β βββ base_agent.py # Base agent implementation
β β βββ gemini_agent.py # Gemini-based agent
β β βββ huggingface_agent.py # HuggingFace-based agent
β β βββ ollama_agent.py # Ollama-based agent
β β βββ openai_agent.py # OpenAI-based agent
β β βββ registry.py # Agent registry
β β βββ __init__.py # Package initialization
β βββ config/ # Configuration settings
β β βββ settings.py # Application settings
β β βββ __init__.py # Package initialization
β βββ rag/ # Retrieval Augmented Generation
β β βββ chroma_vector_store.py # Chroma vectorstore implementation
β β βββ supabase_vector_store.py # Supabase vectorstore implementation
β β βββ vector_store.py # Base vectorstore implementation
β β βββ __init__.py # Package initialization
β βββ tools/ # Tool implementations
β β βββ code_interpreter.py # Code execution tools
β β βββ data.py # Data processing tools
β β βββ file.py # File handling tools
β β βββ image.py # Image processing tools
β β βββ math.py # Mathematical tools
β β βββ media.py # Media handling tools
β β βββ search.py # Search tools
β β βββ utilities.py # Utility tools
β β βββ wrappers.py # Tool wrappers
β β βββ __init__.py # Package initialization
βββ tests/ # Test files
β βββ __init__.py
β βββ agents/ # Agent tests
β βββ fixtures.py # Test fixtures
β βββ test_agents.py # Agent tests
β βββ __init__.py # Package initialization
βββ exp/ # Experimental code and notebooks
βββ app.py # Gradio application
βββ system_prompt.txt # System prompt for the agent
βββ pyproject.toml # Project configuration
βββ requirements.txt # Dependencies
βββ install.sh # Installation script
βββ env.example # Example environment variables
βββ .pre-commit-config.yaml # Pre-commit hooks configuration
βββ README.md # This file
```
## Installation
### Quick Start
```shell
# Clone the repository
git clone https://github.com/uoc/gagent.git
cd gagent
# Run the installation script
./install.sh
```
### Manual Installation
1. Create and activate a virtual environment:
```shell
python -m venv .venv
source .venv/bin/activate # On Windows: venv\Scripts\activate
```
2. Install dependencies:
```shell
pip install -r requirements.txt
```
3. Set up environment variables:
```shell
cp .env.example .env
# Edit .env with your API keys and configuration
```
## Development Setup
### Prerequisites
- Python 3.8 or higher
- Git
- Virtual environment (recommended)
### Development Tools
The project uses several development tools:
- **Ruff**: For linting and code formatting
- **Black**: For code formatting
- **MyPy**: For type checking
- **Pytest**: For testing
### Running Development Tools
```shell
# Format code
black .
# Lint code
ruff check .
# Type check
mypy .
# Run tests
pytest
```
### Pre-commit Hooks
Pre-commit hooks are set up to run checks before each commit:
```shell
pre-commit install
```
## Configuration
Create a `.env` file with the following variables:
```python
# API Keys
OPENAI_API_KEY=your_openai_api_key
GOOGLE_API_KEY=your_google_api_key
HUGGINGFACE_API_KEY=your_huggingface_api_key
# Database Configuration
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key
# Other Configuration
PYTHONPATH=$(pwd)
```
## Usage
### Running the Application
```shell
python gagent/main.py
```
### Using Agents Programmatically
#### LangGraph Agent
```python
from main import process_question
# Process a question using Google's Gemini
result = process_question("Your question here", provider="google")
# Or use Groq
result = process_question("Your question here", provider="groq")
# Or use HuggingFace
result = process_question("Your question here", provider="huggingface")
```
#### Gemini Agent
```python
from main import create_gemini_agent
# Create the agent
agent = create_gemini_agent(api_key="your_google_api_key")
# Run a query
response = agent.run("What are the main effects of climate change?")
```
#### GAIA Agent
```python
from main import create_gaia_agent
# Create with HuggingFace models
agent = create_gaia_agent(
model_type="HfApiModel",
model_id="meta-llama/Llama-3-70B-Instruct",
verbose=True
)
# Or create with OpenAI
agent = create_gaia_agent(
model_type="OpenAIServerModel",
model_id="gpt-4o",
verbose=True
)
# Answer a question
response = agent.answer_question("What is the square root of 144?")
```
## Testing
### Running Tests
```shell
# Run all tests
pytest
# Run tests with coverage
pytest --cov=gagent
# Run specific test file
pytest tests/test_agents.py
```
### Writing Tests
1. Create test files in the `tests` directory
2. Use fixtures from `conftest.py`
3. Follow pytest best practices
## Available Agent Types
1. LangGraph Agent:
- Graph-based approach for complex reasoning
- Vectorstore-backed retrieval
- Multiple LLM provider support
2. Gemini Agent:
- Media analysis capabilities (images, videos, tables)
- Multi-tool framework with web search and Wikipedia
- Conversation memory
3. GAIA Agent:
- Built with smolagents
- Code execution capability
- Multiple model backends
- File handling and data analysis
## Available Tools
1. Mathematical Operations:
- Addition, Subtraction, Multiplication, Division, Modulus
2. Search Tools:
- Wikipedia Search
- Web Search (via Tavily or DuckDuckGo)
- ArXiv Search
3. File & Media Tools:
- Image analysis
- Excel/CSV analysis
- File download and processing
## Contributing
1. Fork the repository
2. Create a feature branch
3. Set up development environment
4. Make your changes
5. Run tests and checks
6. Commit your changes
7. Push to the branch
8. Create a Pull Request
### Development Workflow
1. Create a new branch:
```shell
git checkout -b feature/your-feature-name
```
2. Make your changes and run checks:
```shell
black .
ruff check .
mypy .
pytest
```
3. Commit your changes:
```shell
git add .
git commit -m "Description of your changes"
```
4. Push and create a PR:
```shell
git push origin feature/your-feature-name
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.
|