kalibr 1.1.3a0__tar.gz → 1.2.0__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.0/LICENSE +190 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/PKG-INFO +176 -62
- kalibr-1.2.0/README.md +282 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/__init__.py +19 -2
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/capsule_cmd.py +1 -1
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/main.py +3 -3
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/run.py +1 -1
- kalibr-1.2.0/kalibr/intelligence.py +317 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/PKG-INFO +176 -62
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/SOURCES.txt +3 -1
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_crewai/__init__.py +1 -1
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_langchain/__init__.py +1 -1
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_openai_agents/__init__.py +1 -1
- {kalibr-1.1.3a0 → kalibr-1.2.0}/pyproject.toml +6 -6
- {kalibr-1.1.3a0 → kalibr-1.2.0}/tests/test_capsule_builder.py +1 -1
- kalibr-1.2.0/tests/test_intelligence.py +175 -0
- kalibr-1.1.3a0/LICENSE +0 -21
- kalibr-1.1.3a0/README.md +0 -168
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/__main__.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/capsule_middleware.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/__init__.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/deploy_cmd.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cli/serve.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/client.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/collector.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/context.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/cost_adapter.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/decorators.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/__init__.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/anthropic_instr.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/base.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/google_instr.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/openai_instr.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/instrumentation/registry.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/kalibr.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/kalibr_app.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/middleware/__init__.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/middleware/auto_tracer.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/models.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/redaction.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/schemas.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/simple_tracer.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/tokens.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/trace_capsule.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/trace_models.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/tracer.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/types.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr/utils.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/dependency_links.txt +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/entry_points.txt +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/requires.txt +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr.egg-info/top_level.txt +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_crewai/callbacks.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_crewai/instrumentor.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_langchain/async_callback.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_langchain/callback.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/kalibr_openai_agents/processor.py +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/setup.cfg +0 -0
- {kalibr-1.1.3a0 → kalibr-1.2.0}/tests/test_instrumentation.py +0 -0
kalibr-1.2.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Kalibr Systems Inc.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kalibr
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Unified LLM Observability & Multi-Model AI Integration Framework - Deploy to GPT, Claude, Gemini, Copilot with full telemetry.
|
|
5
|
-
Author-email: Kalibr Team <
|
|
6
|
-
License:
|
|
5
|
+
Author-email: Kalibr Team <support@kalibr.systems>
|
|
6
|
+
License: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://github.com/kalibr-ai/kalibr-sdk-python
|
|
8
|
-
Project-URL: Documentation, https://
|
|
8
|
+
Project-URL: Documentation, https://kalibr.systems/docs
|
|
9
9
|
Project-URL: Repository, https://github.com/kalibr-ai/kalibr-sdk-python
|
|
10
10
|
Project-URL: Issues, https://github.com/kalibr-ai/kalibr-sdk-python/issues
|
|
11
11
|
Keywords: ai,mcp,gpt,claude,gemini,copilot,openai,anthropic,google,microsoft,observability,telemetry,tracing,llm,schema-generation,api,multi-model,langchain,crewai
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
|
-
Classifier: License :: OSI Approved ::
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.8
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: httpx>=0.27.0
|
|
@@ -68,15 +68,20 @@ Dynamic: license-file
|
|
|
68
68
|
|
|
69
69
|
# Kalibr Python SDK
|
|
70
70
|
|
|
71
|
-
Production-grade observability for LLM applications. Automatically instrument OpenAI, Anthropic, and Google AI SDKs with zero code changes.
|
|
71
|
+
Production-grade observability and execution intelligence for LLM applications. Automatically instrument OpenAI, Anthropic, and Google AI SDKs with zero code changes.
|
|
72
|
+
|
|
73
|
+
[](https://pypi.org/project/kalibr/)
|
|
74
|
+
[](https://pypi.org/project/kalibr/)
|
|
75
|
+
[](LICENSE)
|
|
72
76
|
|
|
73
77
|
## Features
|
|
74
78
|
|
|
75
|
-
- **Zero-code instrumentation** - Automatic tracing for OpenAI, Anthropic, and Google AI
|
|
79
|
+
- **Zero-code instrumentation** - Automatic tracing for OpenAI, Anthropic, and Google AI SDKs
|
|
80
|
+
- **Outcome-conditioned routing** - Query for optimal models based on historical success rates
|
|
81
|
+
- **TraceCapsule** - Cross-agent context propagation for multi-agent systems
|
|
76
82
|
- **Cost tracking** - Real-time cost calculation for all LLM calls
|
|
77
83
|
- **Token monitoring** - Track input/output tokens across providers
|
|
78
|
-
- **
|
|
79
|
-
- **Multi-provider support** - Works with GPT-4, Claude, Gemini, and more
|
|
84
|
+
- **Framework integrations** - LangChain, CrewAI, OpenAI Agents SDK
|
|
80
85
|
|
|
81
86
|
## Installation
|
|
82
87
|
|
|
@@ -91,32 +96,28 @@ pip install kalibr
|
|
|
91
96
|
Simply import `kalibr` at the start of your application - all LLM calls are automatically traced:
|
|
92
97
|
|
|
93
98
|
```python
|
|
94
|
-
import kalibr #
|
|
95
|
-
import
|
|
96
|
-
|
|
97
|
-
# Set your Kalibr API key
|
|
98
|
-
import os
|
|
99
|
-
os.environ["KALIBR_API_KEY"] = "your-kalibr-api-key"
|
|
99
|
+
import kalibr # Must be FIRST import
|
|
100
|
+
from openai import OpenAI
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
client = openai.OpenAI()
|
|
102
|
+
client = OpenAI()
|
|
103
103
|
response = client.chat.completions.create(
|
|
104
104
|
model="gpt-4o",
|
|
105
105
|
messages=[{"role": "user", "content": "Hello!"}]
|
|
106
106
|
)
|
|
107
|
+
# That's it. The call is automatically traced.
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
### Manual Tracing with Decorator
|
|
110
|
+
### Manual Tracing with @trace Decorator
|
|
110
111
|
|
|
111
112
|
For more control, use the `@trace` decorator:
|
|
112
113
|
|
|
113
114
|
```python
|
|
114
115
|
from kalibr import trace
|
|
115
|
-
import
|
|
116
|
+
from openai import OpenAI
|
|
116
117
|
|
|
117
118
|
@trace(operation="summarize", provider="openai", model="gpt-4o")
|
|
118
119
|
def summarize_text(text: str) -> str:
|
|
119
|
-
client =
|
|
120
|
+
client = OpenAI()
|
|
120
121
|
response = client.chat.completions.create(
|
|
121
122
|
model="gpt-4o",
|
|
122
123
|
messages=[
|
|
@@ -125,64 +126,188 @@ def summarize_text(text: str) -> str:
|
|
|
125
126
|
]
|
|
126
127
|
)
|
|
127
128
|
return response.choices[0].message.content
|
|
128
|
-
|
|
129
|
-
result = summarize_text("Your long text here...")
|
|
130
129
|
```
|
|
131
130
|
|
|
132
131
|
### Multi-Provider Example
|
|
133
132
|
|
|
134
133
|
```python
|
|
135
134
|
import kalibr
|
|
136
|
-
import
|
|
137
|
-
import
|
|
135
|
+
from openai import OpenAI
|
|
136
|
+
from anthropic import Anthropic
|
|
137
|
+
|
|
138
|
+
# Both are automatically traced
|
|
139
|
+
openai_client = OpenAI()
|
|
140
|
+
anthropic_client = Anthropic()
|
|
138
141
|
|
|
139
|
-
# OpenAI call - automatically traced
|
|
140
|
-
openai_client = openai.OpenAI()
|
|
141
142
|
gpt_response = openai_client.chat.completions.create(
|
|
142
143
|
model="gpt-4o",
|
|
143
144
|
messages=[{"role": "user", "content": "Explain quantum computing"}]
|
|
144
145
|
)
|
|
145
146
|
|
|
146
|
-
# Anthropic call - automatically traced
|
|
147
|
-
anthropic_client = anthropic.Anthropic()
|
|
148
147
|
claude_response = anthropic_client.messages.create(
|
|
149
|
-
model="claude-sonnet-
|
|
148
|
+
model="claude-3-5-sonnet-20241022",
|
|
150
149
|
max_tokens=1024,
|
|
151
150
|
messages=[{"role": "user", "content": "Explain machine learning"}]
|
|
152
151
|
)
|
|
153
152
|
```
|
|
154
153
|
|
|
154
|
+
## Outcome-Conditioned Routing
|
|
155
|
+
|
|
156
|
+
Query Kalibr for optimal model recommendations based on real execution outcomes:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from kalibr import get_policy, report_outcome
|
|
160
|
+
|
|
161
|
+
# Before executing - get the best model for your goal
|
|
162
|
+
policy = get_policy(goal="book_meeting")
|
|
163
|
+
print(f"Use {policy['recommended_model']} - {policy['outcome_success_rate']:.0%} success rate")
|
|
164
|
+
|
|
165
|
+
# Execute with the recommended model
|
|
166
|
+
# ...
|
|
167
|
+
|
|
168
|
+
# After executing - report what happened
|
|
169
|
+
report_outcome(
|
|
170
|
+
trace_id="abc123",
|
|
171
|
+
goal="book_meeting",
|
|
172
|
+
success=True
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### With Constraints
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from kalibr import get_policy
|
|
180
|
+
|
|
181
|
+
policy = get_policy(
|
|
182
|
+
goal="resolve_ticket",
|
|
183
|
+
constraints={
|
|
184
|
+
"max_cost_usd": 0.05,
|
|
185
|
+
"max_latency_ms": 3000,
|
|
186
|
+
"min_quality": 0.8
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## TraceCapsule - Cross-Agent Tracing
|
|
192
|
+
|
|
193
|
+
Propagate trace context across agent boundaries:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from kalibr import TraceCapsule, get_or_create_capsule
|
|
197
|
+
|
|
198
|
+
# Agent 1: Create capsule and add hop
|
|
199
|
+
capsule = get_or_create_capsule()
|
|
200
|
+
capsule.append_hop({
|
|
201
|
+
"provider": "openai",
|
|
202
|
+
"operation": "chat_completion",
|
|
203
|
+
"model": "gpt-4o",
|
|
204
|
+
"duration_ms": 150,
|
|
205
|
+
"cost_usd": 0.002,
|
|
206
|
+
"status": "success"
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
# Pass to Agent 2 via HTTP header
|
|
210
|
+
headers = {"X-Kalibr-Capsule": capsule.to_json()}
|
|
211
|
+
|
|
212
|
+
# Agent 2: Receive and continue
|
|
213
|
+
capsule = TraceCapsule.from_json(headers["X-Kalibr-Capsule"])
|
|
214
|
+
capsule.append_hop({
|
|
215
|
+
"provider": "anthropic",
|
|
216
|
+
"operation": "chat_completion",
|
|
217
|
+
"model": "claude-3-5-sonnet-20241022",
|
|
218
|
+
"duration_ms": 200,
|
|
219
|
+
"cost_usd": 0.003,
|
|
220
|
+
"status": "success"
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Framework Integrations
|
|
225
|
+
|
|
226
|
+
### LangChain
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
pip install kalibr[langchain]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from kalibr_langchain import KalibrCallbackHandler
|
|
234
|
+
from langchain_openai import ChatOpenAI
|
|
235
|
+
|
|
236
|
+
handler = KalibrCallbackHandler()
|
|
237
|
+
llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])
|
|
238
|
+
response = llm.invoke("What is the capital of France?")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
See [LangChain Integration Guide](kalibr_langchain/README.md) for full documentation.
|
|
242
|
+
|
|
243
|
+
### CrewAI
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pip install kalibr[crewai]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from kalibr_crewai import KalibrCrewAIInstrumentor
|
|
251
|
+
from crewai import Agent, Task, Crew
|
|
252
|
+
|
|
253
|
+
instrumentor = KalibrCrewAIInstrumentor()
|
|
254
|
+
instrumentor.instrument()
|
|
255
|
+
|
|
256
|
+
# Use CrewAI normally - all operations are traced
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
See [CrewAI Integration Guide](kalibr_crewai/README.md) for full documentation.
|
|
260
|
+
|
|
261
|
+
### OpenAI Agents SDK
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
pip install kalibr[openai-agents]
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
from kalibr_openai_agents import setup_kalibr_tracing
|
|
269
|
+
from agents import Agent, Runner
|
|
270
|
+
|
|
271
|
+
setup_kalibr_tracing()
|
|
272
|
+
|
|
273
|
+
agent = Agent(name="Assistant", instructions="You are helpful.")
|
|
274
|
+
result = Runner.run_sync(agent, "Hello!")
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
See [OpenAI Agents Integration Guide](kalibr_openai_agents/README.md) for full documentation.
|
|
278
|
+
|
|
155
279
|
## Configuration
|
|
156
280
|
|
|
157
|
-
Configure
|
|
281
|
+
Configure via environment variables:
|
|
158
282
|
|
|
159
283
|
| Variable | Description | Default |
|
|
160
284
|
|----------|-------------|---------|
|
|
161
285
|
| `KALIBR_API_KEY` | API key for authentication | *Required* |
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
164
|
-
| `
|
|
165
|
-
| `KALIBR_SERVICE_NAME` | Service name for
|
|
166
|
-
| `KALIBR_ENVIRONMENT` | Environment (prod
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
286
|
+
| `KALIBR_TENANT_ID` | Tenant identifier | `default` |
|
|
287
|
+
| `KALIBR_COLLECTOR_URL` | Collector endpoint URL | `https://api.kalibr.systems/api/ingest` |
|
|
288
|
+
| `KALIBR_INTELLIGENCE_URL` | Intelligence API URL | `https://kalibr-intelligence.fly.dev` |
|
|
289
|
+
| `KALIBR_SERVICE_NAME` | Service name for spans | `kalibr-app` |
|
|
290
|
+
| `KALIBR_ENVIRONMENT` | Environment (prod/staging/dev) | `prod` |
|
|
291
|
+
| `KALIBR_WORKFLOW_ID` | Workflow identifier | `default` |
|
|
292
|
+
| `KALIBR_AUTO_INSTRUMENT` | Enable auto-instrumentation | `true` |
|
|
169
293
|
|
|
170
|
-
## CLI
|
|
171
|
-
|
|
172
|
-
The SDK includes command-line tools for running and deploying applications:
|
|
294
|
+
## CLI Commands
|
|
173
295
|
|
|
174
296
|
```bash
|
|
175
|
-
#
|
|
297
|
+
# Serve your app with tracing
|
|
176
298
|
kalibr serve myapp.py
|
|
177
299
|
|
|
178
|
-
# Run with managed runtime
|
|
300
|
+
# Run with managed runtime
|
|
179
301
|
kalibr run myapp.py --port 8000
|
|
180
302
|
|
|
181
303
|
# Deploy to cloud platforms
|
|
182
304
|
kalibr deploy myapp.py --runtime fly.io
|
|
183
305
|
|
|
184
|
-
# Fetch trace
|
|
306
|
+
# Fetch trace capsule by ID
|
|
185
307
|
kalibr capsule <trace-id>
|
|
308
|
+
|
|
309
|
+
# Show version
|
|
310
|
+
kalibr version
|
|
186
311
|
```
|
|
187
312
|
|
|
188
313
|
## Supported Providers
|
|
@@ -190,27 +315,15 @@ kalibr capsule <trace-id>
|
|
|
190
315
|
| Provider | Models | Auto-Instrumentation |
|
|
191
316
|
|----------|--------|---------------------|
|
|
192
317
|
| OpenAI | GPT-4, GPT-4o, GPT-3.5 | Yes |
|
|
193
|
-
| Anthropic | Claude 3
|
|
318
|
+
| Anthropic | Claude 3.5 Sonnet, Claude 3 Opus/Sonnet/Haiku | Yes |
|
|
194
319
|
| Google | Gemini Pro, Gemini Flash | Yes |
|
|
195
320
|
|
|
196
|
-
## Examples
|
|
197
|
-
|
|
198
|
-
See the [`examples/`](./examples) directory for complete examples:
|
|
199
|
-
|
|
200
|
-
- `basic_example.py` - Simple tracing example
|
|
201
|
-
- `basic_agent.py` - Agent with auto-instrumentation
|
|
202
|
-
- `advanced_example.py` - Advanced tracing patterns
|
|
203
|
-
- `cross_vendor.py` - Multi-provider workflows
|
|
204
|
-
- `test_mas.py` - Multi-agent system demonstration
|
|
205
|
-
|
|
206
321
|
## Development
|
|
207
322
|
|
|
208
323
|
```bash
|
|
209
|
-
# Clone the repository
|
|
210
324
|
git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
|
|
211
325
|
cd kalibr-sdk-python
|
|
212
326
|
|
|
213
|
-
# Install in development mode
|
|
214
327
|
pip install -e ".[dev]"
|
|
215
328
|
|
|
216
329
|
# Run tests
|
|
@@ -223,14 +336,15 @@ ruff check kalibr/
|
|
|
223
336
|
|
|
224
337
|
## Contributing
|
|
225
338
|
|
|
226
|
-
We welcome contributions!
|
|
339
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
227
340
|
|
|
228
341
|
## License
|
|
229
342
|
|
|
230
|
-
|
|
343
|
+
Apache 2.0 - see [LICENSE](LICENSE).
|
|
231
344
|
|
|
232
345
|
## Links
|
|
233
346
|
|
|
234
|
-
- [Documentation](https://
|
|
235
|
-
- [
|
|
236
|
-
- [
|
|
347
|
+
- [Documentation](https://kalibr.systems/docs)
|
|
348
|
+
- [Dashboard](https://dashboard.kalibr.systems)
|
|
349
|
+
- [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
|
|
350
|
+
- [PyPI](https://pypi.org/project/kalibr/)
|