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
@@ -8,7 +8,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
8
8
  from openlit.__helpers import (
9
9
  handle_exception,
10
10
  )
11
- from openlit.semcov import SemanticConvetion
11
+ from openlit.semcov import SemanticConvention
12
12
 
13
13
  # Initialize logger for logging potential issues and operations
14
14
  logger = logging.getLogger(__name__)
@@ -21,16 +21,16 @@ def set_span_attributes(span, version, operation_name, environment,
21
21
 
22
22
  # Set Span attributes (OTel Semconv)
23
23
  span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
24
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, operation_name)
25
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AG2)
26
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS, server_address)
27
- span.set_attribute(SemanticConvetion.SERVER_PORT, server_port)
28
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
24
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, operation_name)
25
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AG2)
26
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
27
+ span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
28
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
29
29
 
30
30
  # Set Span attributes (Extras)
31
31
  span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
32
32
  span.set_attribute(SERVICE_NAME, application_name)
33
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
33
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
34
34
 
35
35
  def create_agent(version, environment, application_name,
36
36
  tracer, event_provider, pricing_info, capture_message_content, metrics, disable_metrics):
@@ -41,17 +41,17 @@ def create_agent(version, environment, application_name,
41
41
  server_address, server_port = '127.0.0.1', 80
42
42
 
43
43
  agent_name = kwargs.get('name', 'openai_agent')
44
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {agent_name}'
44
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {agent_name}'
45
45
 
46
46
  with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
47
47
  try:
48
48
  response = wrapped(*args, **kwargs)
49
49
 
50
- set_span_attributes(span, version, SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
50
+ set_span_attributes(span, version, SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
51
51
  environment, application_name, server_address, server_port, kwargs.get('model', 'gpt-4o'))
52
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_NAME, agent_name)
52
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, agent_name)
53
53
 
54
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_DESCRIPTION, kwargs.get('instructions', ''))
54
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, kwargs.get('instructions', ''))
55
55
 
56
56
  span.set_status(Status(StatusCode.OK))
57
57
 
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
9
9
  from openlit.__helpers import (
10
10
  handle_exception,
11
11
  )
12
- from openlit.semcov import SemanticConvetion
12
+ from openlit.semcov import SemanticConvention
13
13
 
14
14
  # Initialize logger for logging potential issues and operations
15
15
  logger = logging.getLogger(__name__)
@@ -56,33 +56,33 @@ def phidata_wrap(gen_ai_endpoint, version, environment, application_name,
56
56
  try:
57
57
  # Set base span attribues
58
58
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
59
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
60
- SemanticConvetion.GEN_AI_SYSTEM_PHIDATA)
61
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
62
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
63
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
59
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
60
+ SemanticConvention.GEN_AI_SYSTEM_PHIDATA)
61
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
62
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
63
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
64
64
  gen_ai_endpoint)
65
65
  span.set_attribute(SERVICE_NAME,
66
66
  application_name)
67
67
  span.set_attribute(DEPLOYMENT_ENVIRONMENT,
68
68
  environment)
69
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
69
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
70
70
  getattr(instance, 'agent_id', '') or '')
71
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
71
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
72
72
  getattr(instance, 'name', '') or '')
73
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
73
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
74
74
  getattr(getattr(instance, 'model', None), 'id', '') or '')
75
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
75
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
76
76
  str(getattr(instance, 'tools', '')) or '')
77
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
77
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
78
78
  str(getattr(instance, 'knowledge', '')) or '')
79
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK,
79
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK,
80
80
  str(getattr(instance, 'task', '')) or '')
81
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_INSTRUCTIONS,
81
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
82
82
  str(getattr(instance, 'instructions', '')) or '')
83
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STORAGE,
83
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STORAGE,
84
84
  str(getattr(instance, 'storage', '')) or '')
85
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ENABLE_HISTORY,
85
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_HISTORY,
86
86
  str(getattr(instance, 'add_history_to_messages', '')) or '')
87
87
 
88
88
  span.set_status(Status(StatusCode.OK))
@@ -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__)
@@ -70,74 +70,74 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
70
70
 
71
71
  try:
72
72
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
73
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
73
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
74
74
  gen_ai_endpoint)
75
75
  span.set_attribute(DEPLOYMENT_ENVIRONMENT,
76
76
  environment)
77
77
  span.set_attribute(SERVICE_NAME,
78
78
  application_name)
79
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
80
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
81
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
82
- SemanticConvetion.DB_SYSTEM_PINECONE)
79
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
80
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
81
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
82
+ SemanticConvention.DB_SYSTEM_PINECONE)
83
83
 
84
84
  if gen_ai_endpoint == "pinecone.create_index":
85
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_INDEX
86
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
87
- SemanticConvetion.DB_OPERATION_CREATE_INDEX)
88
- span.set_attribute(SemanticConvetion.DB_INDEX_NAME,
85
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX
86
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
87
+ SemanticConvention.DB_OPERATION_CREATE_INDEX)
88
+ span.set_attribute(SemanticConvention.DB_INDEX_NAME,
89
89
  kwargs.get("name", ""))
90
- span.set_attribute(SemanticConvetion.DB_INDEX_DIMENSION,
90
+ span.set_attribute(SemanticConvention.DB_INDEX_DIMENSION,
91
91
  kwargs.get("dimensions", ""))
92
- span.set_attribute(SemanticConvetion.DB_INDEX_METRIC,
92
+ span.set_attribute(SemanticConvention.DB_INDEX_METRIC,
93
93
  kwargs.get("metric", ""))
94
- span.set_attribute(SemanticConvetion.DB_INDEX_SPEC,
94
+ span.set_attribute(SemanticConvention.DB_INDEX_SPEC,
95
95
  str(kwargs.get("spec", "")))
96
96
 
97
97
  elif gen_ai_endpoint == "pinecone.query":
98
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
99
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
100
- SemanticConvetion.DB_OPERATION_QUERY)
101
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
98
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
99
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
100
+ SemanticConvention.DB_OPERATION_QUERY)
101
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
102
102
  str(kwargs.get("vector")))
103
- span.set_attribute(SemanticConvetion.DB_N_RESULTS,
103
+ span.set_attribute(SemanticConvention.DB_N_RESULTS,
104
104
  kwargs.get("top_k", ""))
105
- span.set_attribute(SemanticConvetion.DB_FILTER,
105
+ span.set_attribute(SemanticConvention.DB_FILTER,
106
106
  str(kwargs.get("filter", "")))
107
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
107
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
108
108
  str(kwargs.get("namespace", "")))
109
109
 
110
110
  elif gen_ai_endpoint == "pinecone.update":
111
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
112
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
113
- SemanticConvetion.DB_OPERATION_UPDATE)
114
- span.set_attribute(SemanticConvetion.DB_UPDATE_ID,
111
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
112
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
113
+ SemanticConvention.DB_OPERATION_UPDATE)
114
+ span.set_attribute(SemanticConvention.DB_UPDATE_ID,
115
115
  kwargs.get("id",""))
116
- span.set_attribute(SemanticConvetion.DB_UPDATE_VALUES,
116
+ span.set_attribute(SemanticConvention.DB_UPDATE_VALUES,
117
117
  str(kwargs.get("values",[])))
118
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
118
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
119
119
  str(kwargs.get("namespace", "")))
120
- span.set_attribute(SemanticConvetion.DB_UPDATE_METADATA,
120
+ span.set_attribute(SemanticConvention.DB_UPDATE_METADATA,
121
121
  str(kwargs.get("set_metadata", "")))
122
122
 
123
123
  elif gen_ai_endpoint == "pinecone.upsert":
124
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
125
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
126
- SemanticConvetion.DB_OPERATION_UPSERT)
127
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
124
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
125
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
126
+ SemanticConvention.DB_OPERATION_UPSERT)
127
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
128
128
  object_count(kwargs.get("vectors")))
129
129
 
130
130
  elif gen_ai_endpoint == "pinecone.delete":
131
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
132
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
133
- SemanticConvetion.DB_OPERATION_DELETE)
134
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
131
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
132
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
133
+ SemanticConvention.DB_OPERATION_DELETE)
134
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
135
135
  object_count(kwargs.get("ids")))
136
- span.set_attribute(SemanticConvetion.DB_FILTER,
136
+ span.set_attribute(SemanticConvention.DB_FILTER,
137
137
  str(kwargs.get("filter", "")))
138
- span.set_attribute(SemanticConvetion.DB_DELETE_ALL,
138
+ span.set_attribute(SemanticConvention.DB_DELETE_ALL,
139
139
  kwargs.get("delete_all", False))
140
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
140
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
141
141
  kwargs.get("namespace", ""))
142
142
 
143
143
  span.set_status(Status(StatusCode.OK))
@@ -148,13 +148,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
148
148
  "openlit",
149
149
  SERVICE_NAME:
150
150
  application_name,
151
- SemanticConvetion.DB_SYSTEM_NAME:
152
- SemanticConvetion.DB_SYSTEM_PINECONE,
151
+ SemanticConvention.DB_SYSTEM_NAME:
152
+ SemanticConvention.DB_SYSTEM_PINECONE,
153
153
  DEPLOYMENT_ENVIRONMENT:
154
154
  environment,
155
- SemanticConvetion.GEN_AI_OPERATION:
156
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
157
- SemanticConvetion.DB_OPERATION_NAME:
155
+ SemanticConvention.GEN_AI_OPERATION:
156
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
157
+ SemanticConvention.DB_OPERATION_NAME:
158
158
  db_operation
159
159
  }
160
160
 
@@ -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__)
@@ -139,45 +139,45 @@ def chat(version, environment, application_name,
139
139
 
140
140
  # Set Span attributes (OTel Semconv)
141
141
  self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
142
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
143
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
144
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
145
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
146
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
142
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
143
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
144
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
145
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
146
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
147
147
  request_model)
148
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
148
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
149
149
  self._kwargs.get("seed", ""))
150
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
150
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
151
151
  self._server_port)
152
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
152
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
153
153
  self._kwargs.get("frequency_penalty", 0.0))
154
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
154
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
155
155
  self._kwargs.get("max_tokens", -1))
156
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
156
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
157
157
  self._kwargs.get("presence_penalty", 0.0))
158
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
158
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
159
159
  self._kwargs.get("stop", []))
160
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
160
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
161
161
  self._kwargs.get("temperature", 1.0))
162
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
162
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
163
163
  self._kwargs.get("top_p", 1.0))
164
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
164
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
165
165
  [self._finish_reason])
166
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
166
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
167
167
  self._response_id)
168
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
168
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
169
169
  self._response_model)
170
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
170
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
171
171
  input_tokens)
172
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
172
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
173
173
  output_tokens)
174
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
174
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
175
175
  self._server_address)
176
176
  if isinstance(self._llmresponse, str):
177
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
177
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
178
178
  "text")
179
179
  else:
180
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
180
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
181
181
  "json")
182
182
 
183
183
  # Set Span attributes (Extra)
@@ -185,31 +185,31 @@ def chat(version, environment, application_name,
185
185
  environment)
186
186
  self._span.set_attribute(SERVICE_NAME,
187
187
  application_name)
188
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
188
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
189
189
  self._kwargs.get("user", ""))
190
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
190
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
191
191
  True)
192
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
192
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
193
193
  input_tokens + output_tokens)
194
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
194
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
195
195
  cost)
196
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
196
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
197
197
  self._tbt)
198
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
198
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
199
199
  self._ttft)
200
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
200
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
201
201
  version)
202
202
  if capture_message_content:
203
203
  self._span.add_event(
204
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
204
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
205
205
  attributes={
206
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
206
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
207
207
  },
208
208
  )
209
209
  self._span.add_event(
210
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
210
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
211
211
  attributes={
212
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
212
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
213
213
  },
214
214
  )
215
215
  self._span.set_status(Status(StatusCode.OK))
@@ -218,8 +218,8 @@ def chat(version, environment, application_name,
218
218
  attributes = create_metrics_attributes(
219
219
  service_name=application_name,
220
220
  deployment_environment=environment,
221
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
222
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
221
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
222
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
223
223
  request_model=request_model,
224
224
  server_address=self._server_address,
225
225
  server_port=self._server_port,
@@ -271,7 +271,7 @@ def chat(version, environment, application_name,
271
271
  server_address, server_port = set_server_address_and_port(instance, "app.premai.io", 443)
272
272
  request_model = kwargs.get("model", "gpt-4o-mini")
273
273
 
274
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
274
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
275
275
 
276
276
  # pylint: disable=no-else-return
277
277
  if streaming:
@@ -317,35 +317,35 @@ def chat(version, environment, application_name,
317
317
 
318
318
  # Set base span attribues (OTel Semconv)
319
319
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
320
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
321
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
322
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
323
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
324
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
320
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
321
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
322
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
323
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
324
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
325
325
  request_model)
326
- span.set_attribute(SemanticConvetion.SERVER_PORT,
326
+ span.set_attribute(SemanticConvention.SERVER_PORT,
327
327
  server_port)
328
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
328
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
329
329
  kwargs.get("frequency_penalty", 0.0))
330
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
330
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
331
331
  kwargs.get("max_tokens", -1))
332
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
332
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
333
333
  kwargs.get("presence_penalty", 0.0))
334
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
334
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
335
335
  kwargs.get("stop", []))
336
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
336
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
337
337
  kwargs.get("temperature", 1.0))
338
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
338
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
339
339
  kwargs.get("top_p", 1.0))
340
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
340
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
341
341
  response.additional_properties.get('id'))
342
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
342
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
343
343
  response.model)
344
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
344
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
345
345
  input_tokens)
346
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
346
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
347
347
  output_tokens)
348
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
348
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
349
349
  server_address)
350
350
 
351
351
  # Set base span attribues (Extras)
@@ -353,39 +353,39 @@ def chat(version, environment, application_name,
353
353
  environment)
354
354
  span.set_attribute(SERVICE_NAME,
355
355
  application_name)
356
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
356
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
357
357
  False)
358
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
358
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
359
359
  input_tokens + output_tokens)
360
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
360
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
361
361
  cost)
362
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
362
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
363
363
  end_time - start_time)
364
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
364
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
365
365
  version)
366
366
  if capture_message_content:
367
367
  span.add_event(
368
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
368
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
369
369
  attributes={
370
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
370
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
371
371
  },
372
372
  )
373
373
  span.add_event(
374
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
374
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
375
375
  attributes={
376
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response.choices[0].message.content),
376
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response.choices[0].message.content),
377
377
  },
378
378
  )
379
379
 
380
380
  if kwargs.get('tools'):
381
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
381
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
382
382
  str(response.choices[0].message.tool_calls))
383
383
 
384
384
  if kwargs.get('response_format', '') != '':
385
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
385
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
386
386
  "json")
387
387
  else:
388
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
388
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
389
389
  "text")
390
390
 
391
391
  span.set_status(Status(StatusCode.OK))
@@ -394,8 +394,8 @@ def chat(version, environment, application_name,
394
394
  attributes = create_metrics_attributes(
395
395
  service_name=application_name,
396
396
  deployment_environment=environment,
397
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
398
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
397
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
398
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
399
399
  request_model=request_model,
400
400
  server_address=server_address,
401
401
  server_port=server_port,
@@ -465,7 +465,7 @@ def embedding(version, environment, application_name,
465
465
  server_address, server_port = set_server_address_and_port(instance, "app.premai.io", 443)
466
466
  request_model = kwargs.get("model", "text-embedding-ada-002")
467
467
 
468
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
468
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
469
469
 
470
470
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
471
471
  start_time = time.time()
@@ -481,21 +481,21 @@ def embedding(version, environment, application_name,
481
481
 
482
482
  # Set Span attributes (OTel Semconv)
483
483
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
484
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
485
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
486
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
487
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
488
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
484
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
485
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
486
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
487
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
488
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
489
489
  request_model)
490
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
490
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
491
491
  [kwargs.get('encoding_format', 'float')])
492
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
492
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
493
493
  response.model)
494
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
494
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
495
495
  server_address)
496
- span.set_attribute(SemanticConvetion.SERVER_PORT,
496
+ span.set_attribute(SemanticConvention.SERVER_PORT,
497
497
  server_port)
498
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
498
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
499
499
  input_tokens)
500
500
 
501
501
  # Set Span attributes (Extras)
@@ -503,20 +503,20 @@ def embedding(version, environment, application_name,
503
503
  environment)
504
504
  span.set_attribute(SERVICE_NAME,
505
505
  application_name)
506
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
506
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
507
507
  kwargs.get("user", ""))
508
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
508
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
509
509
  input_tokens)
510
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
510
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
511
511
  cost)
512
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
512
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
513
513
  version)
514
514
 
515
515
  if capture_message_content:
516
516
  span.add_event(
517
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
517
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
518
518
  attributes={
519
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
519
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
520
520
  },
521
521
  )
522
522
 
@@ -526,8 +526,8 @@ def embedding(version, environment, application_name,
526
526
  attributes = create_metrics_attributes(
527
527
  service_name=application_name,
528
528
  deployment_environment=environment,
529
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
530
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
529
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
530
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
531
531
  request_model=request_model,
532
532
  server_address=server_address,
533
533
  server_port=server_port,