openlit 1.33.19__py3-none-any.whl → 1.33.21__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 +64 -7
- 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 +2 -2
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +2 -2
- openlit/instrumentation/azure_ai_inference/utils.py +36 -36
- openlit/instrumentation/bedrock/bedrock.py +2 -2
- openlit/instrumentation/bedrock/utils.py +35 -35
- 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/__init__.py +47 -34
- openlit/instrumentation/ollama/async_ollama.py +7 -5
- openlit/instrumentation/ollama/ollama.py +7 -5
- openlit/instrumentation/ollama/utils.py +58 -54
- 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/__init__.py +11 -7
- openlit/instrumentation/transformers/transformers.py +32 -168
- openlit/instrumentation/transformers/utils.py +183 -0
- 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.19.dist-info → openlit-1.33.21.dist-info}/METADATA +8 -8
- openlit-1.33.21.dist-info/RECORD +132 -0
- {openlit-1.33.19.dist-info → openlit-1.33.21.dist-info}/WHEEL +1 -1
- openlit-1.33.19.dist-info/RECORD +0 -131
- {openlit-1.33.19.dist-info → openlit-1.33.21.dist-info}/LICENSE +0 -0
@@ -16,7 +16,7 @@ from openlit.__helpers import (
|
|
16
16
|
create_metrics_attributes,
|
17
17
|
set_server_address_and_port
|
18
18
|
)
|
19
|
-
from openlit.semcov import
|
19
|
+
from openlit.semcov import SemanticConvention
|
20
20
|
|
21
21
|
# Initialize logger for logging potential issues and operations
|
22
22
|
logger = logging.getLogger(__name__)
|
@@ -58,7 +58,7 @@ def async_chat(version, environment, application_name, tracer,
|
|
58
58
|
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
|
59
59
|
request_model = kwargs.get('model', 'mistral-small-latest')
|
60
60
|
|
61
|
-
span_name = f'{
|
61
|
+
span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
|
62
62
|
|
63
63
|
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
64
64
|
start_time = time.time()
|
@@ -96,37 +96,37 @@ def async_chat(version, environment, application_name, tracer,
|
|
96
96
|
|
97
97
|
# Set base span attribues (OTel Semconv)
|
98
98
|
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
99
|
-
span.set_attribute(
|
100
|
-
|
101
|
-
span.set_attribute(
|
102
|
-
|
103
|
-
span.set_attribute(
|
99
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
100
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
101
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
102
|
+
SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
|
103
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
104
104
|
request_model)
|
105
|
-
span.set_attribute(
|
105
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
106
106
|
kwargs.get('seed', ''))
|
107
|
-
span.set_attribute(
|
107
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
108
108
|
server_port)
|
109
|
-
span.set_attribute(
|
109
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
110
110
|
kwargs.get('frequency_penalty', 0.0))
|
111
|
-
span.set_attribute(
|
111
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
112
112
|
kwargs.get('max_tokens', -1))
|
113
|
-
span.set_attribute(
|
113
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
114
114
|
kwargs.get('presence_penalty', 0.0))
|
115
|
-
span.set_attribute(
|
115
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
116
116
|
kwargs.get('stop', []))
|
117
|
-
span.set_attribute(
|
117
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
118
118
|
kwargs.get('temperature', 1.0))
|
119
|
-
span.set_attribute(
|
119
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
120
120
|
kwargs.get('top_p', 1.0))
|
121
|
-
span.set_attribute(
|
121
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
122
122
|
response_dict.get('id'))
|
123
|
-
span.set_attribute(
|
123
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
124
124
|
response_dict.get('model'))
|
125
|
-
span.set_attribute(
|
125
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
126
126
|
input_tokens)
|
127
|
-
span.set_attribute(
|
127
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
128
128
|
output_tokens)
|
129
|
-
span.set_attribute(
|
129
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
130
130
|
server_address)
|
131
131
|
|
132
132
|
# Set base span attribues (Extras)
|
@@ -134,44 +134,44 @@ def async_chat(version, environment, application_name, tracer,
|
|
134
134
|
environment)
|
135
135
|
span.set_attribute(SERVICE_NAME,
|
136
136
|
application_name)
|
137
|
-
span.set_attribute(
|
137
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
138
138
|
False)
|
139
|
-
span.set_attribute(
|
139
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
140
140
|
input_tokens + output_tokens)
|
141
|
-
span.set_attribute(
|
141
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
142
142
|
cost)
|
143
|
-
span.set_attribute(
|
143
|
+
span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
144
144
|
end_time - start_time)
|
145
|
-
span.set_attribute(
|
145
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
146
146
|
version)
|
147
147
|
if capture_message_content:
|
148
148
|
span.add_event(
|
149
|
-
name=
|
149
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
150
150
|
attributes={
|
151
|
-
|
151
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
152
152
|
},
|
153
153
|
)
|
154
154
|
|
155
155
|
for i in range(kwargs.get('n',1)):
|
156
|
-
span.set_attribute(
|
156
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
|
157
157
|
[response_dict.get('choices')[i].get('finish_reason')])
|
158
158
|
if capture_message_content:
|
159
159
|
span.add_event(
|
160
|
-
name=
|
160
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
161
161
|
attributes={
|
162
162
|
# pylint: disable=line-too-long
|
163
|
-
|
163
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
|
164
164
|
},
|
165
165
|
)
|
166
166
|
if kwargs.get('tools'):
|
167
|
-
span.set_attribute(
|
167
|
+
span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
|
168
168
|
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
|
169
169
|
|
170
170
|
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
|
171
|
-
span.set_attribute(
|
171
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
172
172
|
'text')
|
173
173
|
elif response_dict.get('choices')[i].get('message').get('content') is not None:
|
174
|
-
span.set_attribute(
|
174
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
175
175
|
'json')
|
176
176
|
|
177
177
|
span.set_status(Status(StatusCode.OK))
|
@@ -180,8 +180,8 @@ def async_chat(version, environment, application_name, tracer,
|
|
180
180
|
attributes = create_metrics_attributes(
|
181
181
|
service_name=application_name,
|
182
182
|
deployment_environment=environment,
|
183
|
-
operation=
|
184
|
-
system=
|
183
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
184
|
+
system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
|
185
185
|
request_model=request_model,
|
186
186
|
server_address=server_address,
|
187
187
|
server_port=server_port,
|
@@ -361,48 +361,48 @@ def async_chat_stream(version, environment, application_name,
|
|
361
361
|
|
362
362
|
# Set Span attributes (OTel Semconv)
|
363
363
|
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
364
|
-
self._span.set_attribute(
|
365
|
-
|
366
|
-
self._span.set_attribute(
|
367
|
-
|
368
|
-
self._span.set_attribute(
|
364
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
365
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
366
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
367
|
+
SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
|
368
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
369
369
|
request_model)
|
370
|
-
self._span.set_attribute(
|
370
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
371
371
|
self._kwargs.get('seed', ''))
|
372
|
-
self._span.set_attribute(
|
372
|
+
self._span.set_attribute(SemanticConvention.SERVER_PORT,
|
373
373
|
self._server_port)
|
374
|
-
self._span.set_attribute(
|
374
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
375
375
|
self._kwargs.get('frequency_penalty', 0.0))
|
376
|
-
self._span.set_attribute(
|
376
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
377
377
|
self._kwargs.get('max_tokens', -1))
|
378
|
-
self._span.set_attribute(
|
378
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
379
379
|
self._kwargs.get('presence_penalty', 0.0))
|
380
|
-
self._span.set_attribute(
|
380
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
381
381
|
self._kwargs.get('stop_sequences', []))
|
382
|
-
self._span.set_attribute(
|
382
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
383
383
|
self._kwargs.get('temperature', 0.3))
|
384
|
-
self._span.set_attribute(
|
384
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
|
385
385
|
self._kwargs.get('k', 1.0))
|
386
|
-
self._span.set_attribute(
|
386
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
387
387
|
self._kwargs.get('p', 1.0))
|
388
|
-
self._span.set_attribute(
|
388
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
|
389
389
|
[self._finish_reason])
|
390
|
-
self._span.set_attribute(
|
390
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
391
391
|
self._response_id)
|
392
|
-
self._span.set_attribute(
|
392
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
393
393
|
self._response_model)
|
394
|
-
self._span.set_attribute(
|
394
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
395
395
|
self._input_tokens)
|
396
|
-
self._span.set_attribute(
|
396
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
397
397
|
self._output_tokens)
|
398
|
-
self._span.set_attribute(
|
398
|
+
self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
399
399
|
self._server_address)
|
400
400
|
|
401
401
|
if isinstance(self._llmresponse, str):
|
402
|
-
self._span.set_attribute(
|
402
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
403
403
|
'text')
|
404
404
|
else:
|
405
|
-
self._span.set_attribute(
|
405
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
406
406
|
'json')
|
407
407
|
|
408
408
|
# Set Span attributes (Extra)
|
@@ -410,29 +410,29 @@ def async_chat_stream(version, environment, application_name,
|
|
410
410
|
environment)
|
411
411
|
self._span.set_attribute(SERVICE_NAME,
|
412
412
|
application_name)
|
413
|
-
self._span.set_attribute(
|
413
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
414
414
|
True)
|
415
|
-
self._span.set_attribute(
|
415
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
416
416
|
self._input_tokens + self._output_tokens)
|
417
|
-
self._span.set_attribute(
|
417
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
418
418
|
cost)
|
419
|
-
self._span.set_attribute(
|
419
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
420
420
|
self._tbt)
|
421
|
-
self._span.set_attribute(
|
421
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
422
422
|
self._ttft)
|
423
|
-
self._span.set_attribute(
|
423
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
424
424
|
version)
|
425
425
|
if capture_message_content:
|
426
426
|
self._span.add_event(
|
427
|
-
name=
|
427
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
428
428
|
attributes={
|
429
|
-
|
429
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
430
430
|
},
|
431
431
|
)
|
432
432
|
self._span.add_event(
|
433
|
-
name=
|
433
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
434
434
|
attributes={
|
435
|
-
|
435
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
|
436
436
|
},
|
437
437
|
)
|
438
438
|
self._span.set_status(Status(StatusCode.OK))
|
@@ -441,8 +441,8 @@ def async_chat_stream(version, environment, application_name,
|
|
441
441
|
attributes = create_metrics_attributes(
|
442
442
|
service_name=application_name,
|
443
443
|
deployment_environment=environment,
|
444
|
-
operation=
|
445
|
-
system=
|
444
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
445
|
+
system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
|
446
446
|
request_model=request_model,
|
447
447
|
server_address=self._server_address,
|
448
448
|
server_port=self._server_port,
|
@@ -476,7 +476,7 @@ def async_chat_stream(version, environment, application_name,
|
|
476
476
|
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
|
477
477
|
request_model = kwargs.get('model', 'mistral-small-latest')
|
478
478
|
|
479
|
-
span_name = f'{
|
479
|
+
span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
|
480
480
|
|
481
481
|
awaited_wrapped = await wrapped(*args, **kwargs)
|
482
482
|
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
|
@@ -521,7 +521,7 @@ def async_embeddings(version, environment, application_name,
|
|
521
521
|
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
|
522
522
|
request_model = kwargs.get('model', 'mistral-embed')
|
523
523
|
|
524
|
-
span_name = f'{
|
524
|
+
span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
|
525
525
|
|
526
526
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
527
527
|
start_time = time.time()
|
@@ -538,21 +538,21 @@ def async_embeddings(version, environment, application_name,
|
|
538
538
|
|
539
539
|
# Set Span attributes (OTel Semconv)
|
540
540
|
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
541
|
-
span.set_attribute(
|
542
|
-
|
543
|
-
span.set_attribute(
|
544
|
-
|
545
|
-
span.set_attribute(
|
541
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
542
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
|
543
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
544
|
+
SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
|
545
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
546
546
|
request_model)
|
547
|
-
span.set_attribute(
|
547
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
|
548
548
|
[kwargs.get('encoding_format', 'float')])
|
549
|
-
span.set_attribute(
|
549
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
550
550
|
response_dict.get('model'))
|
551
|
-
span.set_attribute(
|
551
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
552
552
|
server_address)
|
553
|
-
span.set_attribute(
|
553
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
554
554
|
server_port)
|
555
|
-
span.set_attribute(
|
555
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
556
556
|
input_tokens)
|
557
557
|
|
558
558
|
# Set Span attributes (Extras)
|
@@ -560,18 +560,18 @@ def async_embeddings(version, environment, application_name,
|
|
560
560
|
environment)
|
561
561
|
span.set_attribute(SERVICE_NAME,
|
562
562
|
application_name)
|
563
|
-
span.set_attribute(
|
563
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
564
564
|
input_tokens)
|
565
|
-
span.set_attribute(
|
565
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
566
566
|
cost)
|
567
|
-
span.set_attribute(
|
567
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
568
568
|
version)
|
569
569
|
|
570
570
|
if capture_message_content:
|
571
571
|
span.add_event(
|
572
|
-
name=
|
572
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
573
573
|
attributes={
|
574
|
-
|
574
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('inputs', '')),
|
575
575
|
},
|
576
576
|
)
|
577
577
|
|
@@ -581,8 +581,8 @@ def async_embeddings(version, environment, application_name,
|
|
581
581
|
attributes = create_metrics_attributes(
|
582
582
|
service_name=application_name,
|
583
583
|
deployment_environment=environment,
|
584
|
-
operation=
|
585
|
-
system=
|
584
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
|
585
|
+
system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
|
586
586
|
request_model=request_model,
|
587
587
|
server_address=server_address,
|
588
588
|
server_port=server_port,
|