kalibr 1.1.3a0__py3-none-any.whl → 1.2.1__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- """Kalibr SDK v1.1.0 - LLM Observability & Tracing Framework
1
+ """Kalibr SDK v1.2.0 - 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.1.0-alpha"
39
+ __version__ = "1.2.0"
40
40
 
41
41
  # Auto-instrument LLM SDKs on import (can be disabled via env var)
42
42
  import os
@@ -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,
@@ -71,6 +81,18 @@ from .trace_capsule import TraceCapsule, get_or_create_capsule
71
81
  from .tracer import SpanContext, Tracer
72
82
  from .utils import load_config_from_env
73
83
 
84
+ # ============================================================================
85
+ # INTELLIGENCE & OUTCOME ROUTING (v1.2.0)
86
+ # ============================================================================
87
+ from .intelligence import (
88
+ KalibrIntelligence,
89
+ get_policy,
90
+ report_outcome,
91
+ get_recommendation,
92
+ register_path,
93
+ decide,
94
+ )
95
+
74
96
  if os.getenv("KALIBR_AUTO_INSTRUMENT", "true").lower() == "true":
75
97
  # Setup OpenTelemetry collector
76
98
  try:
@@ -104,6 +126,11 @@ __all__ = [
104
126
  "get_trace_id",
105
127
  "get_parent_span_id",
106
128
  "new_trace_id",
129
+ # Goal Context (v1.3.0)
130
+ "goal",
131
+ "set_goal",
132
+ "get_goal",
133
+ "clear_goal",
107
134
  # Tracer
108
135
  "Tracer",
109
136
  "SpanContext",
@@ -127,4 +154,13 @@ __all__ = [
127
154
  "setup_collector",
128
155
  "get_tracer_provider",
129
156
  "is_collector_configured",
157
+ # ========================================================================
158
+ # INTELLIGENCE & OUTCOME ROUTING (v1.2.0)
159
+ # ========================================================================
160
+ "KalibrIntelligence",
161
+ "get_policy",
162
+ "report_outcome",
163
+ "get_recommendation",
164
+ "register_path",
165
+ "decide",
130
166
  ]
kalibr/cli/capsule_cmd.py CHANGED
@@ -63,7 +63,7 @@ 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.io
66
+ kalibr capsule abc-123-def -u https://api.kalibr.systems
67
67
  """
68
68
  # Determine API base URL
69
69
  base_url = api_url or "https://api.kalibr.systems"
kalibr/cli/main.py CHANGED
@@ -30,9 +30,9 @@ def version():
30
30
  from kalibr import __version__
31
31
 
32
32
  console.print(f"[bold]Kalibr SDK version:[/bold] {__version__}")
33
- console.print("Enhanced multi-model AI integration framework")
34
- console.print("Supports: GPT Actions, Claude MCP, Gemini Extensions, Copilot Plugins")
35
- console.print("GitHub: https://github.com/devonakelley/kalibr-sdk")
33
+ console.print("LLM Observability & Execution Intelligence")
34
+ console.print("Auto-instrumentation for OpenAI, Anthropic, Google AI")
35
+ console.print("GitHub: https://github.com/kalibr-ai/kalibr-sdk-python")
36
36
 
37
37
 
38
38
  @app.command()
kalibr/cli/run.py CHANGED
@@ -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.io
50
+ kalibr run weather.py --backend-url https://api.kalibr.systems
51
51
  """
52
52
  # Validate file exists
53
53
  agent_path = Path(file_path).resolve()
kalibr/context.py CHANGED
@@ -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()