Metadata-Version: 2.4
Name: onsetlab
Version: 0.1.0
Summary: Build, benchmark, and package local SLM agents. No API keys, no cloud.
Author: OnsetLab Team
License: Apache-2.0
Project-URL: Homepage, https://github.com/riyanshibohra/onsetlab
Project-URL: Documentation, https://github.com/riyanshibohra/onsetlab#readme
Project-URL: Repository, https://github.com/riyanshibohra/onsetlab
Project-URL: Issues, https://github.com/riyanshibohra/onsetlab/issues
Keywords: ai,agents,slm,small-language-models,tool-calling,rewoo,mcp,model-context-protocol,ollama,local-ai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: server
Requires-Dist: fastapi>=0.100.0; extra == "server"
Requires-Dist: uvicorn>=0.22.0; extra == "server"
Provides-Extra: binary
Requires-Dist: pyinstaller>=5.0.0; extra == "binary"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: all
Requires-Dist: fastapi>=0.100.0; extra == "all"
Requires-Dist: uvicorn>=0.22.0; extra == "all"
Requires-Dist: pyinstaller>=5.0.0; extra == "all"
Dynamic: license-file

# OnsetLab

Make your local SLMs do actual work.

## What

Agent framework for small language models (3B parameters) that achieves GPT-4 level tool use on your laptop. Uses REWOO architecture (plan → execute → verify) with ReAct fallback for robustness.

- **No API keys** - runs entirely on Ollama
- **No fine-tuning** - works out of the box with any Ollama model
- **MCP support** - connect to any MCP-compatible server
- **Package & Deploy** - export as Docker, config, or standalone script

## Install

```bash
pip install onsetlab
```

Requires [Ollama](https://ollama.ai) running locally.

## Quick Start

```python
from onsetlab import Agent

agent = Agent("phi3.5")
result = agent.run("What time is it in Tokyo?")
print(result.answer)
```

## Adding Tools

Choose only the tools you need:

```python
from onsetlab import Agent
from onsetlab.tools import Calculator, DateTime, UnitConverter, TextProcessor, RandomGenerator

agent = Agent(
    model="phi3.5",
    tools=[Calculator(), DateTime()]
)

result = agent.run("What's 15% tip on $84.50?")
print(result.answer)  # "The 15% tip on $84.50 is $12.68"
```

**Available built-in tools:**
- `Calculator` - math operations
- `DateTime` - current time, timezones, date math
- `UnitConverter` - convert between units
- `TextProcessor` - word count, search, transform text
- `RandomGenerator` - random numbers, strings, choices

## MCP Servers

Connect to external services via Model Context Protocol:

```python
from onsetlab import Agent, MCPServer

agent = Agent("phi3.5")

# Add filesystem access
agent.add_mcp_server(MCPServer.from_registry("filesystem", path="/my/project"))

# Add GitHub integration
agent.add_mcp_server(MCPServer.from_registry("github", token="ghp_..."))

result = agent.run("List all Python files in the project")
print(result.answer)
```

**Registry servers:** `filesystem`, `github`, `slack`, `notion`, `google_calendar`, `tavily`

Or configure any MCP server manually:

```python
server = MCPServer(
    name="my-server",
    command="npx",
    args=["-y", "@some/mcp-server"],
    env={"API_KEY": "..."}
)
agent.add_mcp_server(server)
```

## Packaging & Deployment

Export your agent for deployment:

```python
# Export as Docker (includes docker-compose with Ollama)
agent.export("docker", "./my_agent/")

# Export as config file
agent.export("config", "my_agent.yaml")

# Export as standalone script
agent.export("binary", "my_agent.py")
```

Or via CLI:

```bash
python -m onsetlab export --format docker --output ./deployment/
cd deployment && docker-compose up --build
```

See [docs/PACKAGING.md](docs/PACKAGING.md) for full deployment guide.

## Benchmarking

Compare model performance on tool-calling:

```bash
# Benchmark single model
python -m onsetlab benchmark --model phi3.5

# Compare models
python -m onsetlab benchmark --compare "phi3.5,qwen2.5:3b,llama3.2:3b"
```

See [specs/BENCHMARKING.md](specs/BENCHMARKING.md) for methodology.

## Architecture

```
Task → Router → Strategy Selection
                    ↓
         ┌─────────┼─────────┐
         ↓         ↓         ↓
      DIRECT    REWOO     REACT
         ↓         ↓         ↓
                   └─────────┘
                       ↓
                   Verifier → Solver → Answer
```

1. **Router** - selects optimal strategy (DIRECT/REWOO/REACT)
2. **Planner** - creates step-by-step execution plan (REWOO)
3. **Verifier** - validates plan before execution
4. **Executor** - runs tools with dependency resolution
5. **Solver** - synthesizes final answer from results
6. **ReAct fallback** - recovers from planning failures

## Options

```python
agent = Agent(
    model="phi3.5",           # any Ollama model
    tools=[...],              # built-in tools
    mcp_servers=[...],        # MCP servers
    memory=True,              # conversation memory
    verify=True,              # pre-execution verification
    routing=True,             # intelligent strategy selection
    react_fallback=True,      # fallback on REWOO failure
    debug=False               # verbose logging
)
```

## License

Apache 2.0
