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
@@ -19,7 +19,7 @@ from openlit.__helpers import (
19
19
  otel_event,
20
20
  concatenate_all_contents
21
21
  )
22
- from openlit.semcov import SemanticConvetion
22
+ from openlit.semcov import SemanticConvention
23
23
 
24
24
  def process_chunk(self, chunk):
25
25
  """
@@ -64,20 +64,20 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
64
64
 
65
65
  # Set Span attributes (OTel Semconv)
66
66
  scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
67
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
68
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_OLLAMA)
69
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
70
- scope._span.set_attribute(SemanticConvetion.SERVER_PORT, scope._server_port)
67
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
68
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
69
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
70
+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
71
71
 
72
72
  options = scope._kwargs.get('options', {})
73
73
  attributes = [
74
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'repeat_penalty'),
75
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
76
- (SemanticConvetion.GEN_AI_REQUEST_SEED, 'seed'),
77
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop'),
78
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
79
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
80
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
74
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'repeat_penalty'),
75
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
76
+ (SemanticConvention.GEN_AI_REQUEST_SEED, 'seed'),
77
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop'),
78
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
79
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
80
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
81
81
  ]
82
82
 
83
83
  for attribute, key in attributes:
@@ -85,37 +85,37 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
85
85
  if value is not None:
86
86
  scope._span.set_attribute(attribute, value)
87
87
 
88
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
89
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, scope._response_model)
90
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
91
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
92
- scope._span.set_attribute(SemanticConvetion.SERVER_ADDRESS, scope._server_address)
88
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
89
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
90
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
91
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
92
+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
93
93
 
94
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
94
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
95
95
  "text" if isinstance(scope._llmresponse, str) else "json")
96
96
 
97
97
  scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
98
98
  scope._span.set_attribute(SERVICE_NAME, application_name)
99
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM, is_stream)
100
- scope._span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
101
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
102
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT, scope._tbt)
103
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, scope._ttft)
104
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
99
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
100
+ scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
101
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
102
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
103
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
104
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
105
105
 
106
106
  # To be removed one the change to log events (from span events) is complete
107
107
  prompt = concatenate_all_contents(formatted_messages)
108
108
  if capture_message_content:
109
109
  scope._span.add_event(
110
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
110
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
111
111
  attributes={
112
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
112
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
113
113
  },
114
114
  )
115
115
  scope._span.add_event(
116
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
116
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
117
117
  attributes={
118
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
118
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
119
119
  },
120
120
  )
121
121
 
@@ -145,9 +145,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
145
145
  for role in ['user', 'system', 'assistant', 'tool']:
146
146
  if formatted_messages.get(role, {}).get('content', ''):
147
147
  event = otel_event(
148
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
148
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
149
149
  attributes={
150
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
150
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
151
151
  },
152
152
  body = {
153
153
  # pylint: disable=line-too-long
@@ -172,9 +172,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
172
172
  event_provider.emit(event)
173
173
 
174
174
  choice_event = otel_event(
175
- name=SemanticConvetion.GEN_AI_CHOICE,
175
+ name=SemanticConvention.GEN_AI_CHOICE,
176
176
  attributes={
177
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
177
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
178
178
  },
179
179
  body=choice_event_body
180
180
  )
@@ -186,8 +186,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
186
186
  metrics_attributes = create_metrics_attributes(
187
187
  service_name=application_name,
188
188
  deployment_environment=environment,
189
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
190
- system=SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
189
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
190
+ system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
191
191
  request_model=request_model,
192
192
  server_address=scope._server_address,
193
193
  server_port=scope._server_port,
@@ -260,19 +260,19 @@ def process_embedding_response(response, request_model, pricing_info, server_por
260
260
 
261
261
  # Set Span attributes (OTel Semconv)
262
262
  span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
263
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
264
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
265
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
266
- SemanticConvetion.GEN_AI_SYSTEM_OLLAMA)
267
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
263
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
264
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
265
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
266
+ SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
267
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
268
268
  request_model)
269
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
269
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
270
270
  request_model)
271
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
271
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
272
272
  server_address)
273
- span.set_attribute(SemanticConvetion.SERVER_PORT,
273
+ span.set_attribute(SemanticConvention.SERVER_PORT,
274
274
  server_port)
275
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
275
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
276
276
  input_tokens)
277
277
 
278
278
  # Set Span attributes (Extras)
@@ -280,17 +280,17 @@ def process_embedding_response(response, request_model, pricing_info, server_por
280
280
  environment)
281
281
  span.set_attribute(SERVICE_NAME,
282
282
  application_name)
283
- span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE,
283
+ span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
284
284
  input_tokens)
285
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
285
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
286
286
  cost)
287
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
287
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
288
288
  version)
289
289
 
290
290
  prompt_event = otel_event(
291
- name=SemanticConvetion.GEN_AI_USER_MESSAGE,
291
+ name=SemanticConvention.GEN_AI_USER_MESSAGE,
292
292
  attributes={
293
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
293
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
294
294
  },
295
295
  body={
296
296
  **({"content": kwargs.get('prompt', '')} if capture_message_content else {}),
@@ -305,8 +305,8 @@ def process_embedding_response(response, request_model, pricing_info, server_por
305
305
  attributes = create_metrics_attributes(
306
306
  service_name=application_name,
307
307
  deployment_environment=environment,
308
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
309
- system=SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
308
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
309
+ system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
310
310
  request_model=request_model,
311
311
  server_address=server_address,
312
312
  server_port=server_port,