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.
Files changed (80) hide show
  1. openlit/__helpers.py +11 -41
  2. openlit/__init__.py +3 -3
  3. openlit/evals/utils.py +7 -7
  4. openlit/guard/utils.py +7 -7
  5. openlit/instrumentation/ag2/ag2.py +24 -24
  6. openlit/instrumentation/ai21/ai21.py +3 -3
  7. openlit/instrumentation/ai21/async_ai21.py +3 -3
  8. openlit/instrumentation/ai21/utils.py +59 -59
  9. openlit/instrumentation/anthropic/anthropic.py +2 -2
  10. openlit/instrumentation/anthropic/async_anthropic.py +2 -2
  11. openlit/instrumentation/anthropic/utils.py +34 -34
  12. openlit/instrumentation/assemblyai/assemblyai.py +24 -24
  13. openlit/instrumentation/astra/astra.py +3 -3
  14. openlit/instrumentation/astra/async_astra.py +3 -3
  15. openlit/instrumentation/astra/utils.py +39 -39
  16. openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +10 -10
  17. openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +10 -10
  18. openlit/instrumentation/azure_ai_inference/utils.py +38 -38
  19. openlit/instrumentation/bedrock/__init__.py +2 -1
  20. openlit/instrumentation/bedrock/bedrock.py +32 -214
  21. openlit/instrumentation/bedrock/utils.py +252 -0
  22. openlit/instrumentation/chroma/chroma.py +57 -57
  23. openlit/instrumentation/cohere/async_cohere.py +88 -88
  24. openlit/instrumentation/cohere/cohere.py +88 -88
  25. openlit/instrumentation/controlflow/controlflow.py +15 -15
  26. openlit/instrumentation/crawl4ai/async_crawl4ai.py +14 -14
  27. openlit/instrumentation/crawl4ai/crawl4ai.py +14 -14
  28. openlit/instrumentation/crewai/crewai.py +22 -22
  29. openlit/instrumentation/dynamiq/dynamiq.py +19 -19
  30. openlit/instrumentation/elevenlabs/async_elevenlabs.py +24 -25
  31. openlit/instrumentation/elevenlabs/elevenlabs.py +23 -25
  32. openlit/instrumentation/embedchain/embedchain.py +15 -15
  33. openlit/instrumentation/firecrawl/firecrawl.py +10 -10
  34. openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +33 -33
  35. openlit/instrumentation/google_ai_studio/google_ai_studio.py +33 -33
  36. openlit/instrumentation/gpt4all/gpt4all.py +78 -78
  37. openlit/instrumentation/gpu/__init__.py +8 -8
  38. openlit/instrumentation/groq/async_groq.py +74 -74
  39. openlit/instrumentation/groq/groq.py +74 -74
  40. openlit/instrumentation/haystack/haystack.py +6 -6
  41. openlit/instrumentation/julep/async_julep.py +14 -14
  42. openlit/instrumentation/julep/julep.py +14 -14
  43. openlit/instrumentation/langchain/async_langchain.py +39 -39
  44. openlit/instrumentation/langchain/langchain.py +39 -39
  45. openlit/instrumentation/letta/letta.py +26 -26
  46. openlit/instrumentation/litellm/async_litellm.py +94 -94
  47. openlit/instrumentation/litellm/litellm.py +94 -94
  48. openlit/instrumentation/llamaindex/llamaindex.py +7 -7
  49. openlit/instrumentation/mem0/mem0.py +13 -13
  50. openlit/instrumentation/milvus/milvus.py +47 -47
  51. openlit/instrumentation/mistral/async_mistral.py +88 -88
  52. openlit/instrumentation/mistral/mistral.py +88 -88
  53. openlit/instrumentation/multion/async_multion.py +21 -21
  54. openlit/instrumentation/multion/multion.py +21 -21
  55. openlit/instrumentation/ollama/async_ollama.py +3 -3
  56. openlit/instrumentation/ollama/ollama.py +3 -3
  57. openlit/instrumentation/ollama/utils.py +50 -50
  58. openlit/instrumentation/openai/async_openai.py +225 -225
  59. openlit/instrumentation/openai/openai.py +225 -225
  60. openlit/instrumentation/openai_agents/openai_agents.py +11 -11
  61. openlit/instrumentation/phidata/phidata.py +15 -15
  62. openlit/instrumentation/pinecone/pinecone.py +43 -43
  63. openlit/instrumentation/premai/premai.py +86 -86
  64. openlit/instrumentation/qdrant/async_qdrant.py +95 -95
  65. openlit/instrumentation/qdrant/qdrant.py +99 -99
  66. openlit/instrumentation/reka/async_reka.py +33 -33
  67. openlit/instrumentation/reka/reka.py +33 -33
  68. openlit/instrumentation/together/async_together.py +90 -90
  69. openlit/instrumentation/together/together.py +90 -90
  70. openlit/instrumentation/transformers/transformers.py +26 -26
  71. openlit/instrumentation/vertexai/async_vertexai.py +64 -64
  72. openlit/instrumentation/vertexai/vertexai.py +64 -64
  73. openlit/instrumentation/vllm/vllm.py +24 -24
  74. openlit/otel/metrics.py +11 -11
  75. openlit/semcov/__init__.py +3 -3
  76. {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/METADATA +8 -8
  77. openlit-1.33.20.dist-info/RECORD +131 -0
  78. {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/WHEEL +1 -1
  79. openlit-1.33.18.dist-info/RECORD +0 -130
  80. {openlit-1.33.18.dist-info → openlit-1.33.20.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 SemanticConvetion
19
+ from openlit.semcov import SemanticConvention
20
20
 
21
21
  # Initialize logger for logging potential issues and operations
22
22
  logger = logging.getLogger(__name__)
@@ -157,46 +157,46 @@ def completion(version, environment, application_name,
157
157
 
158
158
  # Set Span attributes (OTel Semconv)
159
159
  self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
160
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
161
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
162
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
163
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
164
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
160
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
161
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
162
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
163
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
164
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
165
165
  request_model)
166
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
166
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
167
167
  self._kwargs.get("seed", ""))
168
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
168
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
169
169
  self._server_port)
170
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
170
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
171
171
  self._kwargs.get("frequency_penalty", 0.0))
172
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
172
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
173
173
  self._kwargs.get("max_tokens", -1))
174
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
174
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
175
175
  self._kwargs.get("presence_penalty", 0.0))
176
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
176
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
177
177
  self._kwargs.get("stop", []))
178
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
178
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
179
179
  self._kwargs.get("temperature", 1.0))
180
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
180
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
181
181
  self._kwargs.get("top_p", 1.0))
182
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
182
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
183
183
  [self._finish_reason])
184
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
184
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
185
185
  self._response_id)
186
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
186
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
187
187
  self._response_model)
188
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
188
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
189
189
  self._input_tokens)
190
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
190
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
191
191
  self._output_tokens)
192
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
192
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
193
193
  self._server_address)
194
194
 
195
195
  if isinstance(self._llmresponse, str):
196
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
196
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
197
197
  "text")
198
198
  else:
199
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
199
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
200
200
  "json")
201
201
 
202
202
  # Set Span attributes (Extra)
@@ -204,31 +204,31 @@ def completion(version, environment, application_name,
204
204
  environment)
205
205
  self._span.set_attribute(SERVICE_NAME,
206
206
  application_name)
207
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
207
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
208
208
  self._kwargs.get("user", ""))
209
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
209
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
210
210
  True)
211
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
211
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
212
212
  self._input_tokens + self._output_tokens)
213
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
213
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
214
214
  cost)
215
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
215
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
216
216
  self._tbt)
217
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
217
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
218
218
  self._ttft)
219
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
219
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
220
220
  version)
221
221
  if capture_message_content:
222
222
  self._span.add_event(
223
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
223
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
224
224
  attributes={
225
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
225
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
226
226
  },
227
227
  )
228
228
  self._span.add_event(
229
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
229
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
230
230
  attributes={
231
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
231
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
232
232
  },
233
233
  )
234
234
  self._span.set_status(Status(StatusCode.OK))
@@ -237,8 +237,8 @@ def completion(version, environment, application_name,
237
237
  attributes = create_metrics_attributes(
238
238
  service_name=application_name,
239
239
  deployment_environment=environment,
240
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
241
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
240
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
241
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
242
242
  request_model=request_model,
243
243
  server_address=self._server_address,
244
244
  server_port=self._server_port,
@@ -290,7 +290,7 @@ def completion(version, environment, application_name,
290
290
  server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
291
291
  request_model = kwargs.get("model", "gpt-4o")
292
292
 
293
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
293
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
294
294
 
295
295
  # pylint: disable=no-else-return
296
296
  if streaming:
@@ -338,37 +338,37 @@ def completion(version, environment, application_name,
338
338
 
339
339
  # Set base span attribues (OTel Semconv)
340
340
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
341
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
342
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
343
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
344
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
345
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
341
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
342
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
343
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
344
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
345
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
346
346
  request_model)
347
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
347
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
348
348
  kwargs.get("seed", ""))
349
- span.set_attribute(SemanticConvetion.SERVER_PORT,
349
+ span.set_attribute(SemanticConvention.SERVER_PORT,
350
350
  server_port)
351
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
351
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
352
352
  kwargs.get("frequency_penalty", 0.0))
353
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
353
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
354
354
  kwargs.get("max_tokens", -1))
355
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
355
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
356
356
  kwargs.get("presence_penalty", 0.0))
357
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
357
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
358
358
  kwargs.get("stop", []))
359
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
359
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
360
360
  kwargs.get("temperature", 1.0))
361
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
361
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
362
362
  kwargs.get("top_p", 1.0))
363
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
363
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
364
364
  response_dict.get("id"))
365
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
365
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
366
366
  response_dict.get('model'))
367
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
367
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
368
368
  input_tokens)
369
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
369
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
370
370
  output_tokens)
371
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
371
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
372
372
  server_address)
373
373
 
374
374
  # Set base span attribues (Extras)
@@ -376,46 +376,46 @@ def completion(version, environment, application_name,
376
376
  environment)
377
377
  span.set_attribute(SERVICE_NAME,
378
378
  application_name)
379
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
379
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
380
380
  kwargs.get("user", ""))
381
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
381
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
382
382
  False)
383
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
383
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
384
384
  input_tokens + output_tokens)
385
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
385
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
386
386
  cost)
387
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
387
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
388
388
  end_time - start_time)
389
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
389
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
390
390
  version)
391
391
  if capture_message_content:
392
392
  span.add_event(
393
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
393
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
394
394
  attributes={
395
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
395
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
396
396
  },
397
397
  )
398
398
 
399
399
  for i in range(kwargs.get('n',1)):
400
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
400
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
401
401
  [str(response_dict.get('choices')[i].get('finish_reason'))])
402
402
  if capture_message_content:
403
403
  span.add_event(
404
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
404
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
405
405
  attributes={
406
406
  # pylint: disable=line-too-long
407
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
407
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
408
408
  },
409
409
  )
410
410
  if kwargs.get('tools'):
411
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
411
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
412
412
  str(response_dict.get('choices')[i].get('message').get('tool_calls')))
413
413
 
414
414
  if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
415
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
415
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
416
416
  "text")
417
417
  elif response_dict.get('choices')[i].get('message').get('content') is not None:
418
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
418
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
419
419
  "json")
420
420
 
421
421
  span.set_status(Status(StatusCode.OK))
@@ -424,8 +424,8 @@ def completion(version, environment, application_name,
424
424
  attributes = create_metrics_attributes(
425
425
  service_name=application_name,
426
426
  deployment_environment=environment,
427
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
428
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
427
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
428
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
429
429
  request_model=request_model,
430
430
  server_address=server_address,
431
431
  server_port=server_port,
@@ -495,7 +495,7 @@ def image_generate(version, environment, application_name,
495
495
  server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
496
496
  request_model = kwargs.get("model", "dall-e-2")
497
497
 
498
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
498
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
499
499
 
500
500
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
501
501
  start_time = time.time()
@@ -521,21 +521,21 @@ def image_generate(version, environment, application_name,
521
521
  for items in response.data:
522
522
  # Set Span attributes (OTel Semconv)
523
523
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
524
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
525
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
526
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
527
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
528
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
524
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
525
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
526
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
527
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
528
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
529
529
  request_model)
530
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
530
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
531
531
  server_address)
532
- span.set_attribute(SemanticConvetion.SERVER_PORT,
532
+ span.set_attribute(SemanticConvention.SERVER_PORT,
533
533
  server_port)
534
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
534
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
535
535
  response.id)
536
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
536
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
537
537
  response.model)
538
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
538
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
539
539
  "image")
540
540
 
541
541
  # Set Span attributes (Extras)
@@ -543,29 +543,29 @@ def image_generate(version, environment, application_name,
543
543
  environment)
544
544
  span.set_attribute(SERVICE_NAME,
545
545
  application_name)
546
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
546
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
547
547
  image_size)
548
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
548
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
549
549
  version)
550
550
 
551
551
  if capture_message_content:
552
552
  span.add_event(
553
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
553
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
554
554
  attributes={
555
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
555
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
556
556
  },
557
557
  )
558
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
558
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
559
559
  span.add_event(
560
560
  name=attribute_name,
561
561
  attributes={
562
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
562
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
563
563
  },
564
564
  )
565
565
 
566
566
  images_count+=1
567
567
 
568
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
568
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
569
569
  len(response.data) * cost)
570
570
  span.set_status(Status(StatusCode.OK))
571
571
 
@@ -573,8 +573,8 @@ def image_generate(version, environment, application_name,
573
573
  attributes = create_metrics_attributes(
574
574
  service_name=application_name,
575
575
  deployment_environment=environment,
576
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
577
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
576
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
577
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
578
578
  request_model=request_model,
579
579
  server_address=server_address,
580
580
  server_port=server_port,
@@ -13,7 +13,7 @@ from openlit.__helpers import (
13
13
  create_metrics_attributes,
14
14
  set_server_address_and_port
15
15
  )
16
- from openlit.semcov import SemanticConvetion
16
+ from openlit.semcov import SemanticConvention
17
17
 
18
18
  # Initialize logger for logging potential issues and operations
19
19
  logger = logging.getLogger(__name__)
@@ -63,7 +63,7 @@ def text_wrap(version, environment, application_name,
63
63
  server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 80)
64
64
  request_model = instance.model.config.name_or_path
65
65
 
66
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
66
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
67
67
 
68
68
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
69
69
  start_time = time.time()
@@ -82,42 +82,42 @@ def text_wrap(version, environment, application_name,
82
82
  input_tokens = general_tokens(prompt[0])
83
83
 
84
84
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
85
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
86
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
87
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
88
- SemanticConvetion.GEN_AI_SYSTEM_HUGGING_FACE)
89
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
85
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
86
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
87
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
88
+ SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE)
89
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
90
90
  request_model)
91
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
91
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
92
92
  forward_params.get("temperature", "null"))
93
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
93
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
94
94
  forward_params.get("top_p", "null"))
95
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
95
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
96
96
  forward_params.get("max_length", -1))
97
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
97
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
98
98
  input_tokens)
99
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
99
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
100
100
  server_address)
101
- span.set_attribute(SemanticConvetion.SERVER_PORT,
101
+ span.set_attribute(SemanticConvention.SERVER_PORT,
102
102
  server_port)
103
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
103
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
104
104
  request_model)
105
105
 
106
106
  span.set_attribute(DEPLOYMENT_ENVIRONMENT,
107
107
  environment)
108
108
  span.set_attribute(SERVICE_NAME,
109
109
  application_name)
110
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
110
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
111
111
  False)
112
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
112
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
113
113
  end_time - start_time)
114
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
114
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
115
115
  version)
116
116
  if capture_message_content:
117
117
  span.add_event(
118
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
118
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
119
119
  attributes={
120
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
120
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
121
121
  },
122
122
  )
123
123
 
@@ -127,7 +127,7 @@ def text_wrap(version, environment, application_name,
127
127
  if len(response) > 1:
128
128
  attribute_name = f"gen_ai.content.completion.{i}"
129
129
  else:
130
- attribute_name = SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT
130
+ attribute_name = SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT
131
131
  if capture_message_content:
132
132
  # pylint: disable=bare-except
133
133
  try:
@@ -138,22 +138,22 @@ def text_wrap(version, environment, application_name,
138
138
  span.add_event(
139
139
  name=attribute_name,
140
140
  attributes={
141
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
141
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
142
142
  },
143
143
  )
144
144
  output_tokens += general_tokens(llm_response)
145
145
 
146
146
  i=i+1
147
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
147
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
148
148
  output_tokens)
149
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
149
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
150
150
  input_tokens + output_tokens)
151
151
 
152
152
  # Calculate cost of the operation
153
153
  cost = get_chat_model_cost(request_model,
154
154
  pricing_info, input_tokens,
155
155
  output_tokens)
156
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
156
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
157
157
  cost)
158
158
 
159
159
  span.set_status(Status(StatusCode.OK))
@@ -162,8 +162,8 @@ def text_wrap(version, environment, application_name,
162
162
  attributes = create_metrics_attributes(
163
163
  service_name=application_name,
164
164
  deployment_environment=environment,
165
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
166
- system=SemanticConvetion.GEN_AI_SYSTEM_HUGGING_FACE,
165
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
166
+ system=SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
167
167
  request_model=request_model,
168
168
  server_address=server_address,
169
169
  server_port=server_port,