Metadata-Version: 2.4
Name: waken-ollama
Version: 0.1.0
Summary: Ollama Target adapter for Waken — routes waken Events to a local/self-hosted Ollama daemon.
Project-URL: Homepage, https://github.com/WakenHQ/waken-ollama
Project-URL: Repository, https://github.com/WakenHQ/waken-ollama
Project-URL: Issues, https://github.com/WakenHQ/waken-ollama/issues
Author: Waken contributors
License: MIT
License-File: LICENSE
Keywords: agents,ai,local,ollama,waken
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Requires-Dist: ollama>=0.3.0
Requires-Dist: waken>=0.1.1
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# waken-ollama

[![CI](https://github.com/WakenHQ/waken-ollama/actions/workflows/ci.yml/badge.svg)](https://github.com/WakenHQ/waken-ollama/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-lightgrey)](https://github.com/WakenHQ/waken-ollama/blob/main/LICENSE)

Ollama Target adapter for [Waken](https://github.com/WakenHQ/waken) —
"nginx for AI agents." Routes a waken `Event` to a local or self-hosted
[Ollama](https://ollama.com) daemon via the official `ollama` Python SDK
and returns a `Response`.

## Why Ollama fits here particularly well

Every other Target adapter in this ecosystem wraps a cloud API and needs an
API key (`ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, ...). Ollama needs none of
that — it's a daemon that runs on hardware you already control, the same
"no external services" idea behind Waken itself: `waken` keeps all its own
state (sessions, scheduled jobs, the retry queue) in one local SQLite file
instead of reaching for Docker, Redis, or Postgres. `waken-ollama` extends
that same idea to the model itself — no cloud account, no billing, no
secret to manage, just a local process talking to another local process.

## Install

```bash
pip install waken-ollama
```

Prerequisite: [Ollama](https://ollama.com) must already be installed and
running — either locally (`ollama serve`, or the desktop app, which starts
it automatically) or as a self-hosted daemon reachable over the network —
with the model you intend to use already pulled:

```bash
ollama pull llama3.2
```

This adapter only talks to an already-running daemon; it doesn't install
Ollama, start it, or pull models on your behalf. If the daemon isn't
reachable, calls raise a `ConnectionError` — that's a setup problem to fix
on the machine running Waken, not something this adapter papers over.

## Usage

```python
from waken import Runtime
from waken_ollama import OllamaAdapter

runtime = Runtime()
runtime.target("ollama", OllamaAdapter(model="llama3.2"))
runtime.run()
```

```bash
waken send ollama "Build tic tac toe." --wait
```

By default `OllamaAdapter` talks to `http://127.0.0.1:11434`, or whatever
`OLLAMA_HOST` is set to in the environment — the `ollama` SDK's own
convention, read automatically. Point it at a remote/self-hosted daemon
with `host=`:

```python
runtime.target("ollama", OllamaAdapter(model="llama3.2", host="http://gpu-box:11434"))
```

Ollama's `/api/chat` endpoint has no server-side conversation state, unlike
Claude's `resume` or OpenAI's `previous_response_id` — the full message
history has to be resent on every call. `OllamaAdapter` keeps a `waken
session_id -> list of chat messages` map internally and grows it in place
across turns of the same `event.session_id`, so a multi-turn conversation
picks up where it left off without the caller managing history itself.
Extra keyword arguments passed to `OllamaAdapter(...)` are forwarded to
`ollama.AsyncClient(...)`.

## Development

```bash
git clone https://github.com/WakenHQ/waken-ollama
cd waken-ollama
pip install -e ".[dev]"
pytest
```

Tests mock `ollama.AsyncClient` entirely — no local Ollama daemon or
network access is needed to run the suite.

## License

[MIT](https://github.com/WakenHQ/waken-ollama/blob/main/LICENSE)
