openlit 1.33.8__py3-none-any.whl → 1.33.10__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 +88 -0
- openlit/__init__.py +4 -3
- openlit/instrumentation/ag2/ag2.py +5 -5
- openlit/instrumentation/ai21/__init__.py +4 -4
- openlit/instrumentation/ai21/ai21.py +370 -319
- openlit/instrumentation/ai21/async_ai21.py +371 -319
- openlit/instrumentation/anthropic/__init__.py +4 -4
- openlit/instrumentation/anthropic/anthropic.py +321 -189
- openlit/instrumentation/anthropic/async_anthropic.py +323 -190
- openlit/instrumentation/assemblyai/__init__.py +1 -1
- openlit/instrumentation/assemblyai/assemblyai.py +59 -43
- openlit/instrumentation/astra/astra.py +9 -9
- openlit/instrumentation/astra/async_astra.py +9 -9
- openlit/instrumentation/azure_ai_inference/__init__.py +4 -4
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +406 -252
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +406 -252
- openlit/instrumentation/bedrock/__init__.py +1 -1
- openlit/instrumentation/bedrock/bedrock.py +115 -58
- openlit/instrumentation/chroma/chroma.py +9 -9
- openlit/instrumentation/cohere/__init__.py +33 -10
- openlit/instrumentation/cohere/async_cohere.py +610 -0
- openlit/instrumentation/cohere/cohere.py +410 -219
- openlit/instrumentation/controlflow/controlflow.py +5 -5
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +5 -5
- openlit/instrumentation/crawl4ai/crawl4ai.py +5 -5
- openlit/instrumentation/crewai/crewai.py +6 -4
- openlit/instrumentation/dynamiq/dynamiq.py +5 -5
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +71 -46
- openlit/instrumentation/elevenlabs/elevenlabs.py +71 -51
- openlit/instrumentation/embedchain/embedchain.py +9 -9
- openlit/instrumentation/firecrawl/firecrawl.py +5 -5
- openlit/instrumentation/google_ai_studio/__init__.py +9 -9
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +183 -219
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +183 -220
- openlit/instrumentation/gpt4all/__init__.py +2 -2
- openlit/instrumentation/gpt4all/gpt4all.py +345 -220
- openlit/instrumentation/gpu/__init__.py +5 -5
- openlit/instrumentation/groq/__init__.py +2 -2
- openlit/instrumentation/groq/async_groq.py +356 -240
- openlit/instrumentation/groq/groq.py +356 -240
- openlit/instrumentation/haystack/haystack.py +5 -5
- openlit/instrumentation/julep/async_julep.py +5 -5
- openlit/instrumentation/julep/julep.py +5 -5
- openlit/instrumentation/langchain/__init__.py +13 -7
- openlit/instrumentation/langchain/async_langchain.py +384 -0
- openlit/instrumentation/langchain/langchain.py +105 -492
- openlit/instrumentation/letta/letta.py +11 -9
- openlit/instrumentation/litellm/__init__.py +4 -5
- openlit/instrumentation/litellm/async_litellm.py +318 -247
- openlit/instrumentation/litellm/litellm.py +314 -243
- openlit/instrumentation/llamaindex/llamaindex.py +5 -5
- openlit/instrumentation/mem0/mem0.py +5 -5
- openlit/instrumentation/milvus/milvus.py +9 -9
- openlit/instrumentation/mistral/__init__.py +6 -6
- openlit/instrumentation/mistral/async_mistral.py +423 -250
- openlit/instrumentation/mistral/mistral.py +420 -246
- openlit/instrumentation/multion/async_multion.py +6 -4
- openlit/instrumentation/multion/multion.py +6 -4
- openlit/instrumentation/ollama/__init__.py +8 -30
- openlit/instrumentation/ollama/async_ollama.py +385 -417
- openlit/instrumentation/ollama/ollama.py +384 -417
- openlit/instrumentation/openai/__init__.py +11 -230
- openlit/instrumentation/openai/async_openai.py +433 -410
- openlit/instrumentation/openai/openai.py +414 -394
- openlit/instrumentation/phidata/phidata.py +6 -4
- openlit/instrumentation/pinecone/pinecone.py +9 -9
- openlit/instrumentation/premai/__init__.py +2 -2
- openlit/instrumentation/premai/premai.py +262 -213
- openlit/instrumentation/qdrant/async_qdrant.py +9 -9
- openlit/instrumentation/qdrant/qdrant.py +9 -9
- openlit/instrumentation/reka/__init__.py +2 -2
- openlit/instrumentation/reka/async_reka.py +90 -52
- openlit/instrumentation/reka/reka.py +90 -52
- openlit/instrumentation/together/__init__.py +4 -4
- openlit/instrumentation/together/async_together.py +278 -236
- openlit/instrumentation/together/together.py +278 -236
- openlit/instrumentation/transformers/__init__.py +1 -1
- openlit/instrumentation/transformers/transformers.py +76 -45
- openlit/instrumentation/vertexai/__init__.py +14 -64
- openlit/instrumentation/vertexai/async_vertexai.py +330 -987
- openlit/instrumentation/vertexai/vertexai.py +330 -987
- openlit/instrumentation/vllm/__init__.py +1 -1
- openlit/instrumentation/vllm/vllm.py +66 -36
- openlit/otel/metrics.py +98 -7
- openlit/semcov/__init__.py +113 -80
- {openlit-1.33.8.dist-info → openlit-1.33.10.dist-info}/METADATA +1 -1
- openlit-1.33.10.dist-info/RECORD +122 -0
- {openlit-1.33.8.dist-info → openlit-1.33.10.dist-info}/WHEEL +1 -1
- openlit/instrumentation/openai/async_azure_openai.py +0 -900
- openlit/instrumentation/openai/azure_openai.py +0 -898
- openlit-1.33.8.dist-info/RECORD +0 -122
- {openlit-1.33.8.dist-info → openlit-1.33.10.dist-info}/LICENSE +0 -0
@@ -1,19 +1,23 @@
|
|
1
|
-
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment
|
2
1
|
"""
|
3
2
|
Module for monitoring Assembly AI API calls.
|
4
3
|
"""
|
5
4
|
|
6
5
|
import logging
|
6
|
+
import time
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
9
|
-
from openlit.__helpers import
|
10
|
-
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
|
+
from openlit.__helpers import (
|
10
|
+
get_audio_model_cost,
|
11
|
+
handle_exception,
|
12
|
+
create_metrics_attributes,
|
13
|
+
set_server_address_and_port
|
14
|
+
)
|
11
15
|
from openlit.semcov import SemanticConvetion
|
12
16
|
|
13
17
|
# Initialize logger for logging potential issues and operations
|
14
18
|
logger = logging.getLogger(__name__)
|
15
19
|
|
16
|
-
def transcribe(
|
20
|
+
def transcribe(version, environment, application_name,
|
17
21
|
tracer, pricing_info, trace_content, metrics, disable_metrics):
|
18
22
|
"""
|
19
23
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
@@ -48,43 +52,56 @@ def transcribe(gen_ai_endpoint, version, environment, application_name,
|
|
48
52
|
The response from the original 'transcribe' method.
|
49
53
|
"""
|
50
54
|
|
51
|
-
|
55
|
+
server_address, server_port = set_server_address_and_port(instance, 'api.assemblyai.com', 443)
|
56
|
+
request_model = kwargs.get('speech_model', 'best')
|
57
|
+
|
58
|
+
span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
|
59
|
+
|
60
|
+
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
61
|
+
start_time = time.time()
|
52
62
|
response = wrapped(*args, **kwargs)
|
63
|
+
end_time = time.time()
|
53
64
|
|
54
65
|
try:
|
55
|
-
llm_model = response.speech_model if response.speech_model else "best"
|
56
|
-
|
57
66
|
# Calculate cost of the operation
|
58
|
-
cost = get_audio_model_cost(
|
67
|
+
cost = get_audio_model_cost(request_model,
|
59
68
|
pricing_info, None, response.audio_duration)
|
60
69
|
|
61
|
-
# Set Span attributes
|
62
|
-
span.set_attribute(TELEMETRY_SDK_NAME,
|
70
|
+
# Set Span attributes (OTel Semconv)
|
71
|
+
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
72
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
73
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
|
63
74
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
64
75
|
SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
|
65
|
-
span.set_attribute(SemanticConvetion.
|
66
|
-
|
67
|
-
span.set_attribute(SemanticConvetion.
|
68
|
-
|
69
|
-
span.set_attribute(SemanticConvetion.
|
76
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
77
|
+
request_model)
|
78
|
+
span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
|
79
|
+
server_address)
|
80
|
+
span.set_attribute(SemanticConvetion.SERVER_PORT,
|
81
|
+
server_port)
|
82
|
+
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
|
83
|
+
request_model)
|
84
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
|
85
|
+
'text')
|
86
|
+
|
87
|
+
# Set Span attributes (Extras)
|
88
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
70
89
|
environment)
|
71
|
-
span.set_attribute(
|
90
|
+
span.set_attribute(SERVICE_NAME,
|
72
91
|
application_name)
|
73
|
-
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
|
74
|
-
response.id)
|
75
|
-
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
76
|
-
llm_model)
|
77
92
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_DURATION,
|
78
93
|
response.audio_duration)
|
79
94
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
80
95
|
cost)
|
96
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
97
|
+
version)
|
81
98
|
|
82
99
|
if trace_content:
|
83
100
|
span.add_event(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
101
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
102
|
+
attributes={
|
103
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: response.audio_url,
|
104
|
+
},
|
88
105
|
)
|
89
106
|
span.add_event(
|
90
107
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
@@ -96,30 +113,29 @@ def transcribe(gen_ai_endpoint, version, environment, application_name,
|
|
96
113
|
span.set_status(Status(StatusCode.OK))
|
97
114
|
|
98
115
|
if disable_metrics is False:
|
99
|
-
attributes =
|
100
|
-
|
101
|
-
|
102
|
-
SemanticConvetion.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
metrics[
|
115
|
-
metrics["genai_cost"].record(cost, attributes)
|
116
|
+
attributes = create_metrics_attributes(
|
117
|
+
service_name=application_name,
|
118
|
+
deployment_environment=environment,
|
119
|
+
operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
|
120
|
+
system=SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI,
|
121
|
+
request_model=request_model,
|
122
|
+
server_address=server_address,
|
123
|
+
server_port=server_port,
|
124
|
+
response_model=request_model,
|
125
|
+
)
|
126
|
+
|
127
|
+
metrics['genai_client_operation_duration'].record(
|
128
|
+
end_time - start_time, attributes
|
129
|
+
)
|
130
|
+
metrics['genai_requests'].add(1, attributes)
|
131
|
+
metrics['genai_cost'].record(cost, attributes)
|
116
132
|
|
117
133
|
# Return original response
|
118
134
|
return response
|
119
135
|
|
120
136
|
except Exception as e:
|
121
137
|
handle_exception(span, e)
|
122
|
-
logger.error(
|
138
|
+
logger.error('Error in trace creation: %s', e)
|
123
139
|
|
124
140
|
# Return original response
|
125
141
|
return response
|
@@ -5,7 +5,7 @@ Module for monitoring AstraDB.
|
|
5
5
|
|
6
6
|
import logging
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
10
|
from openlit.semcov import SemanticConvetion
|
11
11
|
|
@@ -69,12 +69,12 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
69
69
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
70
70
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
71
71
|
gen_ai_endpoint)
|
72
|
-
span.set_attribute(
|
72
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
73
73
|
environment)
|
74
|
-
span.set_attribute(
|
74
|
+
span.set_attribute(SERVICE_NAME,
|
75
75
|
application_name)
|
76
|
-
span.set_attribute(SemanticConvetion.
|
77
|
-
SemanticConvetion.
|
76
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
77
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
|
78
78
|
span.set_attribute(SemanticConvetion.DB_SYSTEM,
|
79
79
|
SemanticConvetion.DB_SYSTEM_ASTRA)
|
80
80
|
|
@@ -199,14 +199,14 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
199
199
|
attributes = {
|
200
200
|
TELEMETRY_SDK_NAME:
|
201
201
|
"openlit",
|
202
|
-
|
202
|
+
SERVICE_NAME:
|
203
203
|
application_name,
|
204
204
|
SemanticConvetion.DB_SYSTEM:
|
205
205
|
SemanticConvetion.DB_SYSTEM_ASTRA,
|
206
|
-
|
206
|
+
DEPLOYMENT_ENVIRONMENT:
|
207
207
|
environment,
|
208
|
-
SemanticConvetion.
|
209
|
-
SemanticConvetion.
|
208
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
209
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
|
210
210
|
SemanticConvetion.DB_OPERATION:
|
211
211
|
db_operation
|
212
212
|
}
|
@@ -5,7 +5,7 @@ Module for monitoring AstraDB.
|
|
5
5
|
|
6
6
|
import logging
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
10
|
from openlit.semcov import SemanticConvetion
|
11
11
|
|
@@ -69,12 +69,12 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
69
69
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
70
70
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
71
71
|
gen_ai_endpoint)
|
72
|
-
span.set_attribute(
|
72
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
73
73
|
environment)
|
74
|
-
span.set_attribute(
|
74
|
+
span.set_attribute(SERVICE_NAME,
|
75
75
|
application_name)
|
76
|
-
span.set_attribute(SemanticConvetion.
|
77
|
-
SemanticConvetion.
|
76
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
77
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
|
78
78
|
span.set_attribute(SemanticConvetion.DB_SYSTEM,
|
79
79
|
SemanticConvetion.DB_SYSTEM_ASTRA)
|
80
80
|
|
@@ -199,14 +199,14 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
199
199
|
attributes = {
|
200
200
|
TELEMETRY_SDK_NAME:
|
201
201
|
"openlit",
|
202
|
-
|
202
|
+
SERVICE_NAME:
|
203
203
|
application_name,
|
204
204
|
SemanticConvetion.DB_SYSTEM:
|
205
205
|
SemanticConvetion.DB_SYSTEM_ASTRA,
|
206
|
-
|
206
|
+
DEPLOYMENT_ENVIRONMENT:
|
207
207
|
environment,
|
208
|
-
SemanticConvetion.
|
209
|
-
SemanticConvetion.
|
208
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
209
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
|
210
210
|
SemanticConvetion.DB_OPERATION:
|
211
211
|
db_operation
|
212
212
|
}
|
@@ -38,7 +38,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
38
38
|
wrap_function_wrapper(
|
39
39
|
"azure.ai.inference",
|
40
40
|
"ChatCompletionsClient.complete",
|
41
|
-
complete(
|
41
|
+
complete(version, environment, application_name,
|
42
42
|
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
43
43
|
)
|
44
44
|
|
@@ -46,7 +46,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
46
46
|
wrap_function_wrapper(
|
47
47
|
"azure.ai.inference",
|
48
48
|
"EmbeddingsClient.embed",
|
49
|
-
embedding(
|
49
|
+
embedding(version, environment, application_name,
|
50
50
|
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
51
51
|
)
|
52
52
|
|
@@ -54,7 +54,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
54
54
|
wrap_function_wrapper(
|
55
55
|
"azure.ai.inference.aio",
|
56
56
|
"ChatCompletionsClient.complete",
|
57
|
-
async_complete(
|
57
|
+
async_complete(version, environment, application_name,
|
58
58
|
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
59
59
|
)
|
60
60
|
|
@@ -62,7 +62,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
62
62
|
wrap_function_wrapper(
|
63
63
|
"azure.ai.inference.aio",
|
64
64
|
"EmbeddingsClient.embed",
|
65
|
-
async_embedding(
|
65
|
+
async_embedding(version, environment, application_name,
|
66
66
|
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
67
67
|
)
|
68
68
|
|