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 embed(version, environment, application_name, tracer,
|
|
58
58
|
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
59
59
|
request_model = kwargs.get("model", "mbed-english-v3.0")
|
60
60
|
|
61
|
-
span_name = f"{
|
61
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {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()
|
@@ -74,23 +74,23 @@ def embed(version, environment, application_name, tracer,
|
|
74
74
|
|
75
75
|
# Set Span attributes (OTel Semconv)
|
76
76
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
77
|
-
span.set_attribute(
|
78
|
-
|
79
|
-
span.set_attribute(
|
80
|
-
|
81
|
-
span.set_attribute(
|
77
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
78
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
|
79
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
80
|
+
SemanticConvention.GEN_AI_SYSTEM_COHERE)
|
81
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
82
82
|
request_model)
|
83
|
-
span.set_attribute(
|
83
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
|
84
84
|
kwargs.get('embedding_types', ['float']))
|
85
|
-
span.set_attribute(
|
85
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
86
86
|
request_model)
|
87
|
-
span.set_attribute(
|
87
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
88
88
|
server_address)
|
89
|
-
span.set_attribute(
|
89
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
90
90
|
server_port)
|
91
|
-
span.set_attribute(
|
91
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
92
92
|
input_tokens)
|
93
|
-
span.set_attribute(
|
93
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
94
94
|
response_dict.get('response_type'))
|
95
95
|
|
96
96
|
# Set Span attributes (Extras)
|
@@ -98,18 +98,18 @@ def embed(version, environment, application_name, tracer,
|
|
98
98
|
environment)
|
99
99
|
span.set_attribute(SERVICE_NAME,
|
100
100
|
application_name)
|
101
|
-
span.set_attribute(
|
101
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
102
102
|
input_tokens)
|
103
|
-
span.set_attribute(
|
103
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
104
104
|
cost)
|
105
|
-
span.set_attribute(
|
105
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
106
106
|
version)
|
107
107
|
|
108
108
|
if capture_message_content:
|
109
109
|
span.add_event(
|
110
|
-
name=
|
110
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
111
111
|
attributes={
|
112
|
-
|
112
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("texts", "")),
|
113
113
|
},
|
114
114
|
)
|
115
115
|
|
@@ -119,8 +119,8 @@ def embed(version, environment, application_name, tracer,
|
|
119
119
|
attributes = create_metrics_attributes(
|
120
120
|
service_name=application_name,
|
121
121
|
deployment_environment=environment,
|
122
|
-
operation=
|
123
|
-
system=
|
122
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
|
123
|
+
system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
|
124
124
|
request_model=request_model,
|
125
125
|
server_address=server_address,
|
126
126
|
server_port=server_port,
|
@@ -185,7 +185,7 @@ def chat(version, environment, application_name, tracer,
|
|
185
185
|
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
186
186
|
request_model = kwargs.get("model", "command-r-plus-08-2024")
|
187
187
|
|
188
|
-
span_name = f"{
|
188
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
189
189
|
|
190
190
|
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
191
191
|
start_time = time.time()
|
@@ -224,45 +224,45 @@ def chat(version, environment, application_name, tracer,
|
|
224
224
|
|
225
225
|
# Set base span attribues (OTel Semconv)
|
226
226
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
227
|
-
span.set_attribute(
|
228
|
-
|
229
|
-
span.set_attribute(
|
230
|
-
|
231
|
-
span.set_attribute(
|
227
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
228
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
229
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
230
|
+
SemanticConvention.GEN_AI_SYSTEM_COHERE)
|
231
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
232
232
|
request_model)
|
233
|
-
span.set_attribute(
|
233
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
234
234
|
kwargs.get("seed", ""))
|
235
|
-
span.set_attribute(
|
235
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
236
236
|
server_port)
|
237
|
-
span.set_attribute(
|
237
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
238
238
|
kwargs.get("frequency_penalty", 0.0))
|
239
|
-
span.set_attribute(
|
239
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
240
240
|
kwargs.get("max_tokens", -1))
|
241
|
-
span.set_attribute(
|
241
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
242
242
|
kwargs.get("presence_penalty", 0.0))
|
243
|
-
span.set_attribute(
|
243
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
244
244
|
kwargs.get("stop_sequences", []))
|
245
|
-
span.set_attribute(
|
245
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
246
246
|
kwargs.get("temperature", 0.3))
|
247
|
-
span.set_attribute(
|
247
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
|
248
248
|
kwargs.get("k", 1.0))
|
249
|
-
span.set_attribute(
|
249
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
250
250
|
kwargs.get("p", 1.0))
|
251
|
-
span.set_attribute(
|
251
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
252
252
|
response_dict.get("id"))
|
253
|
-
span.set_attribute(
|
253
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
254
254
|
request_model)
|
255
|
-
span.set_attribute(
|
255
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
256
256
|
input_tokens)
|
257
|
-
span.set_attribute(
|
257
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
258
258
|
output_tokens)
|
259
|
-
span.set_attribute(
|
259
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
260
260
|
server_address)
|
261
261
|
if isinstance(llm_response, str):
|
262
|
-
span.set_attribute(
|
262
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
263
263
|
"text")
|
264
264
|
else:
|
265
|
-
span.set_attribute(
|
265
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
266
266
|
"json")
|
267
267
|
|
268
268
|
# Set base span attribues (Extras)
|
@@ -270,28 +270,28 @@ def chat(version, environment, application_name, tracer,
|
|
270
270
|
environment)
|
271
271
|
span.set_attribute(SERVICE_NAME,
|
272
272
|
application_name)
|
273
|
-
span.set_attribute(
|
273
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
274
274
|
False)
|
275
|
-
span.set_attribute(
|
275
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
276
276
|
input_tokens + output_tokens)
|
277
|
-
span.set_attribute(
|
277
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
278
278
|
cost)
|
279
|
-
span.set_attribute(
|
279
|
+
span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
280
280
|
end_time - start_time)
|
281
|
-
span.set_attribute(
|
281
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
282
282
|
version)
|
283
283
|
|
284
284
|
if capture_message_content:
|
285
285
|
span.add_event(
|
286
|
-
name=
|
286
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
287
287
|
attributes={
|
288
|
-
|
288
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
289
289
|
},
|
290
290
|
)
|
291
291
|
span.add_event(
|
292
|
-
name=
|
292
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
293
293
|
attributes={
|
294
|
-
|
294
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
|
295
295
|
},
|
296
296
|
)
|
297
297
|
|
@@ -301,8 +301,8 @@ def chat(version, environment, application_name, tracer,
|
|
301
301
|
attributes = create_metrics_attributes(
|
302
302
|
service_name=application_name,
|
303
303
|
deployment_environment=environment,
|
304
|
-
operation=
|
305
|
-
system=
|
304
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
305
|
+
system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
|
306
306
|
request_model=request_model,
|
307
307
|
server_address=server_address,
|
308
308
|
server_port=server_port,
|
@@ -486,48 +486,48 @@ def chat_stream(version, environment, application_name,
|
|
486
486
|
|
487
487
|
# Set Span attributes (OTel Semconv)
|
488
488
|
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
489
|
-
self._span.set_attribute(
|
490
|
-
|
491
|
-
self._span.set_attribute(
|
492
|
-
|
493
|
-
self._span.set_attribute(
|
489
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
490
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
491
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
492
|
+
SemanticConvention.GEN_AI_SYSTEM_COHERE)
|
493
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
494
494
|
request_model)
|
495
|
-
self._span.set_attribute(
|
495
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
496
496
|
self._kwargs.get("seed", ""))
|
497
|
-
self._span.set_attribute(
|
497
|
+
self._span.set_attribute(SemanticConvention.SERVER_PORT,
|
498
498
|
self._server_port)
|
499
|
-
self._span.set_attribute(
|
499
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
500
500
|
self._kwargs.get("frequency_penalty", 0.0))
|
501
|
-
self._span.set_attribute(
|
501
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
502
502
|
self._kwargs.get("max_tokens", -1))
|
503
|
-
self._span.set_attribute(
|
503
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
504
504
|
self._kwargs.get("presence_penalty", 0.0))
|
505
|
-
self._span.set_attribute(
|
505
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
506
506
|
self._kwargs.get("stop_sequences", []))
|
507
|
-
self._span.set_attribute(
|
507
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
508
508
|
self._kwargs.get("temperature", 0.3))
|
509
|
-
self._span.set_attribute(
|
509
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
|
510
510
|
self._kwargs.get("k", 1.0))
|
511
|
-
self._span.set_attribute(
|
511
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
512
512
|
self._kwargs.get("p", 1.0))
|
513
|
-
self._span.set_attribute(
|
513
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
|
514
514
|
[self._finish_reason])
|
515
|
-
self._span.set_attribute(
|
515
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
516
516
|
self._response_id)
|
517
|
-
self._span.set_attribute(
|
517
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
518
518
|
request_model)
|
519
|
-
self._span.set_attribute(
|
519
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
520
520
|
self._input_tokens)
|
521
|
-
self._span.set_attribute(
|
521
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
522
522
|
self._output_tokens)
|
523
|
-
self._span.set_attribute(
|
523
|
+
self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
524
524
|
self._server_address)
|
525
525
|
|
526
526
|
if isinstance(self._llmresponse, str):
|
527
|
-
self._span.set_attribute(
|
527
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
528
528
|
"text")
|
529
529
|
else:
|
530
|
-
self._span.set_attribute(
|
530
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
531
531
|
"json")
|
532
532
|
|
533
533
|
# Set Span attributes (Extra)
|
@@ -535,29 +535,29 @@ def chat_stream(version, environment, application_name,
|
|
535
535
|
environment)
|
536
536
|
self._span.set_attribute(SERVICE_NAME,
|
537
537
|
application_name)
|
538
|
-
self._span.set_attribute(
|
538
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
539
539
|
True)
|
540
|
-
self._span.set_attribute(
|
540
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
541
541
|
self._input_tokens + self._output_tokens)
|
542
|
-
self._span.set_attribute(
|
542
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
543
543
|
cost)
|
544
|
-
self._span.set_attribute(
|
544
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
545
545
|
self._tbt)
|
546
|
-
self._span.set_attribute(
|
546
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
547
547
|
self._ttft)
|
548
|
-
self._span.set_attribute(
|
548
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
549
549
|
version)
|
550
550
|
if capture_message_content:
|
551
551
|
self._span.add_event(
|
552
|
-
name=
|
552
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
553
553
|
attributes={
|
554
|
-
|
554
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
555
555
|
},
|
556
556
|
)
|
557
557
|
self._span.add_event(
|
558
|
-
name=
|
558
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
559
559
|
attributes={
|
560
|
-
|
560
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
|
561
561
|
},
|
562
562
|
)
|
563
563
|
self._span.set_status(Status(StatusCode.OK))
|
@@ -566,8 +566,8 @@ def chat_stream(version, environment, application_name,
|
|
566
566
|
attributes = create_metrics_attributes(
|
567
567
|
service_name=application_name,
|
568
568
|
deployment_environment=environment,
|
569
|
-
operation=
|
570
|
-
system=
|
569
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
570
|
+
system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
|
571
571
|
request_model=request_model,
|
572
572
|
server_address=self._server_address,
|
573
573
|
server_port=self._server_port,
|
@@ -601,7 +601,7 @@ def chat_stream(version, environment, application_name,
|
|
601
601
|
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
602
602
|
request_model = kwargs.get("model", "command-r-plus")
|
603
603
|
|
604
|
-
span_name = f"{
|
604
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
605
605
|
|
606
606
|
awaited_wrapped = wrapped(*args, **kwargs)
|
607
607
|
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
|
@@ -7,7 +7,7 @@ import logging
|
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
8
|
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
|
-
from openlit.semcov import
|
10
|
+
from openlit.semcov import SemanticConvention
|
11
11
|
|
12
12
|
# Initialize logger for logging potential issues and operations
|
13
13
|
logger = logging.getLogger(__name__)
|
@@ -60,42 +60,42 @@ def wrap_controlflow(gen_ai_endpoint, version, environment, application_name,
|
|
60
60
|
|
61
61
|
try:
|
62
62
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
63
|
-
span.set_attribute(
|
63
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
|
-
span.set_attribute(
|
66
|
-
|
65
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
66
|
+
SemanticConvention.GEN_AI_SYSTEM_CONTROLFLOW)
|
67
67
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
68
68
|
environment)
|
69
69
|
span.set_attribute(SERVICE_NAME,
|
70
70
|
application_name)
|
71
|
-
span.set_attribute(
|
72
|
-
|
71
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
72
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
|
73
73
|
|
74
74
|
if gen_ai_endpoint == "controlflow.create_agent":
|
75
|
-
span.set_attribute(
|
75
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
|
76
76
|
instance.name)
|
77
|
-
span.set_attribute(
|
77
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
|
78
78
|
kwargs.get("instructions", ""))
|
79
|
-
span.set_attribute(
|
79
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
|
80
80
|
str(kwargs.get("tools", "")))
|
81
81
|
|
82
82
|
try:
|
83
|
-
span.set_attribute(
|
83
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
84
84
|
instance.model.model_name)
|
85
85
|
except:
|
86
|
-
span.set_attribute(
|
86
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
87
87
|
kwargs.get("model", "openai/gpt-4o-mini"))
|
88
88
|
|
89
89
|
elif gen_ai_endpoint == "controlflow.create_task":
|
90
90
|
if kwargs.get("objective","") == "":
|
91
|
-
span.set_attribute(
|
91
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
|
92
92
|
str(args[0]))
|
93
93
|
else:
|
94
|
-
span.set_attribute(
|
94
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
|
95
95
|
kwargs.get("objective",""))
|
96
|
-
span.set_attribute(
|
96
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
|
97
97
|
kwargs.get("instructions", ""))
|
98
|
-
span.set_attribute(
|
98
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
|
99
99
|
str(kwargs.get("context", "")))
|
100
100
|
|
101
101
|
span.set_status(Status(StatusCode.OK))
|
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
|
|
9
9
|
from openlit.__helpers import (
|
10
10
|
handle_exception,
|
11
11
|
)
|
12
|
-
from openlit.semcov import
|
12
|
+
from openlit.semcov import SemanticConvention
|
13
13
|
|
14
14
|
# Initialize logger for logging potential issues and operations
|
15
15
|
logger = logging.getLogger(__name__)
|
@@ -56,38 +56,38 @@ def async_wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
56
56
|
try:
|
57
57
|
# Set base span attribues
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
|
-
span.set_attribute(
|
60
|
-
|
61
|
-
span.set_attribute(
|
62
|
-
|
63
|
-
span.set_attribute(
|
59
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
60
|
+
SemanticConvention.GEN_AI_SYSTEM_CRAWL4AI)
|
61
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
62
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
|
63
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SERVICE_NAME,
|
66
66
|
application_name)
|
67
67
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
68
68
|
environment)
|
69
|
-
span.set_attribute(
|
70
|
-
|
71
|
-
span.set_attribute(
|
69
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
|
70
|
+
SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER)
|
71
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
|
72
72
|
|
73
73
|
url = kwargs.get("url") if "url" in kwargs else str(args[0]) if args else None
|
74
74
|
if url is not None:
|
75
|
-
span.set_attribute(
|
75
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url)
|
76
76
|
|
77
77
|
extraction_strategy = kwargs.get("extraction_strategy", "NoExtractionStrategy")
|
78
78
|
extraction_name = extraction_strategy.name if hasattr(extraction_strategy, 'name') else extraction_strategy
|
79
79
|
|
80
|
-
span.set_attribute(
|
80
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_STRATEGY, extraction_name)
|
81
81
|
|
82
82
|
if extraction_name == "LLMExtractionStrategy" and hasattr(extraction_strategy, 'provider'):
|
83
83
|
_, llm_model = extraction_strategy.provider.split('/')
|
84
|
-
span.set_attribute(
|
84
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, llm_model)
|
85
85
|
|
86
86
|
elif extraction_name == "CosineStrategy":
|
87
|
-
span.set_attribute(
|
87
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
|
88
88
|
|
89
89
|
elif extraction_name == "JsonCssExtractionStrategy" and hasattr(extraction_strategy, 'schema'):
|
90
|
-
span.set_attribute(
|
90
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
|
91
91
|
|
92
92
|
span.set_status(Status(StatusCode.OK))
|
93
93
|
|
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
|
|
9
9
|
from openlit.__helpers import (
|
10
10
|
handle_exception,
|
11
11
|
)
|
12
|
-
from openlit.semcov import
|
12
|
+
from openlit.semcov import SemanticConvention
|
13
13
|
|
14
14
|
# Initialize logger for logging potential issues and operations
|
15
15
|
logger = logging.getLogger(__name__)
|
@@ -56,38 +56,38 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
56
56
|
try:
|
57
57
|
# Set base span attribues
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
|
-
span.set_attribute(
|
60
|
-
|
61
|
-
span.set_attribute(
|
62
|
-
|
63
|
-
span.set_attribute(
|
59
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
60
|
+
SemanticConvention.GEN_AI_SYSTEM_CRAWL4AI)
|
61
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
62
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
|
63
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SERVICE_NAME,
|
66
66
|
application_name)
|
67
67
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
68
68
|
environment)
|
69
|
-
span.set_attribute(
|
70
|
-
|
71
|
-
span.set_attribute(
|
69
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
|
70
|
+
SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER)
|
71
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
|
72
72
|
|
73
73
|
url = kwargs.get("url") if "url" in kwargs else str(args[0]) if args else None
|
74
74
|
if url is not None:
|
75
|
-
span.set_attribute(
|
75
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url)
|
76
76
|
|
77
77
|
extraction_strategy = kwargs.get("extraction_strategy", "NoExtractionStrategy")
|
78
78
|
extraction_name = extraction_strategy.name if hasattr(extraction_strategy, 'name') else extraction_strategy
|
79
79
|
|
80
|
-
span.set_attribute(
|
80
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_STRATEGY, extraction_name)
|
81
81
|
|
82
82
|
if extraction_name == "LLMExtractionStrategy" and hasattr(extraction_strategy, 'provider'):
|
83
83
|
_, llm_model = extraction_strategy.provider.split('/')
|
84
|
-
span.set_attribute(
|
84
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, llm_model)
|
85
85
|
|
86
86
|
elif extraction_name == "CosineStrategy":
|
87
|
-
span.set_attribute(
|
87
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
|
88
88
|
|
89
89
|
elif extraction_name == "JsonCssExtractionStrategy" and hasattr(extraction_strategy, 'schema'):
|
90
|
-
span.set_attribute(
|
90
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
|
91
91
|
|
92
92
|
span.set_status(Status(StatusCode.OK))
|
93
93
|
|
@@ -10,7 +10,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
|
|
10
10
|
from openlit.__helpers import (
|
11
11
|
handle_exception,
|
12
12
|
)
|
13
|
-
from openlit.semcov import
|
13
|
+
from openlit.semcov import SemanticConvention
|
14
14
|
|
15
15
|
# Initialize logger for logging potential issues and operations
|
16
16
|
logger = logging.getLogger(__name__)
|
@@ -69,11 +69,11 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
69
69
|
try:
|
70
70
|
# Set base span attribues
|
71
71
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
72
|
-
span.set_attribute(
|
73
|
-
|
74
|
-
span.set_attribute(
|
75
|
-
|
76
|
-
span.set_attribute(
|
72
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
73
|
+
SemanticConvention.GEN_AI_SYSTEM_CREWAI)
|
74
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
75
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
|
76
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
77
77
|
gen_ai_endpoint)
|
78
78
|
span.set_attribute(SERVICE_NAME,
|
79
79
|
application_name)
|
@@ -95,17 +95,17 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
95
95
|
else:
|
96
96
|
task[key] = str(value)
|
97
97
|
|
98
|
-
span.set_attribute(
|
98
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ID,
|
99
99
|
task.get('id', ''))
|
100
|
-
span.set_attribute(
|
100
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK,
|
101
101
|
task.get('description', ''))
|
102
|
-
span.set_attribute(
|
102
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_EXPECTED_OUTPUT,
|
103
103
|
task.get('expected_output', ''))
|
104
|
-
span.set_attribute(
|
104
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ACTUAL_OUTPUT,
|
105
105
|
task.get('output', ''))
|
106
|
-
span.set_attribute(
|
106
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_HUMAN_INPUT,
|
107
107
|
task.get('human_input', ''))
|
108
|
-
span.set_attribute(
|
108
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ASSOCIATION,
|
109
109
|
str(task.get('processed_by_agents', '')))
|
110
110
|
|
111
111
|
elif instance_class == "Agent":
|
@@ -117,25 +117,25 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
117
117
|
continue
|
118
118
|
agent[key] = str(value)
|
119
119
|
|
120
|
-
span.set_attribute(
|
120
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
|
121
121
|
agent.get('id', ''))
|
122
|
-
span.set_attribute(
|
122
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
|
123
123
|
agent.get('role', ''))
|
124
|
-
span.set_attribute(
|
124
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
|
125
125
|
agent.get('goal', ''))
|
126
|
-
span.set_attribute(
|
126
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
|
127
127
|
agent.get('backstory', ''))
|
128
|
-
span.set_attribute(
|
128
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE,
|
129
129
|
agent.get('cache', ''))
|
130
|
-
span.set_attribute(
|
130
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ALLOW_DELEGATION,
|
131
131
|
agent.get('allow_delegation', ''))
|
132
|
-
span.set_attribute(
|
132
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ALLOW_CODE_EXECUTION,
|
133
133
|
agent.get('allow_code_execution', ''))
|
134
|
-
span.set_attribute(
|
134
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_MAX_RETRY_LIMIT,
|
135
135
|
agent.get('max_retry_limit', ''))
|
136
|
-
span.set_attribute(
|
136
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
|
137
137
|
str(agent.get('tools', '')))
|
138
|
-
span.set_attribute(
|
138
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOL_RESULTS,
|
139
139
|
str(agent.get('tools_results', '')))
|
140
140
|
|
141
141
|
span.set_status(Status(StatusCode.OK))
|