Metadata-Version: 2.4
Name: sploink
Version: 0.2.0
Summary: Auto-discover repetitive tasks in your AI agent and transparently replace them with small, specialized, locally-trained models.
Project-URL: Homepage, https://github.com/S-3-ai/dynamicrouting
Project-URL: Repository, https://github.com/S-3-ai/dynamicrouting
License-Expression: MIT
Requires-Python: >=3.10
Requires-Dist: openai>=1.50
Provides-Extra: train
Requires-Dist: mlx-lm>=0.31.3; extra == 'train'
Description-Content-Type: text/markdown

# sploink

**Auto-discover the repetitive tasks inside your AI agent, and transparently
replace the expensive ones with small, specialized models trained on your
own real traffic.**

> **Status:** Early. The connect/discover/route mechanism works locally,
> end to end, against Ollama and a local `mlx_lm.server` on Apple Silicon.
> No hosted version yet, no Linux/cloud GPU training path yet.

## Why

Most of what an AI agent does day to day is the same narrow, repetitive
task, over and over -- classify this, check that, draft a reply -- but
every call goes to one expensive, general-purpose model regardless of
whether the task actually needs that much capability. sploink finds those
narrow tasks automatically, from your agent's real traffic, and lets you
train a small local model specifically for one of them -- then transparently
routes future calls to it, with no changes to your agent's code beyond one
line.

## Install

```bash
# Core install -- just the connect/discover/route layer
pip install sploink

# With local LoRA training support (Apple Silicon only, via mlx_lm):
pip install "sploink[train]"
```

## Quickstart

The only integration line you ever write, regardless of what else you do:

```python
import sploink
sploink.init(account_id="your_account")

# ...the rest of your existing agent code, completely unchanged...
```

This patches the OpenAI-compatible client your agent already uses. From
that point on:

- Every call gets logged.
- The real `tools=[...]` schema on each call is read to discover the
  distinct tasks your agent actually performs -- no source-code parsing,
  works with any framework built on the `openai` Python SDK against an
  OpenAI-compatible backend.
- If a task already has a trained adapter, matching calls are transparently
  routed to it instead of the generalist -- including bundled, multi-tool
  ReAct-style calls, split into a cheap "which tool" decision and a routed
  "what arguments" call under the hood.

Training a task (requires the `train` extra):

```python
adapter_path = sploink.create_lora_adapter(
    task_name="classify_expense",
    system_prompt="...",
    train_examples=[(text, {"category": ..., "amount": ...}), ...],
    valid_examples=[...],
)
```

Once trained, the very next real call for that task routes to it
automatically -- no further code change.

## What this isn't (yet)

- No hosted/cloud version -- everything here runs on your own machine.
- No Linux or non-Apple-Silicon training path (`mlx_lm` is Mac-only).
- No automatic quality gating before a newly trained adapter starts serving
  real traffic -- that's on the roadmap, not yet built.
