Skip to main content

A modular, extensible AI agent system

Project description

Agenai

A modular, extensible AI agent system built around a core loop of perceive -> reason -> act.

Features

  • Modular Architecture: Build specialized agents with custom tools
  • Multiple LLM Providers: Anthropic Claude, Ollama (local, free)
  • Web Interface: FastAPI backend with WebSocket chat
  • Built-in Agents: Teaching Assistant for teaching Python programming
  • Hooks System: Full observability into agent behavior

Installation

# Basic installation
pip install -e .

# With web server support (for chat UI)
pip install -e ".[server]"

# All dependencies
pip install -e ".[all]"

Quick Start

Option 1: Using Ollama (Free, Local)

No API key required! Uses local LLMs.

# 1. Install Ollama from https://ollama.ai

# 2. Pull a model
ollama pull llama3.1

# 3. Start the web server
agenai-server

# 4. Open http://localhost:8000 in your browser

Option 2: Using Claude API

# Set your API key
export ANTHROPIC_API_KEY="your-key"

# Run CLI
agenai run "Explain Python for loops" -v

# Or interactive chat
agenai chat

Web Chat Interface

Start the server with WebSocket support:

# Install server dependencies
pip install -e ".[server]"

# Start server
agenai-server --port 8000

# Or with auto-reload for development
agenai-server --reload

Open http://localhost:8000 for the chat UI.

API Endpoints

Endpoint Method Description
/ GET Web chat interface
/health GET Health check + Ollama status
/chat POST REST chat endpoint
/ws/{client_id} WebSocket Real-time chat

Creating Custom Agents

from agenai.agent import SpecializedAgent, OllamaProvider
from agenai.agent.tools import Tool, ToolResult

class MyTool(Tool):
    @property
    def name(self) -> str:
        return "my_tool"

    @property
    def description(self) -> str:
        return "Does something useful"

    @property
    def parameters(self) -> dict:
        return {"type": "object", "properties": {}}

    def execute(self) -> ToolResult:
        return ToolResult.ok("Done!")

class MyAgent(SpecializedAgent):
    name = "my_agent"
    description = "My custom agent"

    def get_system_prompt(self) -> str:
        return "You are a helpful assistant..."

    def get_tools(self) -> list:
        return [MyTool()]

# Use with Ollama (free, local)
agent = MyAgent(llm=OllamaProvider(model="llama3.1"))
result = agent.run("Hello!")

Built-in Agents

Teaching Assistant

Teaching assistant for Python programming:

from agenai.agents.teaching_assistant import TeachingAssistantAgent

agent = TeachingAssistantAgent(difficulty_level="beginner")
result = agent.run("Explain what a for loop is")

Tools: run_code, review_code, create_exercise, create_quiz

Architecture

┌─────────────┐     WebSocket      ┌─────────────┐              ┌─────────────┐
│   Frontend  │ <================> │   Backend   │ <==========> │   Ollama    │
│  (Web Chat) │                    │  (FastAPI)  │              │ (Local LLM) │
└─────────────┘                    └──────┬──────┘              └─────────────┘
                                          │
                                          ▼
                                   ┌─────────────┐
                                   │   Agenai    │
                                   │   Agents    │
                                   └─────────────┘

See AI-AGENT-ARCHITECTURE.md for full details.

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Format code
ruff check --fix .

Publishing to PyPI

Local Publishing

# Build only
./scripts/publish.sh --build-only

# Publish to TestPyPI
TEST_PYPI_TOKEN=xxx ./scripts/publish.sh --test

# Publish to PyPI
PYPI_TOKEN=xxx ./scripts/publish.sh

Automated Publishing (GitHub Actions)

The repo includes a GitHub Actions workflow that auto-publishes to PyPI on release.

Setup Trusted Publisher on PyPI:

  1. Go to https://pypi.org/manage/account/publishing/
  2. Click "Add a new pending publisher"
  3. Fill in:
    • PyPI Project Name: agenai
    • Owner: tautobot
    • Repository: agenai
    • Workflow name: publish.yml
    • Environment name: pypi

Setup Trusted Publisher on TestPyPI:

  1. Go to https://test.pypi.org/manage/account/publishing/
  2. Same fields as above, but Environment name: testpypi

Setup GitHub Environments:

  1. Go to https://github.com/tautobot/agenai/settings/environments
  2. Create environment pypi
  3. Create environment testpypi
  4. (Optional) Add protection rules like required reviewers

Once configured, the GitHub Action publishes without API tokens using OIDC.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenai-0.1.0.tar.gz (57.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenai-0.1.0-py3-none-any.whl (53.5 kB view details)

Uploaded Python 3

File details

Details for the file agenai-0.1.0.tar.gz.

File metadata

  • Download URL: agenai-0.1.0.tar.gz
  • Upload date:
  • Size: 57.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for agenai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 757596e053b306a816e52e30c318a2afb7156cff853a7826a7b9f6503bbd96cb
MD5 32a72e1492a68a1df7394c05b1004f91
BLAKE2b-256 0fe795033e76d2773f36bee6416582d66daeae2e381571e60979223de9b200bc

See more details on using hashes here.

File details

Details for the file agenai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agenai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 53.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for agenai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b00ace241f50f87e98bd7fb09efac87efaf010f0c9ef550ebd3634818caf966
MD5 bd3ac05cb348b65f5c71a1f4a3803172
BLAKE2b-256 96053adc3ad5f6c9a9449d76569751008c9bc9b6145394f4ffbab8475d7c3678

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page