Skip to content

Commit 806a7c9

Browse files
authored
Merge pull request #187 from kalibr-ai/docs/v1.14-readme-update
docs: Python SDK README for v1.14.1
2 parents b02fc0e + b9a6151 commit 806a7c9

1 file changed

Lines changed: 83 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,86 @@ Every model call runs through a self-contained healing loop — no orchestrator
241241

242242
Your original messages are never modified. All LLM calls for meta prompt generation and repair run on your API keys — zero Kalibr inference cost.
243243

244+
### Enable the heal loop
245+
246+
```python
247+
from kalibr import Router
248+
249+
router = Router(goal="summarization", paths=["gpt-4o-mini", "deepseek-chat"])
250+
251+
response = router.completion(
252+
messages=[{"role": "user", "content": "Summarize this article..."}],
253+
healing=True, # Gate 1 eval + prompt repair + model swap on failure
254+
)
255+
256+
print(response.kalibr_healed) # True if healing fired
257+
print(response.kalibr_heal_count) # Number of repair attempts
258+
```
259+
260+
### Tuning the heal loop with `HealConfig`
261+
262+
```python
263+
from kalibr import Router, HealConfig
264+
265+
config = HealConfig(
266+
max_retries=2, # Repair attempts before model swap
267+
gate2_enabled=True, # LLM quality judge (uses DEEPSEEK_API_KEY)
268+
meta_prompt_enabled=True, # Generate task-specific system prompt
269+
judge_model="deepseek-chat",
270+
)
271+
272+
router = Router(goal="summarization", paths=["gpt-4o-mini", "deepseek-chat"])
273+
response = router.completion(
274+
messages=[{"role": "user", "content": "Summarize this article..."}],
275+
healing=True,
276+
heal_config=config,
277+
)
278+
```
279+
280+
## Multi-step pipelines
281+
282+
`router.pipeline()` runs a sequence of goals end-to-end, with healing applied at each step and outputs chained between steps:
283+
284+
```python
285+
from kalibr import Router
286+
287+
router = Router(goal="research", paths=["gpt-4o", "deepseek-chat"])
288+
289+
result = router.pipeline(
290+
[
291+
{
292+
"goal": "research",
293+
"messages": [{"role": "user", "content": "Research this topic..."}],
294+
},
295+
{
296+
"goal": "outreach_generation",
297+
"messages": [{"role": "user", "content": "Write email"}],
298+
"chain": True, # Feed previous step's output into this step
299+
},
300+
],
301+
healing=True,
302+
pipeline_id="my-pipeline",
303+
)
304+
305+
print(result["success"]) # True if all steps succeeded
306+
print(result["total_heals"]) # Total heals across all steps
307+
for step in result["steps"]:
308+
print(step["goal"], step["healed"], step["model_used"])
309+
```
310+
311+
## Pipeline isolation with `pipeline_id`
312+
313+
Pass a `pipeline_id` to keep routing outcomes from bleeding between unrelated agents that share the same goal:
314+
315+
```python
316+
response = router.completion(
317+
messages=[...],
318+
pipeline_id="invoice-processing", # Isolate routing for this pipeline
319+
)
320+
```
321+
322+
Two agents using the same `goal` but different `pipeline_id`s maintain independent bandit state, so a bad run in one pipeline won't shift traffic in the other.
323+
244324
## Paths
245325

246326
A path is any combination of model + tools + params. Kalibr tracks each combination separately and learns which one works best for each goal.
@@ -503,11 +583,11 @@ pytest
503583

504584
## Current Version / Status
505585

506-
- **PyPI version:** `1.12.1` — [pypi.org/project/kalibr](https://pypi.org/project/kalibr/)
586+
- **PyPI version:** `1.14.1` — [pypi.org/project/kalibr](https://pypi.org/project/kalibr/)
507587
- **Python:** 3.10, 3.11, 3.12
508588
- **Status:** Production. Used in live agent pipelines.
509-
- **Latest changes (unreleased):** Tavily search provider, Nebius AI Studio support
510-
- **TS SDK counterpart:** `@kalibr/sdk` v1.12.1 — see [kalibr-sdk-ts](https://github.com/kalibr-ai/kalibr-sdk-ts)
589+
- **Latest changes (1.14.x):** Full heal loop (`healing=True`), `HealConfig` tuning, `router.pipeline()` multi-step execution, `pipeline_id` isolation, Gate 2 LLM judge, LLM meta-prompt generation
590+
- **TS SDK counterpart:** `@kalibr/sdk` v1.14.1 — see [kalibr-sdk-ts](https://github.com/kalibr-ai/kalibr-sdk-ts)
511591

512592
## Contributing
513593

0 commit comments

Comments
 (0)