kalibr 1.2.0__tar.gz → 1.2.2__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 (58) hide show
  1. {kalibr-1.2.0 → kalibr-1.2.2}/PKG-INFO +48 -14
  2. {kalibr-1.2.0 → kalibr-1.2.2}/README.md +46 -11
  3. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/__init__.py +20 -1
  4. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/context.py +42 -0
  5. kalibr-1.2.2/kalibr/intelligence.py +650 -0
  6. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/PKG-INFO +48 -14
  7. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_crewai/callbacks.py +122 -14
  8. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_crewai/instrumentor.py +164 -33
  9. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_langchain/callback.py +26 -0
  10. {kalibr-1.2.0 → kalibr-1.2.2}/pyproject.toml +2 -2
  11. kalibr-1.2.0/kalibr/intelligence.py +0 -317
  12. {kalibr-1.2.0 → kalibr-1.2.2}/LICENSE +0 -0
  13. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/__main__.py +0 -0
  14. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/capsule_middleware.py +0 -0
  15. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/__init__.py +0 -0
  16. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/capsule_cmd.py +0 -0
  17. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/deploy_cmd.py +0 -0
  18. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/main.py +0 -0
  19. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/run.py +0 -0
  20. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cli/serve.py +0 -0
  21. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/client.py +0 -0
  22. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/collector.py +0 -0
  23. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/cost_adapter.py +0 -0
  24. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/decorators.py +0 -0
  25. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/__init__.py +0 -0
  26. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/anthropic_instr.py +0 -0
  27. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/base.py +0 -0
  28. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/google_instr.py +0 -0
  29. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/openai_instr.py +0 -0
  30. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/instrumentation/registry.py +0 -0
  31. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/kalibr.py +0 -0
  32. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/kalibr_app.py +0 -0
  33. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/middleware/__init__.py +0 -0
  34. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/middleware/auto_tracer.py +0 -0
  35. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/models.py +0 -0
  36. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/redaction.py +0 -0
  37. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/schemas.py +0 -0
  38. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/simple_tracer.py +0 -0
  39. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/tokens.py +0 -0
  40. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/trace_capsule.py +0 -0
  41. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/trace_models.py +0 -0
  42. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/tracer.py +0 -0
  43. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/types.py +0 -0
  44. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr/utils.py +0 -0
  45. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/SOURCES.txt +0 -0
  46. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/dependency_links.txt +0 -0
  47. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/entry_points.txt +0 -0
  48. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/requires.txt +0 -0
  49. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr.egg-info/top_level.txt +0 -0
  50. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_crewai/__init__.py +0 -0
  51. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_langchain/__init__.py +0 -0
  52. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_langchain/async_callback.py +0 -0
  53. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_openai_agents/__init__.py +0 -0
  54. {kalibr-1.2.0 → kalibr-1.2.2}/kalibr_openai_agents/processor.py +0 -0
  55. {kalibr-1.2.0 → kalibr-1.2.2}/setup.cfg +0 -0
  56. {kalibr-1.2.0 → kalibr-1.2.2}/tests/test_capsule_builder.py +0 -0
  57. {kalibr-1.2.0 → kalibr-1.2.2}/tests/test_instrumentation.py +0 -0
  58. {kalibr-1.2.0 → kalibr-1.2.2}/tests/test_intelligence.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: kalibr
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Unified LLM Observability & Multi-Model AI Integration Framework - Deploy to GPT, Claude, Gemini, Copilot with full telemetry.
5
5
  Author-email: Kalibr Team <support@kalibr.systems>
6
6
  License: Apache-2.0
@@ -64,7 +64,6 @@ Requires-Dist: pytest>=7.4.0; extra == "dev"
64
64
  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
- Dynamic: license-file
68
67
 
69
68
  # Kalibr Python SDK
70
69
 
@@ -188,6 +187,41 @@ policy = get_policy(
188
187
  )
189
188
  ```
190
189
 
190
+ ### Intelligent Routing with decide()
191
+
192
+ Register execution paths and let Kalibr decide the best strategy:
193
+
194
+ ```python
195
+ from kalibr import register_path, decide
196
+
197
+ # Register available paths
198
+ register_path(goal="book_meeting", model_id="gpt-4o", tool_id="calendar_api")
199
+ register_path(goal="book_meeting", model_id="claude-3-sonnet")
200
+
201
+ # Get intelligent routing decision
202
+ decision = decide(goal="book_meeting")
203
+ model = decision["model_id"] # Selected based on outcomes
204
+ tool = decision.get("tool_id") # If tool routing enabled
205
+ print(decision["exploration"]) # True if exploring new paths
206
+ ```
207
+
208
+ ### Goal Context
209
+
210
+ Tag traces with goals for outcome tracking:
211
+
212
+ ```python
213
+ from kalibr import goal, set_goal, get_goal, clear_goal
214
+
215
+ # Context manager (recommended)
216
+ with goal("book_meeting"):
217
+ response = openai.chat.completions.create(...)
218
+
219
+ # Or manual control
220
+ set_goal("book_meeting")
221
+ response = openai.chat.completions.create(...)
222
+ clear_goal()
223
+ ```
224
+
191
225
  ## TraceCapsule - Cross-Agent Tracing
192
226
 
193
227
  Propagate trace context across agent boundaries:
@@ -285,7 +319,7 @@ Configure via environment variables:
285
319
  | `KALIBR_API_KEY` | API key for authentication | *Required* |
286
320
  | `KALIBR_TENANT_ID` | Tenant identifier | `default` |
287
321
  | `KALIBR_COLLECTOR_URL` | Collector endpoint URL | `https://api.kalibr.systems/api/ingest` |
288
- | `KALIBR_INTELLIGENCE_URL` | Intelligence API URL | `https://kalibr-intelligence.fly.dev` |
322
+ | `KALIBR_INTELLIGENCE_URL` | Intelligence API URL | `https://dashboard.kalibr.systems/intelligence` |
289
323
  | `KALIBR_SERVICE_NAME` | Service name for spans | `kalibr-app` |
290
324
  | `KALIBR_ENVIRONMENT` | Environment (prod/staging/dev) | `prod` |
291
325
  | `KALIBR_WORKFLOW_ID` | Workflow identifier | `default` |
@@ -294,20 +328,20 @@ Configure via environment variables:
294
328
  ## CLI Commands
295
329
 
296
330
  ```bash
297
- # Serve your app with tracing
298
- kalibr serve myapp.py
331
+ # Show version
332
+ kalibr version
299
333
 
300
- # Run with managed runtime
301
- kalibr run myapp.py --port 8000
334
+ # Validate configuration
335
+ kalibr validate
302
336
 
303
- # Deploy to cloud platforms
304
- kalibr deploy myapp.py --runtime fly.io
337
+ # Check connection status
338
+ kalibr status
305
339
 
306
- # Fetch trace capsule by ID
307
- kalibr capsule <trace-id>
340
+ # Package for deployment
341
+ kalibr package
308
342
 
309
- # Show version
310
- kalibr version
343
+ # Update schemas
344
+ kalibr update_schemas
311
345
  ```
312
346
 
313
347
  ## Supported Providers
@@ -120,6 +120,41 @@ policy = get_policy(
120
120
  )
121
121
  ```
122
122
 
123
+ ### Intelligent Routing with decide()
124
+
125
+ Register execution paths and let Kalibr decide the best strategy:
126
+
127
+ ```python
128
+ from kalibr import register_path, decide
129
+
130
+ # Register available paths
131
+ register_path(goal="book_meeting", model_id="gpt-4o", tool_id="calendar_api")
132
+ register_path(goal="book_meeting", model_id="claude-3-sonnet")
133
+
134
+ # Get intelligent routing decision
135
+ decision = decide(goal="book_meeting")
136
+ model = decision["model_id"] # Selected based on outcomes
137
+ tool = decision.get("tool_id") # If tool routing enabled
138
+ print(decision["exploration"]) # True if exploring new paths
139
+ ```
140
+
141
+ ### Goal Context
142
+
143
+ Tag traces with goals for outcome tracking:
144
+
145
+ ```python
146
+ from kalibr import goal, set_goal, get_goal, clear_goal
147
+
148
+ # Context manager (recommended)
149
+ with goal("book_meeting"):
150
+ response = openai.chat.completions.create(...)
151
+
152
+ # Or manual control
153
+ set_goal("book_meeting")
154
+ response = openai.chat.completions.create(...)
155
+ clear_goal()
156
+ ```
157
+
123
158
  ## TraceCapsule - Cross-Agent Tracing
124
159
 
125
160
  Propagate trace context across agent boundaries:
@@ -217,7 +252,7 @@ Configure via environment variables:
217
252
  | `KALIBR_API_KEY` | API key for authentication | *Required* |
218
253
  | `KALIBR_TENANT_ID` | Tenant identifier | `default` |
219
254
  | `KALIBR_COLLECTOR_URL` | Collector endpoint URL | `https://api.kalibr.systems/api/ingest` |
220
- | `KALIBR_INTELLIGENCE_URL` | Intelligence API URL | `https://kalibr-intelligence.fly.dev` |
255
+ | `KALIBR_INTELLIGENCE_URL` | Intelligence API URL | `https://dashboard.kalibr.systems/intelligence` |
221
256
  | `KALIBR_SERVICE_NAME` | Service name for spans | `kalibr-app` |
222
257
  | `KALIBR_ENVIRONMENT` | Environment (prod/staging/dev) | `prod` |
223
258
  | `KALIBR_WORKFLOW_ID` | Workflow identifier | `default` |
@@ -226,20 +261,20 @@ Configure via environment variables:
226
261
  ## CLI Commands
227
262
 
228
263
  ```bash
229
- # Serve your app with tracing
230
- kalibr serve myapp.py
264
+ # Show version
265
+ kalibr version
231
266
 
232
- # Run with managed runtime
233
- kalibr run myapp.py --port 8000
267
+ # Validate configuration
268
+ kalibr validate
234
269
 
235
- # Deploy to cloud platforms
236
- kalibr deploy myapp.py --runtime fly.io
270
+ # Check connection status
271
+ kalibr status
237
272
 
238
- # Fetch trace capsule by ID
239
- kalibr capsule <trace-id>
273
+ # Package for deployment
274
+ kalibr package
240
275
 
241
- # Show version
242
- kalibr version
276
+ # Update schemas
277
+ kalibr update_schemas
243
278
  ```
244
279
 
245
280
  ## Supported Providers
@@ -56,7 +56,17 @@ from .collector import is_configured as is_collector_configured
56
56
  from .collector import (
57
57
  setup_collector,
58
58
  )
59
- from .context import get_parent_span_id, get_trace_id, new_trace_id, trace_context
59
+ from .context import (
60
+ get_parent_span_id,
61
+ get_trace_id,
62
+ new_trace_id,
63
+ trace_context,
64
+ # Goal context (v1.3.0)
65
+ goal,
66
+ set_goal,
67
+ get_goal,
68
+ clear_goal,
69
+ )
60
70
  from .cost_adapter import (
61
71
  AnthropicCostAdapter,
62
72
  BaseCostAdapter,
@@ -79,6 +89,8 @@ from .intelligence import (
79
89
  get_policy,
80
90
  report_outcome,
81
91
  get_recommendation,
92
+ register_path,
93
+ decide,
82
94
  )
83
95
 
84
96
  if os.getenv("KALIBR_AUTO_INSTRUMENT", "true").lower() == "true":
@@ -114,6 +126,11 @@ __all__ = [
114
126
  "get_trace_id",
115
127
  "get_parent_span_id",
116
128
  "new_trace_id",
129
+ # Goal Context (v1.3.0)
130
+ "goal",
131
+ "set_goal",
132
+ "get_goal",
133
+ "clear_goal",
117
134
  # Tracer
118
135
  "Tracer",
119
136
  "SpanContext",
@@ -144,4 +161,6 @@ __all__ = [
144
161
  "get_policy",
145
162
  "report_outcome",
146
163
  "get_recommendation",
164
+ "register_path",
165
+ "decide",
147
166
  ]
@@ -8,6 +8,7 @@ HTTP requests to SDK calls (OpenAI, Anthropic, Google).
8
8
  import random
9
9
  import string
10
10
  import uuid
11
+ from contextlib import contextmanager
11
12
  from contextvars import ContextVar
12
13
  from typing import Dict, Optional
13
14
 
@@ -130,3 +131,44 @@ def inject_kalibr_context_into_span(span: Span):
130
131
  span.set_attribute("kalibr.http_trace_id", ctx["trace_id"])
131
132
  if ctx.get("span_id"):
132
133
  span.set_attribute("kalibr.http_span_id", ctx["span_id"])
134
+
135
+
136
+ # ============================================================================
137
+ # Goal Context for Outcome Tracking (v1.3.0)
138
+ # ============================================================================
139
+
140
+ _goal_context: ContextVar[Optional[str]] = ContextVar("goal_context", default=None)
141
+
142
+
143
+ def set_goal(goal: str):
144
+ """Set the current goal for all subsequent Kalibr traces."""
145
+ _goal_context.set(goal)
146
+
147
+
148
+ def get_goal() -> Optional[str]:
149
+ """Get the current goal."""
150
+ return _goal_context.get()
151
+
152
+
153
+ def clear_goal():
154
+ """Clear the current goal."""
155
+ _goal_context.set(None)
156
+
157
+
158
+ @contextmanager
159
+ def goal(goal_name: str):
160
+ """Context manager to set goal for a block of code.
161
+
162
+ Usage:
163
+ with kalibr.goal("research_company"):
164
+ agent.run("Research Weights & Biases")
165
+ """
166
+ previous = get_goal()
167
+ set_goal(goal_name)
168
+ try:
169
+ yield
170
+ finally:
171
+ if previous:
172
+ set_goal(previous)
173
+ else:
174
+ clear_goal()