openlit 1.33.19__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 (79) hide show
  1. openlit/__helpers.py +7 -7
  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 +2 -2
  17. openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +2 -2
  18. openlit/instrumentation/azure_ai_inference/utils.py +36 -36
  19. openlit/instrumentation/bedrock/bedrock.py +2 -2
  20. openlit/instrumentation/bedrock/utils.py +35 -35
  21. openlit/instrumentation/chroma/chroma.py +57 -57
  22. openlit/instrumentation/cohere/async_cohere.py +88 -88
  23. openlit/instrumentation/cohere/cohere.py +88 -88
  24. openlit/instrumentation/controlflow/controlflow.py +15 -15
  25. openlit/instrumentation/crawl4ai/async_crawl4ai.py +14 -14
  26. openlit/instrumentation/crawl4ai/crawl4ai.py +14 -14
  27. openlit/instrumentation/crewai/crewai.py +22 -22
  28. openlit/instrumentation/dynamiq/dynamiq.py +19 -19
  29. openlit/instrumentation/elevenlabs/async_elevenlabs.py +24 -25
  30. openlit/instrumentation/elevenlabs/elevenlabs.py +23 -25
  31. openlit/instrumentation/embedchain/embedchain.py +15 -15
  32. openlit/instrumentation/firecrawl/firecrawl.py +10 -10
  33. openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +33 -33
  34. openlit/instrumentation/google_ai_studio/google_ai_studio.py +33 -33
  35. openlit/instrumentation/gpt4all/gpt4all.py +78 -78
  36. openlit/instrumentation/gpu/__init__.py +8 -8
  37. openlit/instrumentation/groq/async_groq.py +74 -74
  38. openlit/instrumentation/groq/groq.py +74 -74
  39. openlit/instrumentation/haystack/haystack.py +6 -6
  40. openlit/instrumentation/julep/async_julep.py +14 -14
  41. openlit/instrumentation/julep/julep.py +14 -14
  42. openlit/instrumentation/langchain/async_langchain.py +39 -39
  43. openlit/instrumentation/langchain/langchain.py +39 -39
  44. openlit/instrumentation/letta/letta.py +26 -26
  45. openlit/instrumentation/litellm/async_litellm.py +94 -94
  46. openlit/instrumentation/litellm/litellm.py +94 -94
  47. openlit/instrumentation/llamaindex/llamaindex.py +7 -7
  48. openlit/instrumentation/mem0/mem0.py +13 -13
  49. openlit/instrumentation/milvus/milvus.py +47 -47
  50. openlit/instrumentation/mistral/async_mistral.py +88 -88
  51. openlit/instrumentation/mistral/mistral.py +88 -88
  52. openlit/instrumentation/multion/async_multion.py +21 -21
  53. openlit/instrumentation/multion/multion.py +21 -21
  54. openlit/instrumentation/ollama/async_ollama.py +3 -3
  55. openlit/instrumentation/ollama/ollama.py +3 -3
  56. openlit/instrumentation/ollama/utils.py +50 -50
  57. openlit/instrumentation/openai/async_openai.py +225 -225
  58. openlit/instrumentation/openai/openai.py +225 -225
  59. openlit/instrumentation/openai_agents/openai_agents.py +11 -11
  60. openlit/instrumentation/phidata/phidata.py +15 -15
  61. openlit/instrumentation/pinecone/pinecone.py +43 -43
  62. openlit/instrumentation/premai/premai.py +86 -86
  63. openlit/instrumentation/qdrant/async_qdrant.py +95 -95
  64. openlit/instrumentation/qdrant/qdrant.py +99 -99
  65. openlit/instrumentation/reka/async_reka.py +33 -33
  66. openlit/instrumentation/reka/reka.py +33 -33
  67. openlit/instrumentation/together/async_together.py +90 -90
  68. openlit/instrumentation/together/together.py +90 -90
  69. openlit/instrumentation/transformers/transformers.py +26 -26
  70. openlit/instrumentation/vertexai/async_vertexai.py +64 -64
  71. openlit/instrumentation/vertexai/vertexai.py +64 -64
  72. openlit/instrumentation/vllm/vllm.py +24 -24
  73. openlit/otel/metrics.py +11 -11
  74. openlit/semcov/__init__.py +3 -3
  75. {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/METADATA +8 -8
  76. openlit-1.33.20.dist-info/RECORD +131 -0
  77. {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/WHEEL +1 -1
  78. openlit-1.33.19.dist-info/RECORD +0 -131
  79. {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/LICENSE +0 -0
@@ -15,7 +15,7 @@ from openlit.__helpers import (
15
15
  create_metrics_attributes,
16
16
  set_server_address_and_port
17
17
  )
18
- from openlit.semcov import SemanticConvetion
18
+ from openlit.semcov import SemanticConvention
19
19
 
20
20
  # Initialize logger for logging potential issues and operations
21
21
  logger = logging.getLogger(__name__)
@@ -157,49 +157,49 @@ def async_chat(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_GROQ)
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_GROQ)
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_completion_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
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
194
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
195
195
  self._kwargs.get("service_tier", "on_demand"))
196
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
196
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
197
197
  self._system_fingerprint)
198
198
  if isinstance(self._llmresponse, str):
199
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
199
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
200
200
  "text")
201
201
  else:
202
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
202
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
203
203
  "json")
204
204
 
205
205
  # Set Span attributes (Extra)
@@ -207,31 +207,31 @@ def async_chat(version, environment, application_name,
207
207
  environment)
208
208
  self._span.set_attribute(SERVICE_NAME,
209
209
  application_name)
210
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
210
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
211
211
  self._kwargs.get("user", ""))
212
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
212
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
213
213
  True)
214
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
214
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
215
215
  self._input_tokens + self._output_tokens)
216
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
216
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
217
217
  cost)
218
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
218
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
219
219
  self._tbt)
220
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
220
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
221
221
  self._ttft)
222
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
222
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
223
223
  version)
224
224
  if capture_message_content:
225
225
  self._span.add_event(
226
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
226
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
227
227
  attributes={
228
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
228
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
229
229
  },
230
230
  )
231
231
  self._span.add_event(
232
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
232
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
233
233
  attributes={
234
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
234
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
235
235
  },
236
236
  )
237
237
  self._span.set_status(Status(StatusCode.OK))
@@ -240,8 +240,8 @@ def async_chat(version, environment, application_name,
240
240
  attributes = create_metrics_attributes(
241
241
  service_name=application_name,
242
242
  deployment_environment=environment,
243
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
244
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
243
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
244
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
245
245
  request_model=request_model,
246
246
  server_address=self._server_address,
247
247
  server_port=self._server_port,
@@ -294,7 +294,7 @@ def async_chat(version, environment, application_name,
294
294
  server_address, server_port = set_server_address_and_port(instance, "api.groq.com", 443)
295
295
  request_model = kwargs.get("model", "gpt-4o")
296
296
 
297
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
297
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
298
298
 
299
299
  # pylint: disable=no-else-return
300
300
  if streaming:
@@ -342,41 +342,41 @@ def async_chat(version, environment, application_name,
342
342
 
343
343
  # Set base span attribues (OTel Semconv)
344
344
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
345
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
346
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
347
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
348
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
349
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
345
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
346
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
347
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
348
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
349
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
350
350
  request_model)
351
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
351
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
352
352
  kwargs.get("seed", ""))
353
- span.set_attribute(SemanticConvetion.SERVER_PORT,
353
+ span.set_attribute(SemanticConvention.SERVER_PORT,
354
354
  server_port)
355
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
355
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
356
356
  kwargs.get("frequency_penalty", 0.0))
357
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
357
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
358
358
  kwargs.get("max_completion_tokens", -1))
359
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
359
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
360
360
  kwargs.get("presence_penalty", 0.0))
361
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
361
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
362
362
  kwargs.get("stop", []))
363
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
363
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
364
364
  kwargs.get("temperature", 1.0))
365
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
365
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
366
366
  kwargs.get("top_p", 1.0))
367
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
367
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
368
368
  response_dict.get("id"))
369
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
369
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
370
370
  response_dict.get('model'))
371
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
371
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
372
372
  input_tokens)
373
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
373
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
374
374
  output_tokens)
375
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
375
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
376
376
  server_address)
377
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
377
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
378
378
  kwargs.get("service_tier", "on_demand"))
379
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
379
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
380
380
  response_dict.get('system_fingerprint'))
381
381
 
382
382
  # Set base span attribues (Extras)
@@ -384,46 +384,46 @@ def async_chat(version, environment, application_name,
384
384
  environment)
385
385
  span.set_attribute(SERVICE_NAME,
386
386
  application_name)
387
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
387
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
388
388
  kwargs.get("user", ""))
389
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
389
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
390
390
  False)
391
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
391
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
392
392
  input_tokens + output_tokens)
393
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
393
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
394
394
  cost)
395
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
395
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
396
396
  end_time - start_time)
397
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
397
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
398
398
  version)
399
399
  if capture_message_content:
400
400
  span.add_event(
401
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
401
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
402
402
  attributes={
403
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
403
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
404
404
  },
405
405
  )
406
406
 
407
407
  for i in range(kwargs.get('n',1)):
408
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
408
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
409
409
  [response_dict.get('choices')[i].get('finish_reason')])
410
410
  if capture_message_content:
411
411
  span.add_event(
412
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
412
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
413
413
  attributes={
414
414
  # pylint: disable=line-too-long
415
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
415
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
416
416
  },
417
417
  )
418
418
  if kwargs.get('tools'):
419
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
419
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
420
420
  str(response_dict.get('choices')[i].get('message').get('tool_calls')))
421
421
 
422
422
  if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
423
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
423
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
424
424
  "text")
425
425
  elif response_dict.get('choices')[i].get('message').get('content') is not None:
426
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
426
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
427
427
  "json")
428
428
 
429
429
  span.set_status(Status(StatusCode.OK))
@@ -432,8 +432,8 @@ def async_chat(version, environment, application_name,
432
432
  attributes = create_metrics_attributes(
433
433
  service_name=application_name,
434
434
  deployment_environment=environment,
435
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
436
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
435
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
436
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
437
437
  request_model=request_model,
438
438
  server_address=server_address,
439
439
  server_port=server_port,
@@ -15,7 +15,7 @@ from openlit.__helpers import (
15
15
  create_metrics_attributes,
16
16
  set_server_address_and_port
17
17
  )
18
- from openlit.semcov import SemanticConvetion
18
+ from openlit.semcov import SemanticConvention
19
19
 
20
20
  # Initialize logger for logging potential issues and operations
21
21
  logger = logging.getLogger(__name__)
@@ -157,49 +157,49 @@ def chat(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_GROQ)
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_GROQ)
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_completion_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
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
194
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
195
195
  self._kwargs.get("service_tier", "on_demand"))
196
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
196
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
197
197
  self._system_fingerprint)
198
198
  if isinstance(self._llmresponse, str):
199
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
199
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
200
200
  "text")
201
201
  else:
202
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
202
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
203
203
  "json")
204
204
 
205
205
  # Set Span attributes (Extra)
@@ -207,31 +207,31 @@ def chat(version, environment, application_name,
207
207
  environment)
208
208
  self._span.set_attribute(SERVICE_NAME,
209
209
  application_name)
210
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
210
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
211
211
  self._kwargs.get("user", ""))
212
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
212
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
213
213
  True)
214
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
214
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
215
215
  self._input_tokens + self._output_tokens)
216
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
216
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
217
217
  cost)
218
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
218
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
219
219
  self._tbt)
220
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
220
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
221
221
  self._ttft)
222
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
222
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
223
223
  version)
224
224
  if capture_message_content:
225
225
  self._span.add_event(
226
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
226
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
227
227
  attributes={
228
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
228
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
229
229
  },
230
230
  )
231
231
  self._span.add_event(
232
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
232
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
233
233
  attributes={
234
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
234
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
235
235
  },
236
236
  )
237
237
  self._span.set_status(Status(StatusCode.OK))
@@ -240,8 +240,8 @@ def chat(version, environment, application_name,
240
240
  attributes = create_metrics_attributes(
241
241
  service_name=application_name,
242
242
  deployment_environment=environment,
243
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
244
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
243
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
244
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
245
245
  request_model=request_model,
246
246
  server_address=self._server_address,
247
247
  server_port=self._server_port,
@@ -294,7 +294,7 @@ def chat(version, environment, application_name,
294
294
  server_address, server_port = set_server_address_and_port(instance, "api.groq.com", 443)
295
295
  request_model = kwargs.get("model", "gpt-4o")
296
296
 
297
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
297
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
298
298
 
299
299
  # pylint: disable=no-else-return
300
300
  if streaming:
@@ -342,41 +342,41 @@ def chat(version, environment, application_name,
342
342
 
343
343
  # Set base span attribues (OTel Semconv)
344
344
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
345
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
346
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
347
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
348
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
349
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
345
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
346
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
347
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
348
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
349
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
350
350
  request_model)
351
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
351
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
352
352
  kwargs.get("seed", ""))
353
- span.set_attribute(SemanticConvetion.SERVER_PORT,
353
+ span.set_attribute(SemanticConvention.SERVER_PORT,
354
354
  server_port)
355
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
355
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
356
356
  kwargs.get("frequency_penalty", 0.0))
357
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
357
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
358
358
  kwargs.get("max_completion_tokens", -1))
359
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
359
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
360
360
  kwargs.get("presence_penalty", 0.0))
361
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
361
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
362
362
  kwargs.get("stop", []))
363
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
363
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
364
364
  kwargs.get("temperature", 1.0))
365
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
365
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
366
366
  kwargs.get("top_p", 1.0))
367
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
367
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
368
368
  response_dict.get("id"))
369
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
369
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
370
370
  response_dict.get('model'))
371
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
371
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
372
372
  input_tokens)
373
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
373
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
374
374
  output_tokens)
375
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
375
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
376
376
  server_address)
377
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
377
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
378
378
  kwargs.get("service_tier", "on_demand"))
379
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
379
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
380
380
  response_dict.get('system_fingerprint'))
381
381
 
382
382
  # Set base span attribues (Extras)
@@ -384,46 +384,46 @@ def chat(version, environment, application_name,
384
384
  environment)
385
385
  span.set_attribute(SERVICE_NAME,
386
386
  application_name)
387
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
387
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
388
388
  kwargs.get("user", ""))
389
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
389
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
390
390
  False)
391
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
391
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
392
392
  input_tokens + output_tokens)
393
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
393
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
394
394
  cost)
395
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
395
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
396
396
  end_time - start_time)
397
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
397
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
398
398
  version)
399
399
  if capture_message_content:
400
400
  span.add_event(
401
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
401
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
402
402
  attributes={
403
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
403
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
404
404
  },
405
405
  )
406
406
 
407
407
  for i in range(kwargs.get('n',1)):
408
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
408
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
409
409
  [response_dict.get('choices')[i].get('finish_reason')])
410
410
  if capture_message_content:
411
411
  span.add_event(
412
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
412
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
413
413
  attributes={
414
414
  # pylint: disable=line-too-long
415
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
415
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
416
416
  },
417
417
  )
418
418
  if kwargs.get('tools'):
419
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
419
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
420
420
  str(response_dict.get('choices')[i].get('message').get('tool_calls')))
421
421
 
422
422
  if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
423
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
423
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
424
424
  "text")
425
425
  elif response_dict.get('choices')[i].get('message').get('content') is not None:
426
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
426
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
427
427
  "json")
428
428
 
429
429
  span.set_status(Status(StatusCode.OK))
@@ -432,8 +432,8 @@ def chat(version, environment, application_name,
432
432
  attributes = create_metrics_attributes(
433
433
  service_name=application_name,
434
434
  deployment_environment=environment,
435
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
436
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
435
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
436
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
437
437
  request_model=request_model,
438
438
  server_address=server_address,
439
439
  server_port=server_port,
@@ -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 SemanticConvetion
10
+ from openlit.semcov import SemanticConvention
11
11
 
12
12
  # Initialize logger for logging potential issues and operations
13
13
  logger = logging.getLogger(__name__)
@@ -59,14 +59,14 @@ def join_data(gen_ai_endpoint, version, environment, application_name,
59
59
 
60
60
  try:
61
61
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
62
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
63
- SemanticConvetion.GEN_AI_SYSTEM_HAYSTACK)
64
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
62
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
63
+ SemanticConvention.GEN_AI_SYSTEM_HAYSTACK)
64
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
65
65
  gen_ai_endpoint)
66
66
  span.set_attribute(DEPLOYMENT_ENVIRONMENT,
67
67
  environment)
68
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
69
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
68
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
69
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
70
70
  span.set_attribute(SERVICE_NAME,
71
71
  application_name)
72
72
  span.set_status(Status(StatusCode.OK))