openlit 1.33.8__py3-none-any.whl → 1.33.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openlit/__helpers.py +83 -0
- openlit/__init__.py +1 -1
- openlit/instrumentation/ag2/ag2.py +2 -2
- openlit/instrumentation/ai21/__init__.py +4 -4
- openlit/instrumentation/ai21/ai21.py +370 -319
- openlit/instrumentation/ai21/async_ai21.py +371 -319
- openlit/instrumentation/anthropic/__init__.py +4 -4
- openlit/instrumentation/anthropic/anthropic.py +321 -189
- openlit/instrumentation/anthropic/async_anthropic.py +323 -190
- openlit/instrumentation/assemblyai/__init__.py +1 -1
- openlit/instrumentation/assemblyai/assemblyai.py +59 -43
- openlit/instrumentation/astra/astra.py +4 -4
- openlit/instrumentation/astra/async_astra.py +4 -4
- openlit/instrumentation/azure_ai_inference/__init__.py +4 -4
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +406 -252
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +406 -252
- openlit/instrumentation/bedrock/__init__.py +1 -1
- openlit/instrumentation/bedrock/bedrock.py +115 -58
- openlit/instrumentation/chroma/chroma.py +4 -4
- openlit/instrumentation/cohere/__init__.py +33 -10
- openlit/instrumentation/cohere/async_cohere.py +610 -0
- openlit/instrumentation/cohere/cohere.py +410 -219
- openlit/instrumentation/controlflow/controlflow.py +2 -2
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +2 -2
- openlit/instrumentation/crawl4ai/crawl4ai.py +2 -2
- openlit/instrumentation/crewai/crewai.py +2 -2
- openlit/instrumentation/dynamiq/dynamiq.py +2 -2
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +73 -47
- openlit/instrumentation/elevenlabs/elevenlabs.py +73 -52
- openlit/instrumentation/embedchain/embedchain.py +4 -4
- openlit/instrumentation/firecrawl/firecrawl.py +2 -2
- openlit/instrumentation/google_ai_studio/__init__.py +9 -9
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +183 -219
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +183 -220
- openlit/instrumentation/gpt4all/gpt4all.py +17 -17
- openlit/instrumentation/groq/async_groq.py +14 -14
- openlit/instrumentation/groq/groq.py +14 -14
- openlit/instrumentation/haystack/haystack.py +2 -2
- openlit/instrumentation/julep/async_julep.py +2 -2
- openlit/instrumentation/julep/julep.py +2 -2
- openlit/instrumentation/langchain/langchain.py +36 -31
- openlit/instrumentation/letta/letta.py +6 -6
- openlit/instrumentation/litellm/async_litellm.py +20 -20
- openlit/instrumentation/litellm/litellm.py +20 -20
- openlit/instrumentation/llamaindex/llamaindex.py +2 -2
- openlit/instrumentation/mem0/mem0.py +2 -2
- openlit/instrumentation/milvus/milvus.py +4 -4
- openlit/instrumentation/mistral/async_mistral.py +18 -18
- openlit/instrumentation/mistral/mistral.py +18 -18
- openlit/instrumentation/multion/async_multion.py +2 -2
- openlit/instrumentation/multion/multion.py +2 -2
- openlit/instrumentation/ollama/async_ollama.py +29 -29
- openlit/instrumentation/ollama/ollama.py +29 -29
- openlit/instrumentation/openai/__init__.py +11 -230
- openlit/instrumentation/openai/async_openai.py +434 -409
- openlit/instrumentation/openai/openai.py +415 -393
- openlit/instrumentation/phidata/phidata.py +2 -2
- openlit/instrumentation/pinecone/pinecone.py +4 -4
- openlit/instrumentation/premai/premai.py +20 -20
- openlit/instrumentation/qdrant/async_qdrant.py +4 -4
- openlit/instrumentation/qdrant/qdrant.py +4 -4
- openlit/instrumentation/reka/async_reka.py +6 -6
- openlit/instrumentation/reka/reka.py +6 -6
- openlit/instrumentation/together/async_together.py +18 -18
- openlit/instrumentation/together/together.py +18 -18
- openlit/instrumentation/transformers/transformers.py +6 -6
- openlit/instrumentation/vertexai/async_vertexai.py +53 -53
- openlit/instrumentation/vertexai/vertexai.py +53 -53
- openlit/instrumentation/vllm/vllm.py +6 -6
- openlit/otel/metrics.py +98 -7
- openlit/semcov/__init__.py +113 -80
- {openlit-1.33.8.dist-info → openlit-1.33.9.dist-info}/METADATA +1 -1
- openlit-1.33.9.dist-info/RECORD +121 -0
- {openlit-1.33.8.dist-info → openlit-1.33.9.dist-info}/WHEEL +1 -1
- openlit/instrumentation/openai/async_azure_openai.py +0 -900
- openlit/instrumentation/openai/azure_openai.py +0 -898
- openlit-1.33.8.dist-info/RECORD +0 -122
- {openlit-1.33.8.dist-info → openlit-1.33.9.dist-info}/LICENSE +0 -0
@@ -1,21 +1,24 @@
|
|
1
|
-
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, protected-access
|
2
1
|
"""
|
3
2
|
Module for monitoring Google AI Studio API calls.
|
4
3
|
"""
|
5
4
|
|
6
5
|
import logging
|
6
|
+
import time
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import (
|
10
|
-
handle_exception,
|
11
10
|
get_chat_model_cost,
|
11
|
+
handle_exception,
|
12
|
+
response_as_dict,
|
13
|
+
create_metrics_attributes,
|
14
|
+
set_server_address_and_port
|
12
15
|
)
|
13
16
|
from openlit.semcov import SemanticConvetion
|
14
17
|
|
15
18
|
# Initialize logger for logging potential issues and operations
|
16
19
|
logger = logging.getLogger(__name__)
|
17
20
|
|
18
|
-
def generate(
|
21
|
+
def generate(version, environment, application_name,
|
19
22
|
tracer, pricing_info, trace_content, metrics, disable_metrics):
|
20
23
|
"""
|
21
24
|
Generates a telemetry wrapper for chat to collect metrics.
|
@@ -35,230 +38,190 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
35
38
|
|
36
39
|
def wrapper(wrapped, instance, args, kwargs):
|
37
40
|
"""
|
38
|
-
Wraps the 'chat' API call to add telemetry.
|
39
|
-
|
41
|
+
Wraps the 'chat.completions' API call to add telemetry.
|
42
|
+
|
40
43
|
This collects metrics such as execution time, cost, and token usage, and handles errors
|
41
44
|
gracefully, adding details to the trace for observability.
|
42
45
|
|
43
46
|
Args:
|
44
|
-
wrapped: The original 'chat' method to be wrapped.
|
47
|
+
wrapped: The original 'chat.completions' method to be wrapped.
|
45
48
|
instance: The instance of the class where the original method is defined.
|
46
|
-
args: Positional arguments for the 'chat' method.
|
47
|
-
kwargs: Keyword arguments for the 'chat' method.
|
49
|
+
args: Positional arguments for the 'chat.completions' method.
|
50
|
+
kwargs: Keyword arguments for the 'chat.completions' method.
|
48
51
|
|
49
52
|
Returns:
|
50
|
-
The response from the original 'chat' method.
|
53
|
+
The response from the original 'chat.completions' method.
|
51
54
|
"""
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
model)
|
107
|
-
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
108
|
-
True)
|
109
|
-
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
|
110
|
-
input_tokens)
|
111
|
-
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COMPLETION_TOKENS,
|
55
|
+
|
56
|
+
server_address, server_port = set_server_address_and_port(instance, "generativelanguage.googleapis.com", 443)
|
57
|
+
request_model = kwargs.get("model", "gemini-2.0-flash")
|
58
|
+
|
59
|
+
span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
60
|
+
|
61
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
62
|
+
start_time = time.time()
|
63
|
+
response = wrapped(*args, **kwargs)
|
64
|
+
end_time = time.time()
|
65
|
+
|
66
|
+
response_dict = response_as_dict(response)
|
67
|
+
|
68
|
+
try:
|
69
|
+
# Format 'messages' into a single string
|
70
|
+
message_prompt = kwargs.get("contents", [])
|
71
|
+
formatted_messages = []
|
72
|
+
|
73
|
+
for content in message_prompt:
|
74
|
+
role = content.role
|
75
|
+
parts = content.parts
|
76
|
+
content_str = []
|
77
|
+
|
78
|
+
for part in parts:
|
79
|
+
# Collect relevant fields and handle each type of data that Part could contain
|
80
|
+
if part.text:
|
81
|
+
content_str.append(f"text: {part.text}")
|
82
|
+
if part.video_metadata:
|
83
|
+
content_str.append(f"video_metadata: {part.video_metadata}")
|
84
|
+
if part.thought:
|
85
|
+
content_str.append(f"thought: {part.thought}")
|
86
|
+
if part.code_execution_result:
|
87
|
+
content_str.append(f"code_execution_result: {part.code_execution_result}")
|
88
|
+
if part.executable_code:
|
89
|
+
content_str.append(f"executable_code: {part.executable_code}")
|
90
|
+
if part.file_data:
|
91
|
+
content_str.append(f"file_data: {part.file_data}")
|
92
|
+
if part.function_call:
|
93
|
+
content_str.append(f"function_call: {part.function_call}")
|
94
|
+
if part.function_response:
|
95
|
+
content_str.append(f"function_response: {part.function_response}")
|
96
|
+
if part.inline_data:
|
97
|
+
content_str.append(f"inline_data: {part.inline_data}")
|
98
|
+
|
99
|
+
formatted_messages.append(f"{role}: {', '.join(content_str)}")
|
100
|
+
|
101
|
+
prompt = "\n".join(formatted_messages)
|
102
|
+
|
103
|
+
input_tokens = response_dict.get('usage_metadata').get('prompt_token_count')
|
104
|
+
output_tokens = response_dict.get('usage_metadata').get('candidates_token_count')
|
105
|
+
|
106
|
+
# Calculate cost of the operation
|
107
|
+
cost = get_chat_model_cost(request_model,
|
108
|
+
pricing_info, input_tokens,
|
112
109
|
output_tokens)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
cost
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
span.set_status(Status(StatusCode.OK))
|
231
|
-
|
232
|
-
if disable_metrics is False:
|
233
|
-
attributes = {
|
234
|
-
TELEMETRY_SDK_NAME:
|
235
|
-
"openlit",
|
236
|
-
SemanticConvetion.GEN_AI_APPLICATION_NAME:
|
237
|
-
application_name,
|
238
|
-
SemanticConvetion.GEN_AI_SYSTEM:
|
239
|
-
SemanticConvetion.GEN_AI_SYSTEM_GOOGLE_AI_STUDIO,
|
240
|
-
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
241
|
-
environment,
|
242
|
-
SemanticConvetion.GEN_AI_TYPE:
|
243
|
-
SemanticConvetion.GEN_AI_TYPE_CHAT,
|
244
|
-
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
245
|
-
model
|
246
|
-
}
|
247
|
-
|
248
|
-
metrics["genai_requests"].add(1, attributes)
|
249
|
-
metrics["genai_total_tokens"].add(total_tokens, attributes)
|
250
|
-
metrics["genai_completion_tokens"].add(completion_tokens, attributes)
|
251
|
-
metrics["genai_prompt_tokens"].add(prompt_tokens, attributes)
|
252
|
-
metrics["genai_cost"].record(cost, attributes)
|
253
|
-
|
254
|
-
# Return original response
|
255
|
-
return response
|
256
|
-
|
257
|
-
except Exception as e:
|
258
|
-
handle_exception(span, e)
|
259
|
-
logger.error("Error in trace creation: %s", e)
|
260
|
-
|
261
|
-
# Return original response
|
262
|
-
return response
|
110
|
+
|
111
|
+
# Set base span attribues (OTel Semconv)
|
112
|
+
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
113
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
114
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
|
115
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
116
|
+
SemanticConvetion.GEN_AI_SYSTEM_GEMINI)
|
117
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
118
|
+
request_model)
|
119
|
+
span.set_attribute(SemanticConvetion.SERVER_PORT,
|
120
|
+
server_port)
|
121
|
+
|
122
|
+
inference_config = kwargs.get('config', {})
|
123
|
+
|
124
|
+
# List of attributes and their config keys
|
125
|
+
attributes = [
|
126
|
+
(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
|
127
|
+
(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
|
128
|
+
(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
|
129
|
+
(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
|
130
|
+
(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
|
131
|
+
(SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
|
132
|
+
(SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
|
133
|
+
]
|
134
|
+
|
135
|
+
# Set each attribute if the corresponding value exists and is not None
|
136
|
+
for attribute, key in attributes:
|
137
|
+
# Use getattr to get the attribute value from the object
|
138
|
+
value = getattr(inference_config, key, None)
|
139
|
+
if value is not None:
|
140
|
+
span.set_attribute(attribute, value)
|
141
|
+
|
142
|
+
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
|
143
|
+
response_dict.get('model_version'))
|
144
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
145
|
+
input_tokens)
|
146
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
147
|
+
output_tokens)
|
148
|
+
span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
|
149
|
+
server_address)
|
150
|
+
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
151
|
+
[str(response_dict.get('candidates')[0].get('finish_reason'))])
|
152
|
+
|
153
|
+
# Set base span attribues (Extras)
|
154
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
155
|
+
environment)
|
156
|
+
span.set_attribute(SERVICE_NAME,
|
157
|
+
application_name)
|
158
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
159
|
+
False)
|
160
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
161
|
+
input_tokens + output_tokens)
|
162
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
163
|
+
cost)
|
164
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
|
165
|
+
end_time - start_time)
|
166
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
167
|
+
version)
|
168
|
+
if trace_content:
|
169
|
+
span.add_event(
|
170
|
+
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
171
|
+
attributes={
|
172
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
173
|
+
},
|
174
|
+
)
|
175
|
+
span.add_event(
|
176
|
+
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
177
|
+
attributes={
|
178
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
|
179
|
+
},
|
180
|
+
)
|
181
|
+
|
182
|
+
if isinstance(response_dict.get('text'), str):
|
183
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
|
184
|
+
"text")
|
185
|
+
elif response_dict.get('text') is not None:
|
186
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
|
187
|
+
"json")
|
188
|
+
|
189
|
+
span.set_status(Status(StatusCode.OK))
|
190
|
+
|
191
|
+
if disable_metrics is False:
|
192
|
+
attributes = create_metrics_attributes(
|
193
|
+
service_name=application_name,
|
194
|
+
deployment_environment=environment,
|
195
|
+
operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
|
196
|
+
system=SemanticConvetion.GEN_AI_SYSTEM_GEMINI,
|
197
|
+
request_model=request_model,
|
198
|
+
server_address=server_address,
|
199
|
+
server_port=server_port,
|
200
|
+
response_model=response_dict.get('model_version'),
|
201
|
+
)
|
202
|
+
|
203
|
+
metrics["genai_client_usage_tokens"].record(
|
204
|
+
input_tokens + output_tokens, attributes
|
205
|
+
)
|
206
|
+
metrics["genai_client_operation_duration"].record(
|
207
|
+
end_time - start_time, attributes
|
208
|
+
)
|
209
|
+
metrics["genai_server_ttft"].record(
|
210
|
+
end_time - start_time, attributes
|
211
|
+
)
|
212
|
+
metrics["genai_requests"].add(1, attributes)
|
213
|
+
metrics["genai_completion_tokens"].add(output_tokens, attributes)
|
214
|
+
metrics["genai_prompt_tokens"].add(input_tokens, attributes)
|
215
|
+
metrics["genai_cost"].record(cost, attributes)
|
216
|
+
|
217
|
+
# Return original response
|
218
|
+
return response
|
219
|
+
|
220
|
+
except Exception as e:
|
221
|
+
handle_exception(span, e)
|
222
|
+
logger.error("Error in trace creation: %s", e)
|
223
|
+
|
224
|
+
# Return original response
|
225
|
+
return response
|
263
226
|
|
264
227
|
return wrapper
|
@@ -84,8 +84,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
84
84
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
85
85
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
86
86
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
|
87
|
-
span.set_attribute(SemanticConvetion.
|
88
|
-
SemanticConvetion.
|
87
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
88
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
|
89
89
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
90
90
|
gen_ai_endpoint)
|
91
91
|
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
@@ -120,9 +120,9 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
120
120
|
},
|
121
121
|
)
|
122
122
|
|
123
|
-
span.set_attribute(SemanticConvetion.
|
123
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
124
124
|
prompt_tokens)
|
125
|
-
span.set_attribute(SemanticConvetion.
|
125
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
126
126
|
completion_tokens)
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
128
128
|
total_tokens)
|
@@ -141,8 +141,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
141
141
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
|
142
142
|
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
143
143
|
environment,
|
144
|
-
SemanticConvetion.
|
145
|
-
SemanticConvetion.
|
144
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
145
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
|
146
146
|
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
147
147
|
model
|
148
148
|
}
|
@@ -180,8 +180,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
180
180
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
181
181
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
182
182
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
|
183
|
-
span.set_attribute(SemanticConvetion.
|
184
|
-
SemanticConvetion.
|
183
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
184
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
|
185
185
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
186
186
|
gen_ai_endpoint)
|
187
187
|
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
@@ -216,9 +216,9 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
216
216
|
},
|
217
217
|
)
|
218
218
|
|
219
|
-
span.set_attribute(SemanticConvetion.
|
219
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
220
220
|
prompt_tokens)
|
221
|
-
span.set_attribute(SemanticConvetion.
|
221
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
222
222
|
completion_tokens)
|
223
223
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
224
224
|
total_tokens)
|
@@ -237,8 +237,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
237
237
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
|
238
238
|
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
239
239
|
environment,
|
240
|
-
SemanticConvetion.
|
241
|
-
SemanticConvetion.
|
240
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
241
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
|
242
242
|
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
243
243
|
model
|
244
244
|
}
|
@@ -312,8 +312,8 @@ def embed(gen_ai_endpoint, version, environment, application_name,
|
|
312
312
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
313
313
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
314
314
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
|
315
|
-
span.set_attribute(SemanticConvetion.
|
316
|
-
SemanticConvetion.
|
315
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
316
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
|
317
317
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
318
318
|
gen_ai_endpoint)
|
319
319
|
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
@@ -322,7 +322,7 @@ def embed(gen_ai_endpoint, version, environment, application_name,
|
|
322
322
|
application_name)
|
323
323
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
324
324
|
model)
|
325
|
-
span.set_attribute(SemanticConvetion.
|
325
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
326
326
|
prompt_tokens)
|
327
327
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
328
328
|
prompt_tokens)
|
@@ -348,8 +348,8 @@ def embed(gen_ai_endpoint, version, environment, application_name,
|
|
348
348
|
SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
|
349
349
|
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
350
350
|
environment,
|
351
|
-
SemanticConvetion.
|
352
|
-
SemanticConvetion.
|
351
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
352
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
|
353
353
|
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
354
354
|
model
|
355
355
|
}
|
@@ -104,8 +104,8 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
104
104
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
105
105
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
106
106
|
SemanticConvetion.GEN_AI_SYSTEM_GROQ)
|
107
|
-
span.set_attribute(SemanticConvetion.
|
108
|
-
SemanticConvetion.
|
107
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
108
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
|
109
109
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
110
110
|
gen_ai_endpoint)
|
111
111
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
|
@@ -132,9 +132,9 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
132
132
|
kwargs.get("seed", ""))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
134
134
|
True)
|
135
|
-
span.set_attribute(SemanticConvetion.
|
135
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
136
136
|
prompt_tokens)
|
137
|
-
span.set_attribute(SemanticConvetion.
|
137
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
138
138
|
completion_tokens)
|
139
139
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
140
140
|
prompt_tokens + completion_tokens)
|
@@ -166,8 +166,8 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
166
166
|
SemanticConvetion.GEN_AI_SYSTEM_GROQ,
|
167
167
|
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
168
168
|
environment,
|
169
|
-
SemanticConvetion.
|
170
|
-
SemanticConvetion.
|
169
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
170
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
|
171
171
|
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
172
172
|
kwargs.get("model", "gpt-3.5-turbo")
|
173
173
|
}
|
@@ -216,8 +216,8 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
216
216
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
217
217
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
218
218
|
SemanticConvetion.GEN_AI_SYSTEM_GROQ)
|
219
|
-
span.set_attribute(SemanticConvetion.
|
220
|
-
SemanticConvetion.
|
219
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
220
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
|
221
221
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
222
222
|
gen_ai_endpoint)
|
223
223
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
|
@@ -259,9 +259,9 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
259
259
|
pricing_info, response.usage.prompt_tokens,
|
260
260
|
response.usage.completion_tokens)
|
261
261
|
|
262
|
-
span.set_attribute(SemanticConvetion.
|
262
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
263
263
|
response.usage.prompt_tokens)
|
264
|
-
span.set_attribute(SemanticConvetion.
|
264
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
265
265
|
response.usage.completion_tokens)
|
266
266
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
267
267
|
response.usage.total_tokens)
|
@@ -305,9 +305,9 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
305
305
|
|
306
306
|
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_COMPLETION,
|
307
307
|
"Function called with tools")
|
308
|
-
span.set_attribute(SemanticConvetion.
|
308
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
|
309
309
|
response.usage.prompt_tokens)
|
310
|
-
span.set_attribute(SemanticConvetion.
|
310
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
|
311
311
|
response.usage.completion_tokens)
|
312
312
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
|
313
313
|
response.usage.total_tokens)
|
@@ -326,8 +326,8 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
326
326
|
SemanticConvetion.GEN_AI_SYSTEM_GROQ,
|
327
327
|
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
328
328
|
environment,
|
329
|
-
SemanticConvetion.
|
330
|
-
SemanticConvetion.
|
329
|
+
SemanticConvetion.GEN_AI_OPERATION:
|
330
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
|
331
331
|
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
332
332
|
kwargs.get("model", "gpt-3.5-turbo")
|
333
333
|
}
|