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
# From PyPI
pip install agenai
# With web server support (for chat UI)
pip install agenai[server]
# For development (editable install)
pip install -e ".[dev]"
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 using Trusted Publisher (OIDC - no API tokens needed).
How it works:
- Create a GitHub Release → auto-publishes to PyPI
- Manual dispatch → choose testpypi or pypi target
Step 1: Setup Trusted Publisher on PyPI
-
Go to https://pypi.org/manage/project/agenai/settings/publishing/
-
Click "Add a new publisher"
-
Fill in:
Field Value Owner tautobotRepository agenaiWorkflow name publish.ymlEnvironment name pypi
Step 2: Setup Trusted Publisher on TestPyPI
- Go to https://test.pypi.org/manage/project/agenai/settings/publishing/
- Same fields as above, but Environment name:
testpypi
Step 3: Setup GitHub Environments
- Go to https://github.com/tautobot/agenai/settings/environments
- Create environment
pypi - Create environment
testpypi - (Optional) Add protection rules like required reviewers
Releasing a New Version
- Update version in
pyproject.toml - Commit and push
- Create a GitHub Release with tag
v0.x.x - GitHub Actions auto-publishes to PyPI
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agenai-0.1.1.tar.gz.
File metadata
- Download URL: agenai-0.1.1.tar.gz
- Upload date:
- Size: 57.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7afec2d6caf3c41bf4e9f1a93900ffff8cfba588e267c96a78c962bc0cf15e
|
|
| MD5 |
a276198c159c1e0e30815d0cf7c4caf1
|
|
| BLAKE2b-256 |
bf41d4c74511a4414b5f6db8bd2c02292f9b5d2a768be0a4cb08a2a5c3f04305
|
Provenance
The following attestation bundles were made for agenai-0.1.1.tar.gz:
Publisher:
publish.yml on tautobot/agenai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agenai-0.1.1.tar.gz -
Subject digest:
bc7afec2d6caf3c41bf4e9f1a93900ffff8cfba588e267c96a78c962bc0cf15e - Sigstore transparency entry: 1108181512
- Sigstore integration time:
-
Permalink:
tautobot/agenai@754da138331af217ea163ad2220ed55915c637a6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tautobot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@754da138331af217ea163ad2220ed55915c637a6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agenai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: agenai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 53.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52ff16e84ae60faf74e10825f0197d2537fd96f9037d0ae2ed2248b0258915f0
|
|
| MD5 |
eb07d25d58bb28e7c7f8a160fe33502a
|
|
| BLAKE2b-256 |
4aeefcd3f7e5a54731ff46dbf2f397617fbb70943bfd6268e53bb8709b7b2986
|
Provenance
The following attestation bundles were made for agenai-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on tautobot/agenai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agenai-0.1.1-py3-none-any.whl -
Subject digest:
52ff16e84ae60faf74e10825f0197d2537fd96f9037d0ae2ed2248b0258915f0 - Sigstore transparency entry: 1108181522
- Sigstore integration time:
-
Permalink:
tautobot/agenai@754da138331af217ea163ad2220ed55915c637a6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/tautobot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@754da138331af217ea163ad2220ed55915c637a6 -
Trigger Event:
release
-
Statement type: