kalibr 1.2.5__tar.gz → 1.2.7__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.
Files changed (63) hide show
  1. {kalibr-1.2.5 → kalibr-1.2.7}/PKG-INFO +58 -15
  2. kalibr-1.2.7/README.md +163 -0
  3. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/__init__.py +2 -2
  4. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/capsule_cmd.py +3 -3
  5. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/run.py +2 -2
  6. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/client.py +1 -1
  7. kalibr-1.2.7/kalibr/collector.py +336 -0
  8. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/intelligence.py +2 -0
  9. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/middleware/auto_tracer.py +1 -1
  10. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/router.py +84 -50
  11. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/simple_tracer.py +1 -1
  12. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/utils.py +2 -2
  13. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/PKG-INFO +58 -15
  14. {kalibr-1.2.5 → kalibr-1.2.7}/pyproject.toml +2 -2
  15. kalibr-1.2.5/README.md +0 -120
  16. kalibr-1.2.5/kalibr/collector.py +0 -173
  17. {kalibr-1.2.5 → kalibr-1.2.7}/LICENSE +0 -0
  18. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/__main__.py +0 -0
  19. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/capsule_middleware.py +0 -0
  20. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/__init__.py +0 -0
  21. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/deploy_cmd.py +0 -0
  22. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/main.py +0 -0
  23. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cli/serve.py +0 -0
  24. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/context.py +0 -0
  25. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/cost_adapter.py +0 -0
  26. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/decorators.py +0 -0
  27. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/__init__.py +0 -0
  28. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/anthropic_instr.py +0 -0
  29. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/base.py +0 -0
  30. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/google_instr.py +0 -0
  31. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/openai_instr.py +0 -0
  32. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/instrumentation/registry.py +0 -0
  33. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/kalibr.py +0 -0
  34. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/kalibr_app.py +0 -0
  35. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/middleware/__init__.py +0 -0
  36. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/models.py +0 -0
  37. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/redaction.py +0 -0
  38. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/schemas.py +0 -0
  39. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/tokens.py +0 -0
  40. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/trace_capsule.py +0 -0
  41. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/trace_models.py +0 -0
  42. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/tracer.py +0 -0
  43. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr/types.py +0 -0
  44. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/SOURCES.txt +0 -0
  45. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/dependency_links.txt +0 -0
  46. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/entry_points.txt +0 -0
  47. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/requires.txt +0 -0
  48. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr.egg-info/top_level.txt +0 -0
  49. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_crewai/__init__.py +0 -0
  50. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_crewai/callbacks.py +0 -0
  51. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_crewai/instrumentor.py +0 -0
  52. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_langchain/__init__.py +0 -0
  53. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_langchain/async_callback.py +0 -0
  54. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_langchain/callback.py +0 -0
  55. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_langchain/chat_model.py +0 -0
  56. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_openai_agents/__init__.py +0 -0
  57. {kalibr-1.2.5 → kalibr-1.2.7}/kalibr_openai_agents/processor.py +0 -0
  58. {kalibr-1.2.5 → kalibr-1.2.7}/setup.cfg +0 -0
  59. {kalibr-1.2.5 → kalibr-1.2.7}/tests/test_capsule_builder.py +0 -0
  60. {kalibr-1.2.5 → kalibr-1.2.7}/tests/test_instrumentation.py +0 -0
  61. {kalibr-1.2.5 → kalibr-1.2.7}/tests/test_intelligence.py +0 -0
  62. {kalibr-1.2.5 → kalibr-1.2.7}/tests/test_langchain_routing.py +0 -0
  63. {kalibr-1.2.5 → kalibr-1.2.7}/tests/test_router.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kalibr
3
- Version: 1.2.5
4
- Summary: Unified LLM Observability & Multi-Model AI Integration Framework - Deploy to GPT, Claude, Gemini, Copilot with full telemetry.
3
+ Version: 1.2.7
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
@@ -67,7 +67,7 @@ Requires-Dist: ruff>=0.1.0; extra == "dev"
67
67
 
68
68
  # Kalibr
69
69
 
70
- Adaptive routing for AI agents. Kalibr learns which models, tools, and configs work best for each task and routes automatically.
70
+ Adaptive routing for AI agents. Kalibr learns which models work best for your tasks and routes automatically.
71
71
 
72
72
  [![PyPI](https://img.shields.io/pypi/v/kalibr)](https://pypi.org/project/kalibr/)
73
73
  [![Python](https://img.shields.io/pypi/pyversions/kalibr)](https://pypi.org/project/kalibr/)
@@ -83,24 +83,32 @@ pip install kalibr
83
83
  from kalibr import Router
84
84
 
85
85
  router = Router(
86
- goal="book_meeting",
87
- paths=["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"],
88
- success_when=lambda output: "confirmed" in output.lower()
86
+ goal="extract_company",
87
+ paths=["gpt-4o", "claude-sonnet-4-20250514"]
89
88
  )
90
89
 
91
90
  response = router.completion(
92
- messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
91
+ messages=[{"role": "user", "content": "Extract the company: Hi, I'm Sarah from Stripe."}]
93
92
  )
93
+
94
+ router.report(success=True)
94
95
  ```
95
96
 
96
- Kalibr picks the best model, makes the call, checks success, and learns for next time.
97
+ Kalibr picks the best model, makes the call, and learns from the outcome.
98
+
99
+ ## How It Works
100
+
101
+ 1. **You define paths** - models (and optionally tools/params) that can handle your task
102
+ 2. **Kalibr picks** - uses Thompson Sampling to balance exploration vs exploitation
103
+ 3. **You report outcomes** - tell Kalibr if it worked
104
+ 4. **Kalibr learns** - routes more traffic to what works
97
105
 
98
106
  ## Paths
99
107
 
100
108
  A path is a model + optional tools + optional params:
101
109
  ```python
102
110
  # Just models
103
- paths = ["gpt-4o", "claude-sonnet-4-20250514"]
111
+ paths = ["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"]
104
112
 
105
113
  # With tools
106
114
  paths = [
@@ -115,7 +123,21 @@ paths = [
115
123
  ]
116
124
  ```
117
125
 
118
- ## Manual Outcome Reporting
126
+ ## Outcome Reporting
127
+
128
+ ### Automatic (with success_when)
129
+ ```python
130
+ router = Router(
131
+ goal="summarize",
132
+ paths=["gpt-4o", "claude-sonnet-4-20250514"],
133
+ success_when=lambda output: len(output) > 100
134
+ )
135
+
136
+ response = router.completion(messages=[...])
137
+ # Outcome reported automatically based on success_when
138
+ ```
139
+
140
+ ### Manual
119
141
  ```python
120
142
  router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
121
143
  response = router.completion(messages=[...])
@@ -139,7 +161,7 @@ chain = prompt | llm | parser
139
161
 
140
162
  ## Auto-Instrumentation
141
163
 
142
- Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs when imported:
164
+ Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs on import:
143
165
  ```python
144
166
  import kalibr # Must be first import
145
167
  from openai import OpenAI
@@ -151,19 +173,39 @@ response = client.chat.completions.create(model="gpt-4o", messages=[...])
151
173
 
152
174
  Disable with `KALIBR_AUTO_INSTRUMENT=false`.
153
175
 
176
+ ## Low-Level API
177
+
178
+ For advanced use cases, you can use the intelligence API directly:
179
+ ```python
180
+ from kalibr import register_path, decide, report_outcome
181
+
182
+ # Register paths
183
+ register_path(goal="book_meeting", model_id="gpt-4o")
184
+ register_path(goal="book_meeting", model_id="claude-sonnet-4-20250514")
185
+
186
+ # Get routing decision
187
+ decision = decide(goal="book_meeting")
188
+ model = decision["model_id"]
189
+
190
+ # Make your own LLM call, then report
191
+ report_outcome(trace_id="...", goal="book_meeting", success=True)
192
+ ```
193
+
154
194
  ## Other Integrations
155
195
  ```bash
156
196
  pip install kalibr[crewai] # CrewAI
157
197
  pip install kalibr[openai-agents] # OpenAI Agents SDK
198
+ pip install kalibr[langchain-all] # LangChain with all providers
158
199
  ```
159
200
 
160
201
  ## Configuration
161
202
 
162
203
  | Variable | Description | Default |
163
204
  |----------|-------------|---------|
164
- | `KALIBR_API_KEY` | API key | Required |
165
- | `KALIBR_TENANT_ID` | Tenant ID | `default` |
166
- | `KALIBR_AUTO_INSTRUMENT` | Auto-instrument SDKs | `true` |
205
+ | `KALIBR_API_KEY` | API key from dashboard | Required |
206
+ | `KALIBR_TENANT_ID` | Tenant ID from dashboard | Required |
207
+ | `KALIBR_AUTO_INSTRUMENT` | Auto-instrument LLM SDKs | `true` |
208
+ | `KALIBR_INTELLIGENCE_URL` | Intelligence service URL | `https://kalibr-intelligence.fly.dev` |
167
209
 
168
210
  ## Development
169
211
  ```bash
@@ -183,5 +225,6 @@ Apache-2.0
183
225
 
184
226
  ## Links
185
227
 
186
- - [Docs](https://kalibr.systems/docs)
228
+ - [Docs](https://kalibr.dev/docs)
187
229
  - [Dashboard](https://dashboard.kalibr.systems)
230
+ - [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
kalibr-1.2.7/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # Kalibr
2
+
3
+ Adaptive routing for AI agents. Kalibr learns which models work best for your tasks and routes automatically.
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/kalibr)](https://pypi.org/project/kalibr/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/kalibr)](https://pypi.org/project/kalibr/)
7
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](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="extract_company",
20
+ paths=["gpt-4o", "claude-sonnet-4-20250514"]
21
+ )
22
+
23
+ response = router.completion(
24
+ messages=[{"role": "user", "content": "Extract the company: Hi, I'm Sarah from Stripe."}]
25
+ )
26
+
27
+ router.report(success=True)
28
+ ```
29
+
30
+ Kalibr picks the best model, makes the call, and learns from the outcome.
31
+
32
+ ## How It Works
33
+
34
+ 1. **You define paths** - models (and optionally tools/params) that can handle your task
35
+ 2. **Kalibr picks** - uses Thompson Sampling to balance exploration vs exploitation
36
+ 3. **You report outcomes** - tell Kalibr if it worked
37
+ 4. **Kalibr learns** - routes more traffic to what works
38
+
39
+ ## Paths
40
+
41
+ A path is a model + optional tools + optional params:
42
+ ```python
43
+ # Just models
44
+ paths = ["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"]
45
+
46
+ # With tools
47
+ paths = [
48
+ {"model": "gpt-4o", "tools": ["web_search"]},
49
+ {"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
50
+ ]
51
+
52
+ # With params
53
+ paths = [
54
+ {"model": "gpt-4o", "params": {"temperature": 0.7}},
55
+ {"model": "gpt-4o", "params": {"temperature": 0.2}},
56
+ ]
57
+ ```
58
+
59
+ ## Outcome Reporting
60
+
61
+ ### Automatic (with success_when)
62
+ ```python
63
+ router = Router(
64
+ goal="summarize",
65
+ paths=["gpt-4o", "claude-sonnet-4-20250514"],
66
+ success_when=lambda output: len(output) > 100
67
+ )
68
+
69
+ response = router.completion(messages=[...])
70
+ # Outcome reported automatically based on success_when
71
+ ```
72
+
73
+ ### Manual
74
+ ```python
75
+ router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
76
+ response = router.completion(messages=[...])
77
+
78
+ meeting_created = check_calendar_api()
79
+ router.report(success=meeting_created)
80
+ ```
81
+
82
+ ## LangChain Integration
83
+ ```bash
84
+ pip install kalibr[langchain]
85
+ ```
86
+ ```python
87
+ from kalibr import Router
88
+
89
+ router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
90
+ llm = router.as_langchain()
91
+
92
+ chain = prompt | llm | parser
93
+ ```
94
+
95
+ ## Auto-Instrumentation
96
+
97
+ Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs on import:
98
+ ```python
99
+ import kalibr # Must be first import
100
+ from openai import OpenAI
101
+
102
+ client = OpenAI()
103
+ response = client.chat.completions.create(model="gpt-4o", messages=[...])
104
+ # Traced automatically
105
+ ```
106
+
107
+ Disable with `KALIBR_AUTO_INSTRUMENT=false`.
108
+
109
+ ## Low-Level API
110
+
111
+ For advanced use cases, you can use the intelligence API directly:
112
+ ```python
113
+ from kalibr import register_path, decide, report_outcome
114
+
115
+ # Register paths
116
+ register_path(goal="book_meeting", model_id="gpt-4o")
117
+ register_path(goal="book_meeting", model_id="claude-sonnet-4-20250514")
118
+
119
+ # Get routing decision
120
+ decision = decide(goal="book_meeting")
121
+ model = decision["model_id"]
122
+
123
+ # Make your own LLM call, then report
124
+ report_outcome(trace_id="...", goal="book_meeting", success=True)
125
+ ```
126
+
127
+ ## Other Integrations
128
+ ```bash
129
+ pip install kalibr[crewai] # CrewAI
130
+ pip install kalibr[openai-agents] # OpenAI Agents SDK
131
+ pip install kalibr[langchain-all] # LangChain with all providers
132
+ ```
133
+
134
+ ## Configuration
135
+
136
+ | Variable | Description | Default |
137
+ |----------|-------------|---------|
138
+ | `KALIBR_API_KEY` | API key from dashboard | Required |
139
+ | `KALIBR_TENANT_ID` | Tenant ID from dashboard | Required |
140
+ | `KALIBR_AUTO_INSTRUMENT` | Auto-instrument LLM SDKs | `true` |
141
+ | `KALIBR_INTELLIGENCE_URL` | Intelligence service URL | `https://kalibr-intelligence.fly.dev` |
142
+
143
+ ## Development
144
+ ```bash
145
+ git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
146
+ cd kalibr-sdk-python
147
+ pip install -e ".[dev]"
148
+ pytest
149
+ ```
150
+
151
+ ## Contributing
152
+
153
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
154
+
155
+ ## License
156
+
157
+ Apache-2.0
158
+
159
+ ## Links
160
+
161
+ - [Docs](https://kalibr.dev/docs)
162
+ - [Dashboard](https://dashboard.kalibr.systems)
163
+ - [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
@@ -1,4 +1,4 @@
1
- """Kalibr SDK v1.2.0 - LLM Observability & Tracing Framework
1
+ """Kalibr SDK v1.2.7 - LLM Observability & Tracing Framework
2
2
 
3
3
  Features:
4
4
  - **Auto-Instrumentation**: Zero-config tracing of OpenAI, Anthropic, Google SDK calls
@@ -36,7 +36,7 @@ CLI Usage:
36
36
  kalibr version # Show version
37
37
  """
38
38
 
39
- __version__ = "1.2.0"
39
+ __version__ = "1.2.7"
40
40
 
41
41
  # Auto-instrument LLM SDKs on import (can be disabled via env var)
42
42
  import os
@@ -23,7 +23,7 @@ def capsule(
23
23
  None,
24
24
  "--api-url",
25
25
  "-u",
26
- help="Kalibr API base URL (default: from env KALIBR_API_URL or https://api.kalibr.systems)",
26
+ help="Kalibr API base URL (default: from env KALIBR_API_URL or https://kalibr-backend.fly.dev)",
27
27
  envvar="KALIBR_API_URL",
28
28
  ),
29
29
  output: Optional[Path] = typer.Option(
@@ -63,10 +63,10 @@ def capsule(
63
63
  kalibr capsule abc-123-def --export --output capsule.json
64
64
 
65
65
  # Specify custom API URL
66
- kalibr capsule abc-123-def -u https://api.kalibr.systems
66
+ kalibr capsule abc-123-def -u https://kalibr-backend.fly.dev
67
67
  """
68
68
  # Determine API base URL
69
- base_url = api_url or "https://api.kalibr.systems"
69
+ base_url = api_url or "https://kalibr-backend.fly.dev"
70
70
  base_url = base_url.rstrip("/")
71
71
 
72
72
  # Build endpoint URL
@@ -47,7 +47,7 @@ def run(
47
47
  kalibr run weather.py --runtime fly.io
48
48
 
49
49
  # Custom backend
50
- kalibr run weather.py --backend-url https://api.kalibr.systems
50
+ kalibr run weather.py --backend-url https://kalibr-backend.fly.dev
51
51
  """
52
52
  # Validate file exists
53
53
  agent_path = Path(file_path).resolve()
@@ -56,7 +56,7 @@ def run(
56
56
  raise typer.Exit(1)
57
57
 
58
58
  # Configure backend
59
- backend = backend_url or os.getenv("KALIBR_BACKEND_URL", "https://api.kalibr.systems")
59
+ backend = backend_url or os.getenv("KALIBR_BACKEND_URL", "https://kalibr-backend.fly.dev")
60
60
  api_key = os.getenv("KALIBR_API_KEY")
61
61
  if not api_key:
62
62
  console.print("[yellow]⚠️ KALIBR_API_KEY not set. Set it for trace authentication.[/yellow]")
@@ -70,7 +70,7 @@ class KalibrClient:
70
70
 
71
71
  self.api_key = api_key or env_config.get("auth_token", "")
72
72
  self.endpoint = endpoint or env_config.get(
73
- "api_endpoint", "https://api.kalibr.systems/api/v1/traces"
73
+ "api_endpoint", "https://kalibr-backend.fly.dev/api/v1/traces"
74
74
  )
75
75
  self.tenant_id = tenant_id or env_config.get("tenant_id", "default")
76
76
  self.environment = environment or env_config.get("environment", "prod")