Lightweight, modular, production-first AI agent framework.
Project description
PYFORGEAI
AI AGENT FRAMEWORK
pyforgeai is the PyPI package for the forgeai Python framework, a lightweight production-first toolkit for building autonomous AI agents with:
- async execution
- pluggable tools
- memory abstraction
- multi-provider LLM support
- structured observability
- simple orchestration
It is designed for clean architecture and easy extension, without unnecessary abstractions.
Repository: https://github.com/Pulkit-Py/pyforgeai
Table of Contents
- Why pyforgeai
- Author and Profiles
- Core Concepts
- Project Structure
- Installation
- Quick Start
- Configuration
- Providers
- FastAPI Integration
- Observability
- Testing and Quality
- How to Extend
- Current Limitations
- Troubleshooting
Why pyforgeai
- Async-first runtime (
asyncio) for modern Python services. - Strong typing and Pydantic schemas for reliable interfaces.
- Minimal, modular architecture that is easy to reason about.
- Provider-agnostic model layer (
BaseProvider). - Developer-friendly defaults and fallbacks for local/offline development.
Author and Profiles
- GitHub: https://github.com/Pulkit-Py
- Instagram: https://www.instagram.com/pulkit_py/
- LinkedIn: https://www.linkedin.com/in/pulkit-py/
Core Concepts
Agent: reasons over goal + role + memory + user input, then optionally calls tools.Engine: controls retries, iteration limits, early stop behavior, and metrics.BaseTool: async tool interface (run(input: str) -> str).BaseMemory: async memory interface (add,get_context).BaseProvider: async LLM interface (generate(prompt: str) -> str).AgentTeam: sequential multi-agent orchestration (output of agent A -> input of agent B).
Project Structure
forgeai/
├── agent/
│ └── base.py
├── config.py
├── engine/
│ └── engine.py
├── memory/
│ ├── base.py
│ └── short_term.py
├── observability/
│ ├── logger.py
│ └── metrics.py
├── orchestration/
│ └── team.py
├── providers/
│ ├── base.py
│ ├── factory.py
│ ├── openai_provider.py
│ ├── ollama_provider.py
│ ├── anthropic_provider.py
│ ├── gemini_provider.py
│ ├── deepseek_provider.py
│ └── grok_provider.py
├── schemas/
│ └── agent_schema.py
└── tools/
├── base.py
└── python_tool.py
Installation
1) Python version
- Python
3.11+is required.
2) Install package
pip install -e .
Install from PyPI:
pip install pyforgeai
3) Install provider extras (optional)
pip install -e .[ollama]
pip install -e .[openai]
pip install -e .[anthropic]
pip install -e .[gemini]
pip install -e .[api]
4) Full development install
pip install -e .[dev,all]
Quick Start
Run local example
example_usage.py uses provider factory + environment config.
python example_usage.py
By default, this project is configured for Ollama local usage in forgeai/config.py.
Configuration
Configuration is loaded via ForgeAIConfig.from_env() from forgeai/config.py.
Supported env vars:
FORGEAI_DEFAULT_PROVIDER(default:ollama)FORGEAI_DEFAULT_MODEL(default:qwen3:4b)FORGEAI_PROVIDER_TIMEOUT_S(default:30.0)FORGEAI_PROVIDER_RETRIES(default:1)FORGEAI_MAX_ITERATIONS(default:5)FORGEAI_MAX_RETRIES(default:2)OPENAI_API_KEYOPENAI_MODELANTHROPIC_API_KEYGEMINI_API_KEYorGOOGLE_API_KEYDEEPSEEK_API_KEYXAI_API_KEY
Example:
set FORGEAI_DEFAULT_PROVIDER=ollama
set FORGEAI_DEFAULT_MODEL=qwen3:4b
set FORGEAI_MAX_ITERATIONS=2
python example_usage.py
Providers
Use create_provider(...) from forgeai.providers.factory:
from forgeai.providers.factory import create_provider
provider = create_provider("ollama", model="qwen3:4b", host="http://localhost:11434")
Supported names:
openaiollamaanthropicgeminideepseekgrok(orxai)
All providers implement:
class BaseProvider:
async def generate(self, prompt: str) -> str: ...
FastAPI Integration
A ready example exists at examples/fastapi_app.py.
Run:
uvicorn examples.fastapi_app:app --reload
Endpoints:
GET /healthPOST /run
Request body example:
{
"prompt": "Write a hello world FastAPI app",
"provider": "ollama",
"model": "qwen3:4b"
}
Observability
forgeai includes JSON structured logging and basic metrics:
- per-step latency
- token usage placeholder
- provider/tool call counters
- run correlation id in engine logs
Use logger:
from forgeai.observability.logger import get_logger
logger = get_logger("forgeai-service")
Testing and Quality
Run checks:
ruff check .
mypy forgeai
pytest -q
Current test coverage includes:
- memory behavior
- agent tool-flow behavior
- engine early-stop behavior
- provider factory and fallback behavior
How to Extend
Add a custom tool
from forgeai.tools.base import BaseTool
class MyTool(BaseTool):
def __init__(self) -> None:
super().__init__(name="my_tool", description="Does something useful")
async def run(self, input: str) -> str:
return f"processed: {input}"
Add a custom memory backend
Implement BaseMemory:
async add(entry: str) -> Noneasync get_context(query: str) -> str
Add a new provider
Implement BaseProvider.generate(prompt: str) -> str, then register it in:
forgeai/providers/factory.pyforgeai/providers/__init__.py
Current Limitations
PythonToolusesexecand is not sandboxed. For untrusted input, run in an isolated runtime.- Metrics are intentionally lightweight and not yet integrated with Prometheus/OpenTelemetry.
- Memory is short-term in-process only (no persistent/vector memory by design right now).
Troubleshooting
-
No module named pytest- Install dev deps:
pip install -e .[dev]
- Install dev deps:
-
Provider returns fallback response
- Check API key env vars.
- Ensure relevant SDK is installed (
pip install -e .[provider]).
-
Ollama connection issues
- Ensure Ollama is running locally and model is pulled.
- Verify host URL (
http://localhost:11434by default).
License
MIT
Support
If you found this project helpful, consider:
- Giving it a ⭐ on GitHub
- Following me on social media
- Sharing it with others who might find it useful
GitHub Repository: https://github.com/Pulkit-Py/pyforgeai
For support, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
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 pyforgeai-0.1.1.tar.gz.
File metadata
- Download URL: pyforgeai-0.1.1.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b62034d125299070e991c8b7956d197b55a3fc0009d8c340c22109bfbcba17f
|
|
| MD5 |
688cbffa28ed581781765c70af8134c9
|
|
| BLAKE2b-256 |
9c47bcf4ac0eec309c0544601ec79407ac7c4958823829f6734ce1a560199d32
|
File details
Details for the file pyforgeai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyforgeai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
197ee376606c642318db0a42ffe9f90af6d50247d17f184d3f08e29948043819
|
|
| MD5 |
799329a2ccd493b6444b78b17cad6037
|
|
| BLAKE2b-256 |
3941437f74e93f46a52f28b3d3cb88566fb35e683c59c5259ff5f8186a1b3079
|