Metadata-Version: 2.5
Name: mowa
Version: 0.1.0
Summary: Load your Mowa agents at runtime.
Project-URL: Homepage, https://mowa.dev
License: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: httpx
Requires-Dist: httpx>=0.24; extra == 'httpx'
Description-Content-Type: text/markdown

# mowa

Load your Mowa agents at runtime. Edit the prompt in Mowa, ship it without a deploy.

## Install

```bash
pip install mowa
pip install "mowa[httpx]"
```

No required deps. Uses `httpx` if it's installed, else the standard library.

## Use

```python
from openai import OpenAI
from mowa import Mowa

mowa = Mowa()
openai = OpenAI()

agent = mowa.get_agent(
    "support",
    fallback={"system_prompt": "You are a helpful support agent.", "model": "gpt-4o-mini"},
)

reply = openai.chat.completions.create(
    model=agent.model,
    messages=[
        {"role": "system", "content": agent.system_prompt},
        {"role": "user", "content": "Where is my order?"},
    ],
    temperature=agent.settings.get("temperature"),
)
```

`Mowa()` reads `MOWA_API_KEY` and `MOWA_BASE_URL` from the environment. You can also pass `api_key`, `base_url`, `cache_ttl` (default 60s) and `timeout` (default 2s).

## Versions

```python
mowa.get_agent("support")
mowa.get_agent("support", version="draft")
mowa.get_agent("support", version=3)
```

## Caching and fallback

- First call fetches the agent and keeps it in memory.
- For the next `cache_ttl` seconds you get the cached copy. No network.
- After that you still get the cached copy right away, and it refreshes in the background.
- If the first fetch fails and you passed a `fallback`, you get the fallback. It never raises.
- With no fallback, it raises `MowaError`.

`agent.source` tells you where it came from: `network`, `cache`, `stale` or `fallback`.

Warm the cache at startup with `mowa.prefetch(["support", "billing"])`. Reset it with `mowa.clear_cache()`.

## Traces

```python
span.set_attributes(agent.trace_attributes())
```

Gives `{"mowa.agent": "support", "mowa.version": "v3"}`, so traces link back to the version that ran.

## Raw HTTP

```bash
curl https://mowa.dev/api/v1/agents/support/live -H "x-api-key: $MOWA_API_KEY"
```

Add `?version=draft` or `?version=v3`. Send `If-None-Match` with the `ETag` to get a `304` when nothing changed.
