kalibr 1.2.4__tar.gz → 1.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kalibr-1.2.4 → kalibr-1.2.6}/PKG-INFO +52 -98
- kalibr-1.2.6/README.md +120 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/PKG-INFO +52 -98
- {kalibr-1.2.4 → kalibr-1.2.6}/pyproject.toml +2 -2
- kalibr-1.2.4/README.md +0 -166
- {kalibr-1.2.4 → kalibr-1.2.6}/LICENSE +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/__main__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/capsule_middleware.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/capsule_cmd.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/deploy_cmd.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/main.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/run.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cli/serve.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/client.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/collector.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/context.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/cost_adapter.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/decorators.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/anthropic_instr.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/base.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/google_instr.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/openai_instr.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/instrumentation/registry.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/intelligence.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/kalibr.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/kalibr_app.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/middleware/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/middleware/auto_tracer.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/models.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/redaction.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/router.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/schemas.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/simple_tracer.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/tokens.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/trace_capsule.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/trace_models.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/tracer.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/types.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr/utils.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/SOURCES.txt +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/dependency_links.txt +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/entry_points.txt +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/requires.txt +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr.egg-info/top_level.txt +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_crewai/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_crewai/callbacks.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_crewai/instrumentor.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_langchain/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_langchain/async_callback.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_langchain/callback.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_langchain/chat_model.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_openai_agents/__init__.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/kalibr_openai_agents/processor.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/setup.cfg +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/tests/test_capsule_builder.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/tests/test_instrumentation.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/tests/test_intelligence.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/tests/test_langchain_routing.py +0 -0
- {kalibr-1.2.4 → kalibr-1.2.6}/tests/test_router.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: kalibr
|
|
3
|
-
Version: 1.2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.2.6
|
|
4
|
+
Summary: Adaptive routing for AI agents. Learns which models work best and routes automatically.
|
|
5
5
|
Author-email: Kalibr Team <support@kalibr.systems>
|
|
6
6
|
License: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://github.com/kalibr-ai/kalibr-sdk-python
|
|
@@ -65,17 +65,18 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
|
65
65
|
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
66
66
|
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
67
67
|
|
|
68
|
-
# Kalibr
|
|
68
|
+
# Kalibr
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Adaptive routing for AI agents. Kalibr learns which models, tools, and configs work best for each task and routes automatically.
|
|
71
|
+
|
|
72
|
+
[](https://pypi.org/project/kalibr/)
|
|
73
|
+
[](https://pypi.org/project/kalibr/)
|
|
74
|
+
[](LICENSE)
|
|
71
75
|
|
|
72
76
|
## Installation
|
|
73
77
|
```bash
|
|
74
78
|
pip install kalibr
|
|
75
79
|
```
|
|
76
|
-
```bash
|
|
77
|
-
export KALIBR_API_KEY=kal_xxx # Get from dashboard.kalibr.dev
|
|
78
|
-
```
|
|
79
80
|
|
|
80
81
|
## Quick Start
|
|
81
82
|
```python
|
|
@@ -83,42 +84,28 @@ from kalibr import Router
|
|
|
83
84
|
|
|
84
85
|
router = Router(
|
|
85
86
|
goal="book_meeting",
|
|
86
|
-
paths=["gpt-4o", "claude-
|
|
87
|
+
paths=["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"],
|
|
87
88
|
success_when=lambda output: "confirmed" in output.lower()
|
|
88
89
|
)
|
|
89
90
|
|
|
90
91
|
response = router.completion(
|
|
91
92
|
messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
|
|
92
93
|
)
|
|
93
|
-
|
|
94
|
-
print(response.choices[0].message.content)
|
|
95
94
|
```
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
- ✅ Picking the best model (Thompson Sampling)
|
|
99
|
-
- ✅ Making the API call
|
|
100
|
-
- ✅ Checking success
|
|
101
|
-
- ✅ Learning for next time
|
|
102
|
-
- ✅ Tracing everything
|
|
103
|
-
|
|
104
|
-
## How It Works
|
|
105
|
-
|
|
106
|
-
1. **Define a goal** - What is your agent trying to do?
|
|
107
|
-
2. **Register paths** - Which models/tools can achieve it?
|
|
108
|
-
3. **Report outcomes** - Did it work?
|
|
109
|
-
4. **Kalibr routes** - Traffic shifts to winners
|
|
96
|
+
Kalibr picks the best model, makes the call, checks success, and learns for next time.
|
|
110
97
|
|
|
111
98
|
## Paths
|
|
112
99
|
|
|
113
100
|
A path is a model + optional tools + optional params:
|
|
114
101
|
```python
|
|
115
|
-
#
|
|
116
|
-
paths = ["gpt-4o", "claude-
|
|
102
|
+
# Just models
|
|
103
|
+
paths = ["gpt-4o", "claude-sonnet-4-20250514"]
|
|
117
104
|
|
|
118
105
|
# With tools
|
|
119
106
|
paths = [
|
|
120
107
|
{"model": "gpt-4o", "tools": ["web_search"]},
|
|
121
|
-
{"model": "claude-
|
|
108
|
+
{"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
|
|
122
109
|
]
|
|
123
110
|
|
|
124
111
|
# With params
|
|
@@ -128,106 +115,73 @@ paths = [
|
|
|
128
115
|
]
|
|
129
116
|
```
|
|
130
117
|
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
### Auto-detect from output
|
|
134
|
-
```python
|
|
135
|
-
router = Router(
|
|
136
|
-
goal="summarize",
|
|
137
|
-
paths=["gpt-4o", "claude-3-sonnet"],
|
|
138
|
-
success_when=lambda output: len(output) > 100
|
|
139
|
-
)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Manual reporting
|
|
118
|
+
## Manual Outcome Reporting
|
|
143
119
|
```python
|
|
144
|
-
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-
|
|
145
|
-
|
|
120
|
+
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
146
121
|
response = router.completion(messages=[...])
|
|
147
122
|
|
|
148
|
-
# Your verification logic
|
|
149
123
|
meeting_created = check_calendar_api()
|
|
150
|
-
|
|
151
124
|
router.report(success=meeting_created)
|
|
152
125
|
```
|
|
153
126
|
|
|
154
|
-
##
|
|
155
|
-
|
|
156
|
-
|
|
127
|
+
## LangChain Integration
|
|
128
|
+
```bash
|
|
129
|
+
pip install kalibr[langchain]
|
|
130
|
+
```
|
|
157
131
|
```python
|
|
158
132
|
from kalibr import Router
|
|
159
133
|
|
|
160
|
-
router = Router(goal="summarize", paths=["gpt-4o", "claude-
|
|
134
|
+
router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
161
135
|
llm = router.as_langchain()
|
|
162
136
|
|
|
163
137
|
chain = prompt | llm | parser
|
|
164
|
-
result = chain.invoke({"text": "..."})
|
|
165
138
|
```
|
|
166
139
|
|
|
167
|
-
|
|
168
|
-
```python
|
|
169
|
-
from kalibr import Router
|
|
140
|
+
## Auto-Instrumentation
|
|
170
141
|
|
|
171
|
-
|
|
142
|
+
Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs when imported:
|
|
143
|
+
```python
|
|
144
|
+
import kalibr # Must be first import
|
|
145
|
+
from openai import OpenAI
|
|
172
146
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
...
|
|
177
|
-
)
|
|
147
|
+
client = OpenAI()
|
|
148
|
+
response = client.chat.completions.create(model="gpt-4o", messages=[...])
|
|
149
|
+
# Traced automatically
|
|
178
150
|
```
|
|
179
151
|
|
|
180
|
-
|
|
152
|
+
Disable with `KALIBR_AUTO_INSTRUMENT=false`.
|
|
181
153
|
|
|
182
|
-
|
|
154
|
+
## Other Integrations
|
|
155
|
+
```bash
|
|
156
|
+
pip install kalibr[crewai] # CrewAI
|
|
157
|
+
pip install kalibr[openai-agents] # OpenAI Agents SDK
|
|
158
|
+
```
|
|
183
159
|
|
|
184
|
-
|
|
185
|
-
- Latency (p50, p95, p99)
|
|
186
|
-
- Tool usage
|
|
187
|
-
- Errors with stack traces
|
|
160
|
+
## Configuration
|
|
188
161
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
162
|
+
| Variable | Description | Default |
|
|
163
|
+
|----------|-------------|---------|
|
|
164
|
+
| `KALIBR_API_KEY` | API key | Required |
|
|
165
|
+
| `KALIBR_TENANT_ID` | Tenant ID | `default` |
|
|
166
|
+
| `KALIBR_AUTO_INSTRUMENT` | Auto-instrument SDKs | `true` |
|
|
192
167
|
|
|
193
|
-
|
|
194
|
-
|
|
168
|
+
## Development
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
|
|
171
|
+
cd kalibr-sdk-python
|
|
172
|
+
pip install -e ".[dev]"
|
|
173
|
+
pytest
|
|
195
174
|
```
|
|
196
175
|
|
|
197
|
-
##
|
|
176
|
+
## Contributing
|
|
198
177
|
|
|
199
|
-
|
|
200
|
-
|------|-------------------|-------|
|
|
201
|
-
| Free | 1,000/month | $0 |
|
|
202
|
-
| Pro | 50,000/month | $49/month |
|
|
203
|
-
| Enterprise | Unlimited | Custom |
|
|
178
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
204
179
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
### Router
|
|
208
|
-
```python
|
|
209
|
-
Router(
|
|
210
|
-
goal: str, # Required: name of the goal
|
|
211
|
-
paths: List[str | dict], # Models/tools to route between
|
|
212
|
-
success_when: Callable, # Optional: auto-evaluate success
|
|
213
|
-
exploration_rate: float, # Optional: 0.0-1.0, default 0.1
|
|
214
|
-
)
|
|
215
|
-
```
|
|
180
|
+
## License
|
|
216
181
|
|
|
217
|
-
|
|
218
|
-
```python
|
|
219
|
-
router.completion(messages, **kwargs) # Make routed request
|
|
220
|
-
router.report(success, reason=None) # Report outcome manually
|
|
221
|
-
router.add_path(model, tools=None) # Add path dynamically
|
|
222
|
-
router.as_langchain() # Get LangChain-compatible LLM
|
|
223
|
-
```
|
|
182
|
+
Apache-2.0
|
|
224
183
|
|
|
225
184
|
## Links
|
|
226
185
|
|
|
227
|
-
- [
|
|
228
|
-
- [Dashboard](https://dashboard.kalibr.
|
|
229
|
-
- [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
|
|
230
|
-
|
|
231
|
-
## License
|
|
232
|
-
|
|
233
|
-
MIT
|
|
186
|
+
- [Docs](https://kalibr.systems/docs)
|
|
187
|
+
- [Dashboard](https://dashboard.kalibr.systems)
|
kalibr-1.2.6/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Kalibr
|
|
2
|
+
|
|
3
|
+
Adaptive routing for AI agents. Kalibr learns which models, tools, and configs work best for each task and routes automatically.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/kalibr/)
|
|
6
|
+
[](https://pypi.org/project/kalibr/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
```bash
|
|
11
|
+
pip install kalibr
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
```python
|
|
16
|
+
from kalibr import Router
|
|
17
|
+
|
|
18
|
+
router = Router(
|
|
19
|
+
goal="book_meeting",
|
|
20
|
+
paths=["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"],
|
|
21
|
+
success_when=lambda output: "confirmed" in output.lower()
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
response = router.completion(
|
|
25
|
+
messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Kalibr picks the best model, makes the call, checks success, and learns for next time.
|
|
30
|
+
|
|
31
|
+
## Paths
|
|
32
|
+
|
|
33
|
+
A path is a model + optional tools + optional params:
|
|
34
|
+
```python
|
|
35
|
+
# Just models
|
|
36
|
+
paths = ["gpt-4o", "claude-sonnet-4-20250514"]
|
|
37
|
+
|
|
38
|
+
# With tools
|
|
39
|
+
paths = [
|
|
40
|
+
{"model": "gpt-4o", "tools": ["web_search"]},
|
|
41
|
+
{"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
# With params
|
|
45
|
+
paths = [
|
|
46
|
+
{"model": "gpt-4o", "params": {"temperature": 0.7}},
|
|
47
|
+
{"model": "gpt-4o", "params": {"temperature": 0.2}},
|
|
48
|
+
]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Manual Outcome Reporting
|
|
52
|
+
```python
|
|
53
|
+
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
54
|
+
response = router.completion(messages=[...])
|
|
55
|
+
|
|
56
|
+
meeting_created = check_calendar_api()
|
|
57
|
+
router.report(success=meeting_created)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## LangChain Integration
|
|
61
|
+
```bash
|
|
62
|
+
pip install kalibr[langchain]
|
|
63
|
+
```
|
|
64
|
+
```python
|
|
65
|
+
from kalibr import Router
|
|
66
|
+
|
|
67
|
+
router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
68
|
+
llm = router.as_langchain()
|
|
69
|
+
|
|
70
|
+
chain = prompt | llm | parser
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Auto-Instrumentation
|
|
74
|
+
|
|
75
|
+
Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs when imported:
|
|
76
|
+
```python
|
|
77
|
+
import kalibr # Must be first import
|
|
78
|
+
from openai import OpenAI
|
|
79
|
+
|
|
80
|
+
client = OpenAI()
|
|
81
|
+
response = client.chat.completions.create(model="gpt-4o", messages=[...])
|
|
82
|
+
# Traced automatically
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Disable with `KALIBR_AUTO_INSTRUMENT=false`.
|
|
86
|
+
|
|
87
|
+
## Other Integrations
|
|
88
|
+
```bash
|
|
89
|
+
pip install kalibr[crewai] # CrewAI
|
|
90
|
+
pip install kalibr[openai-agents] # OpenAI Agents SDK
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
| Variable | Description | Default |
|
|
96
|
+
|----------|-------------|---------|
|
|
97
|
+
| `KALIBR_API_KEY` | API key | Required |
|
|
98
|
+
| `KALIBR_TENANT_ID` | Tenant ID | `default` |
|
|
99
|
+
| `KALIBR_AUTO_INSTRUMENT` | Auto-instrument SDKs | `true` |
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
```bash
|
|
103
|
+
git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
|
|
104
|
+
cd kalibr-sdk-python
|
|
105
|
+
pip install -e ".[dev]"
|
|
106
|
+
pytest
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
Apache-2.0
|
|
116
|
+
|
|
117
|
+
## Links
|
|
118
|
+
|
|
119
|
+
- [Docs](https://kalibr.systems/docs)
|
|
120
|
+
- [Dashboard](https://dashboard.kalibr.systems)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: kalibr
|
|
3
|
-
Version: 1.2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.2.6
|
|
4
|
+
Summary: Adaptive routing for AI agents. Learns which models work best and routes automatically.
|
|
5
5
|
Author-email: Kalibr Team <support@kalibr.systems>
|
|
6
6
|
License: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://github.com/kalibr-ai/kalibr-sdk-python
|
|
@@ -65,17 +65,18 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
|
65
65
|
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
66
66
|
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
67
67
|
|
|
68
|
-
# Kalibr
|
|
68
|
+
# Kalibr
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Adaptive routing for AI agents. Kalibr learns which models, tools, and configs work best for each task and routes automatically.
|
|
71
|
+
|
|
72
|
+
[](https://pypi.org/project/kalibr/)
|
|
73
|
+
[](https://pypi.org/project/kalibr/)
|
|
74
|
+
[](LICENSE)
|
|
71
75
|
|
|
72
76
|
## Installation
|
|
73
77
|
```bash
|
|
74
78
|
pip install kalibr
|
|
75
79
|
```
|
|
76
|
-
```bash
|
|
77
|
-
export KALIBR_API_KEY=kal_xxx # Get from dashboard.kalibr.dev
|
|
78
|
-
```
|
|
79
80
|
|
|
80
81
|
## Quick Start
|
|
81
82
|
```python
|
|
@@ -83,42 +84,28 @@ from kalibr import Router
|
|
|
83
84
|
|
|
84
85
|
router = Router(
|
|
85
86
|
goal="book_meeting",
|
|
86
|
-
paths=["gpt-4o", "claude-
|
|
87
|
+
paths=["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"],
|
|
87
88
|
success_when=lambda output: "confirmed" in output.lower()
|
|
88
89
|
)
|
|
89
90
|
|
|
90
91
|
response = router.completion(
|
|
91
92
|
messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
|
|
92
93
|
)
|
|
93
|
-
|
|
94
|
-
print(response.choices[0].message.content)
|
|
95
94
|
```
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
- ✅ Picking the best model (Thompson Sampling)
|
|
99
|
-
- ✅ Making the API call
|
|
100
|
-
- ✅ Checking success
|
|
101
|
-
- ✅ Learning for next time
|
|
102
|
-
- ✅ Tracing everything
|
|
103
|
-
|
|
104
|
-
## How It Works
|
|
105
|
-
|
|
106
|
-
1. **Define a goal** - What is your agent trying to do?
|
|
107
|
-
2. **Register paths** - Which models/tools can achieve it?
|
|
108
|
-
3. **Report outcomes** - Did it work?
|
|
109
|
-
4. **Kalibr routes** - Traffic shifts to winners
|
|
96
|
+
Kalibr picks the best model, makes the call, checks success, and learns for next time.
|
|
110
97
|
|
|
111
98
|
## Paths
|
|
112
99
|
|
|
113
100
|
A path is a model + optional tools + optional params:
|
|
114
101
|
```python
|
|
115
|
-
#
|
|
116
|
-
paths = ["gpt-4o", "claude-
|
|
102
|
+
# Just models
|
|
103
|
+
paths = ["gpt-4o", "claude-sonnet-4-20250514"]
|
|
117
104
|
|
|
118
105
|
# With tools
|
|
119
106
|
paths = [
|
|
120
107
|
{"model": "gpt-4o", "tools": ["web_search"]},
|
|
121
|
-
{"model": "claude-
|
|
108
|
+
{"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
|
|
122
109
|
]
|
|
123
110
|
|
|
124
111
|
# With params
|
|
@@ -128,106 +115,73 @@ paths = [
|
|
|
128
115
|
]
|
|
129
116
|
```
|
|
130
117
|
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
### Auto-detect from output
|
|
134
|
-
```python
|
|
135
|
-
router = Router(
|
|
136
|
-
goal="summarize",
|
|
137
|
-
paths=["gpt-4o", "claude-3-sonnet"],
|
|
138
|
-
success_when=lambda output: len(output) > 100
|
|
139
|
-
)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Manual reporting
|
|
118
|
+
## Manual Outcome Reporting
|
|
143
119
|
```python
|
|
144
|
-
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-
|
|
145
|
-
|
|
120
|
+
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
146
121
|
response = router.completion(messages=[...])
|
|
147
122
|
|
|
148
|
-
# Your verification logic
|
|
149
123
|
meeting_created = check_calendar_api()
|
|
150
|
-
|
|
151
124
|
router.report(success=meeting_created)
|
|
152
125
|
```
|
|
153
126
|
|
|
154
|
-
##
|
|
155
|
-
|
|
156
|
-
|
|
127
|
+
## LangChain Integration
|
|
128
|
+
```bash
|
|
129
|
+
pip install kalibr[langchain]
|
|
130
|
+
```
|
|
157
131
|
```python
|
|
158
132
|
from kalibr import Router
|
|
159
133
|
|
|
160
|
-
router = Router(goal="summarize", paths=["gpt-4o", "claude-
|
|
134
|
+
router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
|
|
161
135
|
llm = router.as_langchain()
|
|
162
136
|
|
|
163
137
|
chain = prompt | llm | parser
|
|
164
|
-
result = chain.invoke({"text": "..."})
|
|
165
138
|
```
|
|
166
139
|
|
|
167
|
-
|
|
168
|
-
```python
|
|
169
|
-
from kalibr import Router
|
|
140
|
+
## Auto-Instrumentation
|
|
170
141
|
|
|
171
|
-
|
|
142
|
+
Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs when imported:
|
|
143
|
+
```python
|
|
144
|
+
import kalibr # Must be first import
|
|
145
|
+
from openai import OpenAI
|
|
172
146
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
...
|
|
177
|
-
)
|
|
147
|
+
client = OpenAI()
|
|
148
|
+
response = client.chat.completions.create(model="gpt-4o", messages=[...])
|
|
149
|
+
# Traced automatically
|
|
178
150
|
```
|
|
179
151
|
|
|
180
|
-
|
|
152
|
+
Disable with `KALIBR_AUTO_INSTRUMENT=false`.
|
|
181
153
|
|
|
182
|
-
|
|
154
|
+
## Other Integrations
|
|
155
|
+
```bash
|
|
156
|
+
pip install kalibr[crewai] # CrewAI
|
|
157
|
+
pip install kalibr[openai-agents] # OpenAI Agents SDK
|
|
158
|
+
```
|
|
183
159
|
|
|
184
|
-
|
|
185
|
-
- Latency (p50, p95, p99)
|
|
186
|
-
- Tool usage
|
|
187
|
-
- Errors with stack traces
|
|
160
|
+
## Configuration
|
|
188
161
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
162
|
+
| Variable | Description | Default |
|
|
163
|
+
|----------|-------------|---------|
|
|
164
|
+
| `KALIBR_API_KEY` | API key | Required |
|
|
165
|
+
| `KALIBR_TENANT_ID` | Tenant ID | `default` |
|
|
166
|
+
| `KALIBR_AUTO_INSTRUMENT` | Auto-instrument SDKs | `true` |
|
|
192
167
|
|
|
193
|
-
|
|
194
|
-
|
|
168
|
+
## Development
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
|
|
171
|
+
cd kalibr-sdk-python
|
|
172
|
+
pip install -e ".[dev]"
|
|
173
|
+
pytest
|
|
195
174
|
```
|
|
196
175
|
|
|
197
|
-
##
|
|
176
|
+
## Contributing
|
|
198
177
|
|
|
199
|
-
|
|
200
|
-
|------|-------------------|-------|
|
|
201
|
-
| Free | 1,000/month | $0 |
|
|
202
|
-
| Pro | 50,000/month | $49/month |
|
|
203
|
-
| Enterprise | Unlimited | Custom |
|
|
178
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
204
179
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
### Router
|
|
208
|
-
```python
|
|
209
|
-
Router(
|
|
210
|
-
goal: str, # Required: name of the goal
|
|
211
|
-
paths: List[str | dict], # Models/tools to route between
|
|
212
|
-
success_when: Callable, # Optional: auto-evaluate success
|
|
213
|
-
exploration_rate: float, # Optional: 0.0-1.0, default 0.1
|
|
214
|
-
)
|
|
215
|
-
```
|
|
180
|
+
## License
|
|
216
181
|
|
|
217
|
-
|
|
218
|
-
```python
|
|
219
|
-
router.completion(messages, **kwargs) # Make routed request
|
|
220
|
-
router.report(success, reason=None) # Report outcome manually
|
|
221
|
-
router.add_path(model, tools=None) # Add path dynamically
|
|
222
|
-
router.as_langchain() # Get LangChain-compatible LLM
|
|
223
|
-
```
|
|
182
|
+
Apache-2.0
|
|
224
183
|
|
|
225
184
|
## Links
|
|
226
185
|
|
|
227
|
-
- [
|
|
228
|
-
- [Dashboard](https://dashboard.kalibr.
|
|
229
|
-
- [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
|
|
230
|
-
|
|
231
|
-
## License
|
|
232
|
-
|
|
233
|
-
MIT
|
|
186
|
+
- [Docs](https://kalibr.systems/docs)
|
|
187
|
+
- [Dashboard](https://dashboard.kalibr.systems)
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "kalibr"
|
|
7
|
-
version = "1.2.
|
|
8
|
-
description = "
|
|
7
|
+
version = "1.2.6"
|
|
8
|
+
description = "Adaptive routing for AI agents. Learns which models work best and routes automatically."
|
|
9
9
|
authors = [{name = "Kalibr Team", email = "support@kalibr.systems"}]
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.9"
|
kalibr-1.2.4/README.md
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# Kalibr SDK
|
|
2
|
-
|
|
3
|
-
**Intelligent routing for AI agents.** Kalibr picks the best model for each request, learns from outcomes, and shifts traffic to what works.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
```bash
|
|
7
|
-
pip install kalibr
|
|
8
|
-
```
|
|
9
|
-
```bash
|
|
10
|
-
export KALIBR_API_KEY=kal_xxx # Get from dashboard.kalibr.dev
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
```python
|
|
15
|
-
from kalibr import Router
|
|
16
|
-
|
|
17
|
-
router = Router(
|
|
18
|
-
goal="book_meeting",
|
|
19
|
-
paths=["gpt-4o", "claude-3-sonnet", "gpt-4o-mini"],
|
|
20
|
-
success_when=lambda output: "confirmed" in output.lower()
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
response = router.completion(
|
|
24
|
-
messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
print(response.choices[0].message.content)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
That's it. Kalibr handles:
|
|
31
|
-
- ✅ Picking the best model (Thompson Sampling)
|
|
32
|
-
- ✅ Making the API call
|
|
33
|
-
- ✅ Checking success
|
|
34
|
-
- ✅ Learning for next time
|
|
35
|
-
- ✅ Tracing everything
|
|
36
|
-
|
|
37
|
-
## How It Works
|
|
38
|
-
|
|
39
|
-
1. **Define a goal** - What is your agent trying to do?
|
|
40
|
-
2. **Register paths** - Which models/tools can achieve it?
|
|
41
|
-
3. **Report outcomes** - Did it work?
|
|
42
|
-
4. **Kalibr routes** - Traffic shifts to winners
|
|
43
|
-
|
|
44
|
-
## Paths
|
|
45
|
-
|
|
46
|
-
A path is a model + optional tools + optional params:
|
|
47
|
-
```python
|
|
48
|
-
# Simple: just models
|
|
49
|
-
paths = ["gpt-4o", "claude-3-sonnet"]
|
|
50
|
-
|
|
51
|
-
# With tools
|
|
52
|
-
paths = [
|
|
53
|
-
{"model": "gpt-4o", "tools": ["web_search"]},
|
|
54
|
-
{"model": "claude-3-sonnet", "tools": ["web_search", "browser"]},
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
# With params
|
|
58
|
-
paths = [
|
|
59
|
-
{"model": "gpt-4o", "params": {"temperature": 0.7}},
|
|
60
|
-
{"model": "gpt-4o", "params": {"temperature": 0.2}},
|
|
61
|
-
]
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Success Criteria
|
|
65
|
-
|
|
66
|
-
### Auto-detect from output
|
|
67
|
-
```python
|
|
68
|
-
router = Router(
|
|
69
|
-
goal="summarize",
|
|
70
|
-
paths=["gpt-4o", "claude-3-sonnet"],
|
|
71
|
-
success_when=lambda output: len(output) > 100
|
|
72
|
-
)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Manual reporting
|
|
76
|
-
```python
|
|
77
|
-
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-3-sonnet"])
|
|
78
|
-
|
|
79
|
-
response = router.completion(messages=[...])
|
|
80
|
-
|
|
81
|
-
# Your verification logic
|
|
82
|
-
meeting_created = check_calendar_api()
|
|
83
|
-
|
|
84
|
-
router.report(success=meeting_created)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Framework Integration
|
|
88
|
-
|
|
89
|
-
### LangChain
|
|
90
|
-
```python
|
|
91
|
-
from kalibr import Router
|
|
92
|
-
|
|
93
|
-
router = Router(goal="summarize", paths=["gpt-4o", "claude-3-sonnet"])
|
|
94
|
-
llm = router.as_langchain()
|
|
95
|
-
|
|
96
|
-
chain = prompt | llm | parser
|
|
97
|
-
result = chain.invoke({"text": "..."})
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### CrewAI
|
|
101
|
-
```python
|
|
102
|
-
from kalibr import Router
|
|
103
|
-
|
|
104
|
-
router = Router(goal="research", paths=["gpt-4o", "claude-3-sonnet"])
|
|
105
|
-
|
|
106
|
-
agent = Agent(
|
|
107
|
-
role="Researcher",
|
|
108
|
-
llm=router.as_langchain(),
|
|
109
|
-
...
|
|
110
|
-
)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Observability (Included)
|
|
114
|
-
|
|
115
|
-
Every call is automatically traced:
|
|
116
|
-
|
|
117
|
-
- Token counts and costs
|
|
118
|
-
- Latency (p50, p95, p99)
|
|
119
|
-
- Tool usage
|
|
120
|
-
- Errors with stack traces
|
|
121
|
-
|
|
122
|
-
View in the [dashboard](https://dashboard.kalibr.dev) or use callback handlers directly:
|
|
123
|
-
```python
|
|
124
|
-
from kalibr_langchain import KalibrCallbackHandler
|
|
125
|
-
|
|
126
|
-
handler = KalibrCallbackHandler()
|
|
127
|
-
chain.invoke({"input": "..."}, config={"callbacks": [handler]})
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Pricing
|
|
131
|
-
|
|
132
|
-
| Tier | Routing Decisions | Price |
|
|
133
|
-
|------|-------------------|-------|
|
|
134
|
-
| Free | 1,000/month | $0 |
|
|
135
|
-
| Pro | 50,000/month | $49/month |
|
|
136
|
-
| Enterprise | Unlimited | Custom |
|
|
137
|
-
|
|
138
|
-
## API Reference
|
|
139
|
-
|
|
140
|
-
### Router
|
|
141
|
-
```python
|
|
142
|
-
Router(
|
|
143
|
-
goal: str, # Required: name of the goal
|
|
144
|
-
paths: List[str | dict], # Models/tools to route between
|
|
145
|
-
success_when: Callable, # Optional: auto-evaluate success
|
|
146
|
-
exploration_rate: float, # Optional: 0.0-1.0, default 0.1
|
|
147
|
-
)
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Methods
|
|
151
|
-
```python
|
|
152
|
-
router.completion(messages, **kwargs) # Make routed request
|
|
153
|
-
router.report(success, reason=None) # Report outcome manually
|
|
154
|
-
router.add_path(model, tools=None) # Add path dynamically
|
|
155
|
-
router.as_langchain() # Get LangChain-compatible LLM
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Links
|
|
159
|
-
|
|
160
|
-
- [Documentation](https://docs.kalibr.dev)
|
|
161
|
-
- [Dashboard](https://dashboard.kalibr.dev)
|
|
162
|
-
- [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
|
|
163
|
-
|
|
164
|
-
## License
|
|
165
|
-
|
|
166
|
-
MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|