|
--- |
|
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. |
|
|