openlit 1.16.0__py3-none-any.whl → 1.17.0__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/instrumentation/anthropic/anthropic.py +30 -12
- openlit/instrumentation/anthropic/async_anthropic.py +29 -12
- openlit/instrumentation/bedrock/__init__.py +3 -3
- openlit/instrumentation/bedrock/bedrock.py +77 -307
- openlit/instrumentation/cohere/cohere.py +35 -14
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +6 -2
- openlit/instrumentation/elevenlabs/elevenlabs.py +6 -2
- openlit/instrumentation/gpt4all/gpt4all.py +30 -10
- openlit/instrumentation/groq/async_groq.py +41 -21
- openlit/instrumentation/groq/groq.py +41 -21
- openlit/instrumentation/mistral/async_mistral.py +37 -16
- openlit/instrumentation/mistral/mistral.py +37 -16
- openlit/instrumentation/ollama/async_ollama.py +57 -20
- openlit/instrumentation/ollama/ollama.py +57 -20
- openlit/instrumentation/openai/async_azure_openai.py +106 -47
- openlit/instrumentation/openai/async_openai.py +78 -37
- openlit/instrumentation/openai/azure_openai.py +101 -43
- openlit/instrumentation/openai/openai.py +78 -39
- openlit/instrumentation/transformers/transformers.py +21 -17
- openlit/instrumentation/vertexai/async_vertexai.py +104 -35
- openlit/instrumentation/vertexai/vertexai.py +104 -35
- openlit/semcov/__init__.py +6 -4
- {openlit-1.16.0.dist-info → openlit-1.17.0.dist-info}/METADATA +2 -2
- {openlit-1.16.0.dist-info → openlit-1.17.0.dist-info}/RECORD +26 -26
- {openlit-1.16.0.dist-info → openlit-1.17.0.dist-info}/LICENSE +0 -0
- {openlit-1.16.0.dist-info → openlit-1.17.0.dist-info}/WHEEL +0 -0
@@ -122,15 +122,15 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
122
122
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
123
123
|
kwargs.get("user", ""))
|
124
124
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
125
|
-
kwargs.get("top_p", 1))
|
125
|
+
kwargs.get("top_p", 1.0))
|
126
126
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
127
|
-
kwargs.get("max_tokens",
|
127
|
+
kwargs.get("max_tokens", -1))
|
128
128
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
129
|
-
kwargs.get("temperature", 1))
|
129
|
+
kwargs.get("temperature", 1.0))
|
130
130
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
131
|
-
kwargs.get("presence_penalty", 0))
|
131
|
+
kwargs.get("presence_penalty", 0.0))
|
132
132
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
133
|
-
kwargs.get("frequency_penalty", 0))
|
133
|
+
kwargs.get("frequency_penalty", 0.0))
|
134
134
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
135
135
|
kwargs.get("seed", ""))
|
136
136
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -144,10 +144,18 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
144
144
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
145
145
|
cost)
|
146
146
|
if trace_content:
|
147
|
-
span.
|
148
|
-
|
149
|
-
|
150
|
-
|
147
|
+
span.add_event(
|
148
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
149
|
+
attributes={
|
150
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
151
|
+
},
|
152
|
+
)
|
153
|
+
span.add_event(
|
154
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
155
|
+
attributes={
|
156
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llmresponse,
|
157
|
+
},
|
158
|
+
)
|
151
159
|
|
152
160
|
span.set_status(Status(StatusCode.OK))
|
153
161
|
|
@@ -224,24 +232,28 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
224
232
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
225
233
|
kwargs.get("model", "gpt-3.5-turbo"))
|
226
234
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
227
|
-
kwargs.get("top_p", 1))
|
235
|
+
kwargs.get("top_p", 1.0))
|
228
236
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
229
|
-
kwargs.get("max_tokens",
|
237
|
+
kwargs.get("max_tokens", -1))
|
230
238
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
231
239
|
kwargs.get("user", ""))
|
232
240
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
233
|
-
kwargs.get("temperature", 1))
|
241
|
+
kwargs.get("temperature", 1.0))
|
234
242
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
235
|
-
kwargs.get("presence_penalty", 0))
|
243
|
+
kwargs.get("presence_penalty", 0.0))
|
236
244
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
237
|
-
kwargs.get("frequency_penalty", 0))
|
245
|
+
kwargs.get("frequency_penalty", 0.0))
|
238
246
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
239
247
|
kwargs.get("seed", ""))
|
240
248
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
241
249
|
False)
|
242
250
|
if trace_content:
|
243
|
-
span.
|
244
|
-
|
251
|
+
span.add_event(
|
252
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
253
|
+
attributes={
|
254
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
255
|
+
},
|
256
|
+
)
|
245
257
|
|
246
258
|
span.set_status(Status(StatusCode.OK))
|
247
259
|
|
@@ -259,23 +271,31 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
259
271
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
260
272
|
response.usage.total_tokens)
|
261
273
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
262
|
-
response.choices[0].finish_reason)
|
274
|
+
[response.choices[0].finish_reason])
|
263
275
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
264
276
|
cost)
|
265
277
|
|
266
278
|
# Set span attributes for when n = 1 (default)
|
267
279
|
if "n" not in kwargs or kwargs["n"] == 1:
|
268
280
|
if trace_content:
|
269
|
-
span.
|
270
|
-
|
281
|
+
span.add_event(
|
282
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
283
|
+
attributes={
|
284
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[0].message.content,
|
285
|
+
},
|
286
|
+
)
|
271
287
|
|
272
288
|
# Set span attributes for when n > 0
|
273
289
|
else:
|
274
290
|
i = 0
|
275
291
|
while i < kwargs["n"] and trace_content is True:
|
276
|
-
attribute_name = f"gen_ai.completion.{i}"
|
277
|
-
span.
|
278
|
-
|
292
|
+
attribute_name = f"gen_ai.content.completion.{i}"
|
293
|
+
span.add_event(
|
294
|
+
name=attribute_name,
|
295
|
+
attributes={
|
296
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[i].message.content,
|
297
|
+
},
|
298
|
+
)
|
279
299
|
i += 1
|
280
300
|
|
281
301
|
# Return original response
|
@@ -288,8 +308,12 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
288
308
|
pricing_info, response.usage.prompt_tokens,
|
289
309
|
response.usage.completion_tokens)
|
290
310
|
|
291
|
-
span.
|
292
|
-
|
311
|
+
span.add_event(
|
312
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
313
|
+
attributes={
|
314
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: "Function called with tools",
|
315
|
+
},
|
316
|
+
)
|
293
317
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
|
294
318
|
response.usage.prompt_tokens)
|
295
319
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COMPLETION_TOKENS,
|
@@ -405,8 +429,12 @@ def async_embedding(gen_ai_endpoint, version, environment, application_name,
|
|
405
429
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
406
430
|
cost)
|
407
431
|
if trace_content:
|
408
|
-
span.
|
409
|
-
|
432
|
+
span.add_event(
|
433
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
434
|
+
attributes={
|
435
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
|
436
|
+
},
|
437
|
+
)
|
410
438
|
|
411
439
|
span.set_status(Status(StatusCode.OK))
|
412
440
|
|
@@ -611,12 +639,19 @@ def async_image_generate(gen_ai_endpoint, version, environment, application_name
|
|
611
639
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
612
640
|
kwargs.get("user", ""))
|
613
641
|
if trace_content:
|
614
|
-
span.
|
615
|
-
|
616
|
-
|
642
|
+
span.add_event(
|
643
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
644
|
+
attributes={
|
645
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
|
646
|
+
},
|
647
|
+
)
|
617
648
|
attribute_name = f"gen_ai.response.image.{images_count}"
|
618
|
-
span.
|
619
|
-
|
649
|
+
span.add_event(
|
650
|
+
name=attribute_name,
|
651
|
+
attributes={
|
652
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
|
653
|
+
},
|
654
|
+
)
|
620
655
|
|
621
656
|
images_count+=1
|
622
657
|
|
@@ -729,11 +764,13 @@ def async_image_variatons(gen_ai_endpoint, version, environment, application_nam
|
|
729
764
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
|
730
765
|
"standard")
|
731
766
|
if trace_content:
|
732
|
-
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
|
733
|
-
kwargs.get(SemanticConvetion.GEN_AI_TYPE_IMAGE, ""))
|
734
|
-
|
735
767
|
attribute_name = f"gen_ai.response.image.{images_count}"
|
736
|
-
span.
|
768
|
+
span.add_event(
|
769
|
+
name=attribute_name,
|
770
|
+
attributes={
|
771
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
|
772
|
+
},
|
773
|
+
)
|
737
774
|
|
738
775
|
images_count+=1
|
739
776
|
|
@@ -838,8 +875,12 @@ def async_audio_create(gen_ai_endpoint, version, environment, application_name,
|
|
838
875
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
839
876
|
cost)
|
840
877
|
if trace_content:
|
841
|
-
span.
|
842
|
-
|
878
|
+
span.add_event(
|
879
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
880
|
+
attributes={
|
881
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
|
882
|
+
},
|
883
|
+
)
|
843
884
|
|
844
885
|
span.set_status(Status(StatusCode.OK))
|
845
886
|
|
@@ -125,11 +125,11 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
126
126
|
kwargs.get("tool_choice", ""))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
128
|
-
kwargs.get("temperature", 1))
|
128
|
+
kwargs.get("temperature", 1.0))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
130
|
-
kwargs.get("presence_penalty", 0))
|
130
|
+
kwargs.get("presence_penalty", 0.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
132
|
-
kwargs.get("frequency_penalty", 0))
|
132
|
+
kwargs.get("frequency_penalty", 0.0))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
134
134
|
kwargs.get("seed", ""))
|
135
135
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -143,10 +143,18 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
143
143
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
144
144
|
cost)
|
145
145
|
if trace_content:
|
146
|
-
span.
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
span.add_event(
|
147
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
148
|
+
attributes={
|
149
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
150
|
+
},
|
151
|
+
)
|
152
|
+
span.add_event(
|
153
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
154
|
+
attributes={
|
155
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llmresponse,
|
156
|
+
},
|
157
|
+
)
|
150
158
|
|
151
159
|
span.set_status(Status(StatusCode.OK))
|
152
160
|
|
@@ -228,15 +236,22 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
228
236
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
229
237
|
kwargs.get("tool_choice", ""))
|
230
238
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
231
|
-
kwargs.get("temperature", 1))
|
239
|
+
kwargs.get("temperature", 1.0))
|
232
240
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
233
|
-
kwargs.get("presence_penalty", 0))
|
241
|
+
kwargs.get("presence_penalty", 0.0))
|
234
242
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
235
|
-
kwargs.get("frequency_penalty", 0))
|
243
|
+
kwargs.get("frequency_penalty", 0.0))
|
236
244
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
237
245
|
kwargs.get("seed", ""))
|
238
246
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
239
247
|
False)
|
248
|
+
if trace_content:
|
249
|
+
span.add_event(
|
250
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
251
|
+
attributes={
|
252
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
253
|
+
},
|
254
|
+
)
|
240
255
|
if trace_content:
|
241
256
|
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
|
242
257
|
prompt)
|
@@ -255,23 +270,31 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
255
270
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
256
271
|
response.usage.total_tokens)
|
257
272
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
258
|
-
response.choices[0].finish_reason)
|
273
|
+
[response.choices[0].finish_reason])
|
259
274
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
260
275
|
cost)
|
261
276
|
|
262
277
|
# Set span attributes for when n = 1 (default)
|
263
278
|
if "n" not in kwargs or kwargs["n"] == 1:
|
264
279
|
if trace_content:
|
265
|
-
span.
|
266
|
-
|
280
|
+
span.add_event(
|
281
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
282
|
+
attributes={
|
283
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[0].message.content,
|
284
|
+
},
|
285
|
+
)
|
267
286
|
|
268
287
|
# Set span attributes for when n > 0
|
269
288
|
else:
|
270
289
|
i = 0
|
271
290
|
while i < kwargs["n"] and trace_content is True:
|
272
|
-
attribute_name = f"gen_ai.completion.{i}"
|
273
|
-
span.
|
274
|
-
|
291
|
+
attribute_name = f"gen_ai.content.completion.{i}"
|
292
|
+
span.add_event(
|
293
|
+
name=attribute_name,
|
294
|
+
attributes={
|
295
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[i].message.content,
|
296
|
+
},
|
297
|
+
)
|
275
298
|
i += 1
|
276
299
|
|
277
300
|
# Return original response
|
@@ -284,8 +307,12 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
284
307
|
response.usage.prompt_tokens,
|
285
308
|
response.usage.completion_tokens)
|
286
309
|
|
287
|
-
span.
|
288
|
-
|
310
|
+
span.add_event(
|
311
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
312
|
+
attributes={
|
313
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: "Function called with tools",
|
314
|
+
},
|
315
|
+
)
|
289
316
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
|
290
317
|
response.usage.prompt_tokens)
|
291
318
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COMPLETION_TOKENS,
|
@@ -423,11 +450,11 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
423
450
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
424
451
|
kwargs.get("tool_choice", ""))
|
425
452
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
426
|
-
kwargs.get("temperature", 1))
|
453
|
+
kwargs.get("temperature", 1.0))
|
427
454
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
428
|
-
kwargs.get("presence_penalty", 0))
|
455
|
+
kwargs.get("presence_penalty", 0.0))
|
429
456
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
430
|
-
kwargs.get("frequency_penalty", 0))
|
457
|
+
kwargs.get("frequency_penalty", 0.0))
|
431
458
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
432
459
|
kwargs.get("seed", ""))
|
433
460
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -441,10 +468,18 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
441
468
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
442
469
|
cost)
|
443
470
|
if trace_content:
|
444
|
-
span.
|
445
|
-
|
446
|
-
|
447
|
-
|
471
|
+
span.add_event(
|
472
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
473
|
+
attributes={
|
474
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
475
|
+
},
|
476
|
+
)
|
477
|
+
span.add_event(
|
478
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
479
|
+
attributes={
|
480
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llmresponse,
|
481
|
+
},
|
482
|
+
)
|
448
483
|
|
449
484
|
span.set_status(Status(StatusCode.OK))
|
450
485
|
|
@@ -507,18 +542,22 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
507
542
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
508
543
|
kwargs.get("tool_choice", ""))
|
509
544
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
510
|
-
kwargs.get("temperature", 1))
|
545
|
+
kwargs.get("temperature", 1.0))
|
511
546
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
512
|
-
kwargs.get("presence_penalty", 0))
|
547
|
+
kwargs.get("presence_penalty", 0.0))
|
513
548
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
514
|
-
kwargs.get("frequency_penalty", 0))
|
549
|
+
kwargs.get("frequency_penalty", 0.0))
|
515
550
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
516
551
|
kwargs.get("seed", ""))
|
517
552
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
518
553
|
False)
|
519
554
|
if trace_content:
|
520
|
-
span.
|
521
|
-
|
555
|
+
span.add_event(
|
556
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
557
|
+
attributes={
|
558
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
|
559
|
+
},
|
560
|
+
)
|
522
561
|
|
523
562
|
# Set span attributes when tools is not passed to the function call
|
524
563
|
if "tools" not in kwargs:
|
@@ -534,23 +573,31 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
534
573
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
535
574
|
response.usage.total_tokens)
|
536
575
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
537
|
-
response.choices[0].finish_reason)
|
576
|
+
[response.choices[0].finish_reason])
|
538
577
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
539
578
|
cost)
|
540
579
|
|
541
580
|
# Set span attributes for when n = 1 (default)
|
542
581
|
if "n" not in kwargs or kwargs["n"] == 1:
|
543
582
|
if trace_content:
|
544
|
-
span.
|
545
|
-
|
583
|
+
span.add_event(
|
584
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
585
|
+
attributes={
|
586
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[0].text,
|
587
|
+
},
|
588
|
+
)
|
546
589
|
|
547
590
|
# Set span attributes for when n > 0
|
548
591
|
else:
|
549
592
|
i = 0
|
550
593
|
while i < kwargs["n"] and trace_content is True:
|
551
|
-
attribute_name = f"gen_ai.completion.{i}"
|
552
|
-
span.
|
553
|
-
|
594
|
+
attribute_name = f"gen_ai.content.completion.{i}"
|
595
|
+
span.add_event(
|
596
|
+
name=attribute_name,
|
597
|
+
attributes={
|
598
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.choices[i].text,
|
599
|
+
},
|
600
|
+
)
|
554
601
|
i += 1
|
555
602
|
return response
|
556
603
|
|
@@ -678,8 +725,12 @@ def azure_embedding(gen_ai_endpoint, version, environment, application_name,
|
|
678
725
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
679
726
|
cost)
|
680
727
|
if trace_content:
|
681
|
-
span.
|
682
|
-
|
728
|
+
span.add_event(
|
729
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
730
|
+
attributes={
|
731
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
|
732
|
+
},
|
733
|
+
)
|
683
734
|
|
684
735
|
span.set_status(Status(StatusCode.OK))
|
685
736
|
|
@@ -795,12 +846,19 @@ def azure_image_generate(gen_ai_endpoint, version, environment, application_name
|
|
795
846
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
796
847
|
kwargs.get("user", ""))
|
797
848
|
if trace_content:
|
798
|
-
span.
|
799
|
-
|
800
|
-
|
849
|
+
span.add_event(
|
850
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
851
|
+
attributes={
|
852
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
|
853
|
+
},
|
854
|
+
)
|
801
855
|
attribute_name = f"gen_ai.response.image.{images_count}"
|
802
|
-
span.
|
803
|
-
|
856
|
+
span.add_event(
|
857
|
+
name=attribute_name,
|
858
|
+
attributes={
|
859
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
|
860
|
+
},
|
861
|
+
)
|
804
862
|
|
805
863
|
images_count+=1
|
806
864
|
|