A newer version of the Gradio SDK is available:
5.29.0
metadata
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:
- LangGraph-based agents with various tools
- Gemini-powered agents with multimedia analysis capabilities
- GAIA agents built with smolagents for flexible deployment
Project Structure
.
βββ 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
# Clone the repository
git clone https://github.com/uoc/gagent.git
cd gagent
# Run the installation script
./install.sh
Manual Installation
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
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
# 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:
pre-commit install
Configuration
Create a .env
file with the following variables:
# 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
python gagent/main.py
Using Agents Programmatically
LangGraph Agent
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
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
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
# Run all tests
pytest
# Run tests with coverage
pytest --cov=gagent
# Run specific test file
pytest tests/test_agents.py
Writing Tests
- Create test files in the
tests
directory - Use fixtures from
conftest.py
- Follow pytest best practices
Available Agent Types
LangGraph Agent:
- Graph-based approach for complex reasoning
- Vectorstore-backed retrieval
- Multiple LLM provider support
Gemini Agent:
- Media analysis capabilities (images, videos, tables)
- Multi-tool framework with web search and Wikipedia
- Conversation memory
GAIA Agent:
- Built with smolagents
- Code execution capability
- Multiple model backends
- File handling and data analysis
Available Tools
Mathematical Operations:
- Addition, Subtraction, Multiplication, Division, Modulus
Search Tools:
- Wikipedia Search
- Web Search (via Tavily or DuckDuckGo)
- ArXiv Search
File & Media Tools:
- Image analysis
- Excel/CSV analysis
- File download and processing
Contributing
- Fork the repository
- Create a feature branch
- Set up development environment
- Make your changes
- Run tests and checks
- Commit your changes
- Push to the branch
- Create a Pull Request
Development Workflow
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and run checks:
black .
ruff check .
mypy .
pytest
- Commit your changes:
git add .
git commit -m "Description of your changes"
- Push and create a PR:
git push origin feature/your-feature-name
License
This project is licensed under the MIT License - see the LICENSE file for details.