openlit 1.33.18__py3-none-any.whl → 1.33.20__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.
- openlit/__helpers.py +11 -41
- openlit/__init__.py +3 -3
- openlit/evals/utils.py +7 -7
- openlit/guard/utils.py +7 -7
- openlit/instrumentation/ag2/ag2.py +24 -24
- openlit/instrumentation/ai21/ai21.py +3 -3
- openlit/instrumentation/ai21/async_ai21.py +3 -3
- openlit/instrumentation/ai21/utils.py +59 -59
- openlit/instrumentation/anthropic/anthropic.py +2 -2
- openlit/instrumentation/anthropic/async_anthropic.py +2 -2
- openlit/instrumentation/anthropic/utils.py +34 -34
- openlit/instrumentation/assemblyai/assemblyai.py +24 -24
- openlit/instrumentation/astra/astra.py +3 -3
- openlit/instrumentation/astra/async_astra.py +3 -3
- openlit/instrumentation/astra/utils.py +39 -39
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +10 -10
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +10 -10
- openlit/instrumentation/azure_ai_inference/utils.py +38 -38
- openlit/instrumentation/bedrock/__init__.py +2 -1
- openlit/instrumentation/bedrock/bedrock.py +32 -214
- openlit/instrumentation/bedrock/utils.py +252 -0
- openlit/instrumentation/chroma/chroma.py +57 -57
- openlit/instrumentation/cohere/async_cohere.py +88 -88
- openlit/instrumentation/cohere/cohere.py +88 -88
- openlit/instrumentation/controlflow/controlflow.py +15 -15
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +14 -14
- openlit/instrumentation/crawl4ai/crawl4ai.py +14 -14
- openlit/instrumentation/crewai/crewai.py +22 -22
- openlit/instrumentation/dynamiq/dynamiq.py +19 -19
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +24 -25
- openlit/instrumentation/elevenlabs/elevenlabs.py +23 -25
- openlit/instrumentation/embedchain/embedchain.py +15 -15
- openlit/instrumentation/firecrawl/firecrawl.py +10 -10
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +33 -33
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +33 -33
- openlit/instrumentation/gpt4all/gpt4all.py +78 -78
- openlit/instrumentation/gpu/__init__.py +8 -8
- openlit/instrumentation/groq/async_groq.py +74 -74
- openlit/instrumentation/groq/groq.py +74 -74
- openlit/instrumentation/haystack/haystack.py +6 -6
- openlit/instrumentation/julep/async_julep.py +14 -14
- openlit/instrumentation/julep/julep.py +14 -14
- openlit/instrumentation/langchain/async_langchain.py +39 -39
- openlit/instrumentation/langchain/langchain.py +39 -39
- openlit/instrumentation/letta/letta.py +26 -26
- openlit/instrumentation/litellm/async_litellm.py +94 -94
- openlit/instrumentation/litellm/litellm.py +94 -94
- openlit/instrumentation/llamaindex/llamaindex.py +7 -7
- openlit/instrumentation/mem0/mem0.py +13 -13
- openlit/instrumentation/milvus/milvus.py +47 -47
- openlit/instrumentation/mistral/async_mistral.py +88 -88
- openlit/instrumentation/mistral/mistral.py +88 -88
- openlit/instrumentation/multion/async_multion.py +21 -21
- openlit/instrumentation/multion/multion.py +21 -21
- openlit/instrumentation/ollama/async_ollama.py +3 -3
- openlit/instrumentation/ollama/ollama.py +3 -3
- openlit/instrumentation/ollama/utils.py +50 -50
- openlit/instrumentation/openai/async_openai.py +225 -225
- openlit/instrumentation/openai/openai.py +225 -225
- openlit/instrumentation/openai_agents/openai_agents.py +11 -11
- openlit/instrumentation/phidata/phidata.py +15 -15
- openlit/instrumentation/pinecone/pinecone.py +43 -43
- openlit/instrumentation/premai/premai.py +86 -86
- openlit/instrumentation/qdrant/async_qdrant.py +95 -95
- openlit/instrumentation/qdrant/qdrant.py +99 -99
- openlit/instrumentation/reka/async_reka.py +33 -33
- openlit/instrumentation/reka/reka.py +33 -33
- openlit/instrumentation/together/async_together.py +90 -90
- openlit/instrumentation/together/together.py +90 -90
- openlit/instrumentation/transformers/transformers.py +26 -26
- openlit/instrumentation/vertexai/async_vertexai.py +64 -64
- openlit/instrumentation/vertexai/vertexai.py +64 -64
- openlit/instrumentation/vllm/vllm.py +24 -24
- openlit/otel/metrics.py +11 -11
- openlit/semcov/__init__.py +3 -3
- {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/METADATA +8 -8
- openlit-1.33.20.dist-info/RECORD +131 -0
- {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/WHEEL +1 -1
- openlit-1.33.18.dist-info/RECORD +0 -130
- {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/LICENSE +0 -0
@@ -19,7 +19,7 @@ from openlit.__helpers import (
|
|
19
19
|
otel_event,
|
20
20
|
concatenate_all_contents
|
21
21
|
)
|
22
|
-
from openlit.semcov import
|
22
|
+
from openlit.semcov import SemanticConvention
|
23
23
|
|
24
24
|
def process_chunk(self, chunk):
|
25
25
|
"""
|
@@ -64,20 +64,20 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
|
|
64
64
|
|
65
65
|
# Set Span attributes (OTel Semconv)
|
66
66
|
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
67
|
-
scope._span.set_attribute(
|
68
|
-
scope._span.set_attribute(
|
69
|
-
scope._span.set_attribute(
|
70
|
-
scope._span.set_attribute(
|
67
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
68
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
|
69
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
70
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
|
71
71
|
|
72
72
|
options = scope._kwargs.get('options', {})
|
73
73
|
attributes = [
|
74
|
-
(
|
75
|
-
(
|
76
|
-
(
|
77
|
-
(
|
78
|
-
(
|
79
|
-
(
|
80
|
-
(
|
74
|
+
(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'repeat_penalty'),
|
75
|
+
(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
|
76
|
+
(SemanticConvention.GEN_AI_REQUEST_SEED, 'seed'),
|
77
|
+
(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop'),
|
78
|
+
(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
|
79
|
+
(SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
|
80
|
+
(SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
|
81
81
|
]
|
82
82
|
|
83
83
|
for attribute, key in attributes:
|
@@ -85,37 +85,37 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
|
|
85
85
|
if value is not None:
|
86
86
|
scope._span.set_attribute(attribute, value)
|
87
87
|
|
88
|
-
scope._span.set_attribute(
|
89
|
-
scope._span.set_attribute(
|
90
|
-
scope._span.set_attribute(
|
91
|
-
scope._span.set_attribute(
|
92
|
-
scope._span.set_attribute(
|
88
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
|
89
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
|
90
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
|
91
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
|
92
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
|
93
93
|
|
94
|
-
scope._span.set_attribute(
|
94
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
95
95
|
"text" if isinstance(scope._llmresponse, str) else "json")
|
96
96
|
|
97
97
|
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
98
98
|
scope._span.set_attribute(SERVICE_NAME, application_name)
|
99
|
-
scope._span.set_attribute(
|
100
|
-
scope._span.set_attribute(
|
101
|
-
scope._span.set_attribute(
|
102
|
-
scope._span.set_attribute(
|
103
|
-
scope._span.set_attribute(
|
104
|
-
scope._span.set_attribute(
|
99
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
100
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
|
101
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
|
102
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
|
103
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
|
104
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
105
105
|
|
106
106
|
# To be removed one the change to log events (from span events) is complete
|
107
107
|
prompt = concatenate_all_contents(formatted_messages)
|
108
108
|
if capture_message_content:
|
109
109
|
scope._span.add_event(
|
110
|
-
name=
|
110
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
111
111
|
attributes={
|
112
|
-
|
112
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
113
113
|
},
|
114
114
|
)
|
115
115
|
scope._span.add_event(
|
116
|
-
name=
|
116
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
117
117
|
attributes={
|
118
|
-
|
118
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
|
119
119
|
},
|
120
120
|
)
|
121
121
|
|
@@ -145,9 +145,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
|
|
145
145
|
for role in ['user', 'system', 'assistant', 'tool']:
|
146
146
|
if formatted_messages.get(role, {}).get('content', ''):
|
147
147
|
event = otel_event(
|
148
|
-
name=getattr(
|
148
|
+
name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
|
149
149
|
attributes={
|
150
|
-
|
150
|
+
SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
|
151
151
|
},
|
152
152
|
body = {
|
153
153
|
# pylint: disable=line-too-long
|
@@ -172,9 +172,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
|
|
172
172
|
event_provider.emit(event)
|
173
173
|
|
174
174
|
choice_event = otel_event(
|
175
|
-
name=
|
175
|
+
name=SemanticConvention.GEN_AI_CHOICE,
|
176
176
|
attributes={
|
177
|
-
|
177
|
+
SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
|
178
178
|
},
|
179
179
|
body=choice_event_body
|
180
180
|
)
|
@@ -186,8 +186,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
|
|
186
186
|
metrics_attributes = create_metrics_attributes(
|
187
187
|
service_name=application_name,
|
188
188
|
deployment_environment=environment,
|
189
|
-
operation=
|
190
|
-
system=
|
189
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
190
|
+
system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
|
191
191
|
request_model=request_model,
|
192
192
|
server_address=scope._server_address,
|
193
193
|
server_port=scope._server_port,
|
@@ -260,19 +260,19 @@ def process_embedding_response(response, request_model, pricing_info, server_por
|
|
260
260
|
|
261
261
|
# Set Span attributes (OTel Semconv)
|
262
262
|
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
263
|
-
span.set_attribute(
|
264
|
-
|
265
|
-
span.set_attribute(
|
266
|
-
|
267
|
-
span.set_attribute(
|
263
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
264
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
|
265
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
266
|
+
SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
|
267
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
268
268
|
request_model)
|
269
|
-
span.set_attribute(
|
269
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
270
270
|
request_model)
|
271
|
-
span.set_attribute(
|
271
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
272
272
|
server_address)
|
273
|
-
span.set_attribute(
|
273
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
274
274
|
server_port)
|
275
|
-
span.set_attribute(
|
275
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
276
276
|
input_tokens)
|
277
277
|
|
278
278
|
# Set Span attributes (Extras)
|
@@ -280,17 +280,17 @@ def process_embedding_response(response, request_model, pricing_info, server_por
|
|
280
280
|
environment)
|
281
281
|
span.set_attribute(SERVICE_NAME,
|
282
282
|
application_name)
|
283
|
-
span.set_attribute(
|
283
|
+
span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
|
284
284
|
input_tokens)
|
285
|
-
span.set_attribute(
|
285
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
286
286
|
cost)
|
287
|
-
span.set_attribute(
|
287
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
288
288
|
version)
|
289
289
|
|
290
290
|
prompt_event = otel_event(
|
291
|
-
name=
|
291
|
+
name=SemanticConvention.GEN_AI_USER_MESSAGE,
|
292
292
|
attributes={
|
293
|
-
|
293
|
+
SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
|
294
294
|
},
|
295
295
|
body={
|
296
296
|
**({"content": kwargs.get('prompt', '')} if capture_message_content else {}),
|
@@ -305,8 +305,8 @@ def process_embedding_response(response, request_model, pricing_info, server_por
|
|
305
305
|
attributes = create_metrics_attributes(
|
306
306
|
service_name=application_name,
|
307
307
|
deployment_environment=environment,
|
308
|
-
operation=
|
309
|
-
system=
|
308
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
|
309
|
+
system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
|
310
310
|
request_model=request_model,
|
311
311
|
server_address=server_address,
|
312
312
|
server_port=server_port,
|