openlit 1.14.2__py3-none-any.whl → 1.16.2__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/__init__.py +3 -0
- openlit/instrumentation/anthropic/anthropic.py +2 -2
- openlit/instrumentation/anthropic/async_anthropic.py +2 -2
- openlit/instrumentation/bedrock/__init__.py +3 -3
- openlit/instrumentation/bedrock/bedrock.py +69 -307
- openlit/instrumentation/cohere/cohere.py +2 -2
- openlit/instrumentation/elevenlabs/__init__.py +70 -0
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +117 -0
- openlit/instrumentation/elevenlabs/elevenlabs.py +123 -0
- openlit/instrumentation/groq/async_groq.py +10 -10
- openlit/instrumentation/groq/groq.py +10 -10
- openlit/instrumentation/mistral/async_mistral.py +4 -4
- openlit/instrumentation/mistral/mistral.py +4 -4
- openlit/instrumentation/openai/async_azure_openai.py +12 -12
- openlit/instrumentation/openai/async_openai.py +10 -10
- openlit/instrumentation/openai/azure_openai.py +12 -12
- openlit/instrumentation/openai/openai.py +10 -10
- openlit/instrumentation/transformers/transformers.py +1 -1
- openlit/semcov/__init__.py +5 -3
- {openlit-1.14.2.dist-info → openlit-1.16.2.dist-info}/METADATA +16 -16
- {openlit-1.14.2.dist-info → openlit-1.16.2.dist-info}/RECORD +23 -20
- {openlit-1.14.2.dist-info → openlit-1.16.2.dist-info}/LICENSE +0 -0
- {openlit-1.14.2.dist-info → openlit-1.16.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment
|
2
|
+
"""
|
3
|
+
Module for monitoring Ollama API calls.
|
4
|
+
"""
|
5
|
+
|
6
|
+
import logging
|
7
|
+
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
+
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
9
|
+
from openlit.__helpers import get_audio_model_cost
|
10
|
+
from openlit.__helpers import handle_exception
|
11
|
+
from openlit.semcov import SemanticConvetion
|
12
|
+
|
13
|
+
# Initialize logger for logging potential issues and operations
|
14
|
+
logger = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
def async_generate(gen_ai_endpoint, version, environment, application_name,
|
17
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics):
|
18
|
+
"""
|
19
|
+
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
20
|
+
|
21
|
+
Args:
|
22
|
+
gen_ai_endpoint: Endpoint identifier for logging and tracing.
|
23
|
+
version: Version of the monitoring package.
|
24
|
+
environment: Deployment environment (e.g., production, staging).
|
25
|
+
application_name: Name of the application using the ElevenLabs API.
|
26
|
+
tracer: OpenTelemetry tracer for creating spans.
|
27
|
+
pricing_info: Information used for calculating the cost of generating speech audio.
|
28
|
+
trace_content: Flag indicating whether to trace the input text and generated audio.
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
A function that wraps the speech audio creation method to add telemetry.
|
32
|
+
"""
|
33
|
+
|
34
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
35
|
+
"""
|
36
|
+
Wraps the 'generate' API call to add telemetry.
|
37
|
+
|
38
|
+
This collects metrics such as execution time, cost, and handles errors
|
39
|
+
gracefully, adding details to the trace for observability.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
wrapped: The original 'generate' method to be wrapped.
|
43
|
+
instance: The instance of the class where the original method is defined.
|
44
|
+
args: Positional arguments for the 'generate' method.
|
45
|
+
kwargs: Keyword arguments for the 'generate' method.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
The response from the original 'generate' method.
|
49
|
+
"""
|
50
|
+
|
51
|
+
with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
|
52
|
+
response = await wrapped(*args, **kwargs)
|
53
|
+
|
54
|
+
try:
|
55
|
+
# Calculate cost of the operation
|
56
|
+
cost = get_audio_model_cost(kwargs.get("model", "eleven_multilingual_v2"),
|
57
|
+
pricing_info, kwargs.get("text", ""))
|
58
|
+
|
59
|
+
# Set Span attributes
|
60
|
+
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
62
|
+
SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS)
|
63
|
+
span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
|
64
|
+
SemanticConvetion.GEN_AI_TYPE_AUDIO)
|
65
|
+
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
66
|
+
gen_ai_endpoint)
|
67
|
+
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
68
|
+
environment)
|
69
|
+
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
70
|
+
application_name)
|
71
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
72
|
+
kwargs.get("model", "eleven_multilingual_v2"))
|
73
|
+
if isinstance(kwargs.get("voice", "Rachel"), str):
|
74
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
75
|
+
kwargs.get("voice", "Rachel"))
|
76
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
|
77
|
+
kwargs.get("output_format", "mp3"))
|
78
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
|
79
|
+
str(kwargs.get("voice_settings", "")))
|
80
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
81
|
+
cost)
|
82
|
+
if trace_content:
|
83
|
+
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
|
84
|
+
str(kwargs.get("text", "")))
|
85
|
+
|
86
|
+
span.set_status(Status(StatusCode.OK))
|
87
|
+
|
88
|
+
if disable_metrics is False:
|
89
|
+
attributes = {
|
90
|
+
TELEMETRY_SDK_NAME:
|
91
|
+
"openlit",
|
92
|
+
SemanticConvetion.GEN_AI_APPLICATION_NAME:
|
93
|
+
application_name,
|
94
|
+
SemanticConvetion.GEN_AI_SYSTEM:
|
95
|
+
SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
|
96
|
+
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
97
|
+
environment,
|
98
|
+
SemanticConvetion.GEN_AI_TYPE:
|
99
|
+
SemanticConvetion.GEN_AI_TYPE_AUDIO,
|
100
|
+
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
101
|
+
kwargs.get("model", "eleven_multilingual_v2")
|
102
|
+
}
|
103
|
+
|
104
|
+
metrics["genai_requests"].add(1, attributes)
|
105
|
+
metrics["genai_cost"].record(cost, attributes)
|
106
|
+
|
107
|
+
# Return original response
|
108
|
+
return response
|
109
|
+
|
110
|
+
except Exception as e:
|
111
|
+
handle_exception(span, e)
|
112
|
+
logger.error("Error in trace creation: %s", e)
|
113
|
+
|
114
|
+
# Return original response
|
115
|
+
return response
|
116
|
+
|
117
|
+
return wrapper
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment
|
2
|
+
"""
|
3
|
+
Module for monitoring Ollama API calls.
|
4
|
+
"""
|
5
|
+
|
6
|
+
import logging
|
7
|
+
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
+
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
9
|
+
from openlit.__helpers import get_audio_model_cost
|
10
|
+
from openlit.__helpers import handle_exception
|
11
|
+
from openlit.semcov import SemanticConvetion
|
12
|
+
|
13
|
+
# Initialize logger for logging potential issues and operations
|
14
|
+
logger = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
def generate(gen_ai_endpoint, version, environment, application_name,
|
17
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics):
|
18
|
+
"""
|
19
|
+
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
20
|
+
|
21
|
+
Args:
|
22
|
+
gen_ai_endpoint: Endpoint identifier for logging and tracing.
|
23
|
+
version: Version of the monitoring package.
|
24
|
+
environment: Deployment environment (e.g., production, staging).
|
25
|
+
application_name: Name of the application using the ElevenLabs API.
|
26
|
+
tracer: OpenTelemetry tracer for creating spans.
|
27
|
+
pricing_info: Information used for calculating the cost of generating speech audio.
|
28
|
+
trace_content: Flag indicating whether to trace the input text and generated audio.
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
A function that wraps the speech audio creation method to add telemetry.
|
32
|
+
"""
|
33
|
+
|
34
|
+
def wrapper(wrapped, instance, args, kwargs):
|
35
|
+
"""
|
36
|
+
Wraps the 'generate' API call to add telemetry.
|
37
|
+
|
38
|
+
This collects metrics such as execution time, cost, and handles errors
|
39
|
+
gracefully, adding details to the trace for observability.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
wrapped: The original 'generate' method to be wrapped.
|
43
|
+
instance: The instance of the class where the original method is defined.
|
44
|
+
args: Positional arguments for the 'generate' method.
|
45
|
+
kwargs: Keyword arguments for the 'generate' method.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
The response from the original 'generate' method.
|
49
|
+
"""
|
50
|
+
|
51
|
+
with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
|
52
|
+
response = wrapped(*args, **kwargs)
|
53
|
+
|
54
|
+
try:
|
55
|
+
# Calculate cost of the operation
|
56
|
+
cost = get_audio_model_cost(kwargs.get("model", "eleven_multilingual_v2"),
|
57
|
+
pricing_info, kwargs.get("text", ""))
|
58
|
+
|
59
|
+
# Set Span attributes
|
60
|
+
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
62
|
+
SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS)
|
63
|
+
span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
|
64
|
+
SemanticConvetion.GEN_AI_TYPE_AUDIO)
|
65
|
+
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
66
|
+
gen_ai_endpoint)
|
67
|
+
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
68
|
+
environment)
|
69
|
+
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
70
|
+
application_name)
|
71
|
+
if gen_ai_endpoint == "elevenlabs.generate":
|
72
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
73
|
+
kwargs.get("model", "eleven_multilingual_v2"))
|
74
|
+
if isinstance(kwargs.get("voice", "Rachel"), str):
|
75
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
76
|
+
kwargs.get("voice", "Rachel"))
|
77
|
+
else:
|
78
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
79
|
+
kwargs.get("model_id", "eleven_multilingual_v2"))
|
80
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
81
|
+
kwargs.get("voice_id", ""))
|
82
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
|
83
|
+
kwargs.get("output_format", "mp3"))
|
84
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
|
85
|
+
str(kwargs.get("voice_settings", "")))
|
86
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
87
|
+
cost)
|
88
|
+
if trace_content:
|
89
|
+
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
|
90
|
+
str(kwargs.get("text", "")))
|
91
|
+
|
92
|
+
span.set_status(Status(StatusCode.OK))
|
93
|
+
|
94
|
+
if disable_metrics is False:
|
95
|
+
attributes = {
|
96
|
+
TELEMETRY_SDK_NAME:
|
97
|
+
"openlit",
|
98
|
+
SemanticConvetion.GEN_AI_APPLICATION_NAME:
|
99
|
+
application_name,
|
100
|
+
SemanticConvetion.GEN_AI_SYSTEM:
|
101
|
+
SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
|
102
|
+
SemanticConvetion.GEN_AI_ENVIRONMENT:
|
103
|
+
environment,
|
104
|
+
SemanticConvetion.GEN_AI_TYPE:
|
105
|
+
SemanticConvetion.GEN_AI_TYPE_AUDIO,
|
106
|
+
SemanticConvetion.GEN_AI_REQUEST_MODEL:
|
107
|
+
kwargs.get("model", "eleven_multilingual_v2")
|
108
|
+
}
|
109
|
+
|
110
|
+
metrics["genai_requests"].add(1, attributes)
|
111
|
+
metrics["genai_cost"].record(cost, attributes)
|
112
|
+
|
113
|
+
# Return original response
|
114
|
+
return response
|
115
|
+
|
116
|
+
except Exception as e:
|
117
|
+
handle_exception(span, e)
|
118
|
+
logger.error("Error in trace creation: %s", e)
|
119
|
+
|
120
|
+
# Return original response
|
121
|
+
return response
|
122
|
+
|
123
|
+
return wrapper
|
@@ -119,15 +119,15 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
119
119
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
120
120
|
kwargs.get("user", ""))
|
121
121
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
122
|
-
kwargs.get("top_p", 1))
|
122
|
+
kwargs.get("top_p", 1.0))
|
123
123
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
124
|
-
kwargs.get("max_tokens",
|
124
|
+
kwargs.get("max_tokens", -1))
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
126
|
-
kwargs.get("temperature", 1))
|
126
|
+
kwargs.get("temperature", 1.0))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
128
|
-
kwargs.get("presence_penalty", 0))
|
128
|
+
kwargs.get("presence_penalty", 0.0))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
130
|
-
kwargs.get("frequency_penalty", 0))
|
130
|
+
kwargs.get("frequency_penalty", 0.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
132
132
|
kwargs.get("seed", ""))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -221,17 +221,17 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
221
221
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
222
222
|
kwargs.get("model", "llama3-8b-8192"))
|
223
223
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
224
|
-
kwargs.get("top_p", 1))
|
224
|
+
kwargs.get("top_p", 1.0))
|
225
225
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
226
|
-
kwargs.get("max_tokens",
|
226
|
+
kwargs.get("max_tokens", -1))
|
227
227
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
228
228
|
kwargs.get("name", ""))
|
229
229
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
230
|
-
kwargs.get("temperature", 1))
|
230
|
+
kwargs.get("temperature", 1.0))
|
231
231
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
232
|
-
kwargs.get("presence_penalty", 0))
|
232
|
+
kwargs.get("presence_penalty", 0.0))
|
233
233
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
234
|
-
kwargs.get("frequency_penalty", 0))
|
234
|
+
kwargs.get("frequency_penalty", 0.0))
|
235
235
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
236
236
|
kwargs.get("seed", ""))
|
237
237
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -119,15 +119,15 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
119
119
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
120
120
|
kwargs.get("user", ""))
|
121
121
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
122
|
-
kwargs.get("top_p", 1))
|
122
|
+
kwargs.get("top_p", 1.0))
|
123
123
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
124
|
-
kwargs.get("max_tokens",
|
124
|
+
kwargs.get("max_tokens", -1))
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
126
|
-
kwargs.get("temperature", 1))
|
126
|
+
kwargs.get("temperature", 1.0))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
128
|
-
kwargs.get("presence_penalty", 0))
|
128
|
+
kwargs.get("presence_penalty", 0.0))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
130
|
-
kwargs.get("frequency_penalty", 0))
|
130
|
+
kwargs.get("frequency_penalty", 0.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
132
132
|
kwargs.get("seed", ""))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -221,17 +221,17 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
221
221
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
222
222
|
kwargs.get("model", "llama3-8b-8192"))
|
223
223
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
224
|
-
kwargs.get("top_p", 1))
|
224
|
+
kwargs.get("top_p", 1.0))
|
225
225
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
226
|
-
kwargs.get("max_tokens",
|
226
|
+
kwargs.get("max_tokens", -1))
|
227
227
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
228
228
|
kwargs.get("name", ""))
|
229
229
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
230
|
-
kwargs.get("temperature", 1))
|
230
|
+
kwargs.get("temperature", 1.0))
|
231
231
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
232
|
-
kwargs.get("presence_penalty", 0))
|
232
|
+
kwargs.get("presence_penalty", 0.0))
|
233
233
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
234
|
-
kwargs.get("frequency_penalty", 0))
|
234
|
+
kwargs.get("frequency_penalty", 0.0))
|
235
235
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
236
236
|
kwargs.get("seed", ""))
|
237
237
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -95,9 +95,9 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
95
95
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
96
96
|
kwargs.get("temperature", 0.7))
|
97
97
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
98
|
-
kwargs.get("top_p", 1))
|
98
|
+
kwargs.get("top_p", 1.0))
|
99
99
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
100
|
-
kwargs.get("max_tokens",
|
100
|
+
kwargs.get("max_tokens", -1))
|
101
101
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
102
102
|
kwargs.get("random_seed", ""))
|
103
103
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -252,9 +252,9 @@ def async_chat_stream(gen_ai_endpoint, version, environment, application_name,
|
|
252
252
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
253
253
|
kwargs.get("temperature", 0.7))
|
254
254
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
255
|
-
kwargs.get("top_p", 1))
|
255
|
+
kwargs.get("top_p", 1.0))
|
256
256
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
257
|
-
kwargs.get("max_tokens",
|
257
|
+
kwargs.get("max_tokens", -1))
|
258
258
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
259
259
|
kwargs.get("random_seed", ""))
|
260
260
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -94,9 +94,9 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
94
94
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
95
95
|
kwargs.get("temperature", 0.7))
|
96
96
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
97
|
-
kwargs.get("top_p", 1))
|
97
|
+
kwargs.get("top_p", 1.0))
|
98
98
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
99
|
-
kwargs.get("max_tokens",
|
99
|
+
kwargs.get("max_tokens", -1))
|
100
100
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
101
101
|
kwargs.get("random_seed", ""))
|
102
102
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -251,9 +251,9 @@ def chat_stream(gen_ai_endpoint, version, environment, application_name,
|
|
251
251
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
252
252
|
kwargs.get("temperature", 0.7))
|
253
253
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
254
|
-
kwargs.get("top_p", 1))
|
254
|
+
kwargs.get("top_p", 1.0))
|
255
255
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
256
|
-
kwargs.get("max_tokens",
|
256
|
+
kwargs.get("max_tokens", -1))
|
257
257
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
258
258
|
kwargs.get("random_seed", ""))
|
259
259
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -125,11 +125,11 @@ def azure_async_chat_completions(gen_ai_endpoint, version, environment, applicat
|
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
126
126
|
kwargs.get("tool_choice", ""))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
128
|
-
kwargs.get("temperature", 1))
|
128
|
+
kwargs.get("temperature", 1.0))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
130
|
-
kwargs.get("presence_penalty", 0))
|
130
|
+
kwargs.get("presence_penalty", 0.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
132
|
-
kwargs.get("frequency_penalty", 0))
|
132
|
+
kwargs.get("frequency_penalty", 0.0))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
134
134
|
kwargs.get("seed", ""))
|
135
135
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -228,11 +228,11 @@ def azure_async_chat_completions(gen_ai_endpoint, version, environment, applicat
|
|
228
228
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
229
229
|
kwargs.get("tool_choice", ""))
|
230
230
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
231
|
-
kwargs.get("temperature", 1))
|
231
|
+
kwargs.get("temperature", 1.0))
|
232
232
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
233
|
-
kwargs.get("presence_penalty", 0))
|
233
|
+
kwargs.get("presence_penalty", 0.0))
|
234
234
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
235
|
-
kwargs.get("frequency_penalty", 0))
|
235
|
+
kwargs.get("frequency_penalty", 0.0))
|
236
236
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
237
237
|
kwargs.get("seed", ""))
|
238
238
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -425,11 +425,11 @@ def azure_async_completions(gen_ai_endpoint, version, environment, application_n
|
|
425
425
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
426
426
|
kwargs.get("tool_choice", ""))
|
427
427
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
428
|
-
kwargs.get("temperature", 1))
|
428
|
+
kwargs.get("temperature", 1.0))
|
429
429
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
430
|
-
kwargs.get("presence_penalty", 0))
|
430
|
+
kwargs.get("presence_penalty", 0.0))
|
431
431
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
432
|
-
kwargs.get("frequency_penalty", 0))
|
432
|
+
kwargs.get("frequency_penalty", 0.0))
|
433
433
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
434
434
|
kwargs.get("seed", ""))
|
435
435
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -509,11 +509,11 @@ def azure_async_completions(gen_ai_endpoint, version, environment, application_n
|
|
509
509
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
510
510
|
kwargs.get("tool_choice", ""))
|
511
511
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
512
|
-
kwargs.get("temperature", 1))
|
512
|
+
kwargs.get("temperature", 1.0))
|
513
513
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
514
|
-
kwargs.get("presence_penalty", 0))
|
514
|
+
kwargs.get("presence_penalty", 0.0))
|
515
515
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
516
|
-
kwargs.get("frequency_penalty", 0))
|
516
|
+
kwargs.get("frequency_penalty", 0.0))
|
517
517
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
518
518
|
kwargs.get("seed", ""))
|
519
519
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -122,15 +122,15 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
122
122
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
123
123
|
kwargs.get("user", ""))
|
124
124
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
125
|
-
kwargs.get("top_p", 1))
|
125
|
+
kwargs.get("top_p", 1.0))
|
126
126
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
127
|
-
kwargs.get("max_tokens",
|
127
|
+
kwargs.get("max_tokens", -1))
|
128
128
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
129
|
-
kwargs.get("temperature", 1))
|
129
|
+
kwargs.get("temperature", 1.0))
|
130
130
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
131
|
-
kwargs.get("presence_penalty", 0))
|
131
|
+
kwargs.get("presence_penalty", 0.0))
|
132
132
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
133
|
-
kwargs.get("frequency_penalty", 0))
|
133
|
+
kwargs.get("frequency_penalty", 0.0))
|
134
134
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
135
135
|
kwargs.get("seed", ""))
|
136
136
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -224,17 +224,17 @@ def async_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
224
224
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
225
225
|
kwargs.get("model", "gpt-3.5-turbo"))
|
226
226
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
227
|
-
kwargs.get("top_p", 1))
|
227
|
+
kwargs.get("top_p", 1.0))
|
228
228
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
229
|
-
kwargs.get("max_tokens",
|
229
|
+
kwargs.get("max_tokens", -1))
|
230
230
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
231
231
|
kwargs.get("user", ""))
|
232
232
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
233
|
-
kwargs.get("temperature", 1))
|
233
|
+
kwargs.get("temperature", 1.0))
|
234
234
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
235
|
-
kwargs.get("presence_penalty", 0))
|
235
|
+
kwargs.get("presence_penalty", 0.0))
|
236
236
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
237
|
-
kwargs.get("frequency_penalty", 0))
|
237
|
+
kwargs.get("frequency_penalty", 0.0))
|
238
238
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
239
239
|
kwargs.get("seed", ""))
|
240
240
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -125,11 +125,11 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
126
126
|
kwargs.get("tool_choice", ""))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
128
|
-
kwargs.get("temperature", 1))
|
128
|
+
kwargs.get("temperature", 1.0))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
130
|
-
kwargs.get("presence_penalty", 0))
|
130
|
+
kwargs.get("presence_penalty", 0.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
132
|
-
kwargs.get("frequency_penalty", 0))
|
132
|
+
kwargs.get("frequency_penalty", 0.0))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
134
134
|
kwargs.get("seed", ""))
|
135
135
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -228,11 +228,11 @@ def azure_chat_completions(gen_ai_endpoint, version, environment, application_na
|
|
228
228
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
229
229
|
kwargs.get("tool_choice", ""))
|
230
230
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
231
|
-
kwargs.get("temperature", 1))
|
231
|
+
kwargs.get("temperature", 1.0))
|
232
232
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
233
|
-
kwargs.get("presence_penalty", 0))
|
233
|
+
kwargs.get("presence_penalty", 0.0))
|
234
234
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
235
|
-
kwargs.get("frequency_penalty", 0))
|
235
|
+
kwargs.get("frequency_penalty", 0.0))
|
236
236
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
237
237
|
kwargs.get("seed", ""))
|
238
238
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -423,11 +423,11 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
423
423
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
424
424
|
kwargs.get("tool_choice", ""))
|
425
425
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
426
|
-
kwargs.get("temperature", 1))
|
426
|
+
kwargs.get("temperature", 1.0))
|
427
427
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
428
|
-
kwargs.get("presence_penalty", 0))
|
428
|
+
kwargs.get("presence_penalty", 0.0))
|
429
429
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
430
|
-
kwargs.get("frequency_penalty", 0))
|
430
|
+
kwargs.get("frequency_penalty", 0.0))
|
431
431
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
432
432
|
kwargs.get("seed", ""))
|
433
433
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -507,11 +507,11 @@ def azure_completions(gen_ai_endpoint, version, environment, application_name,
|
|
507
507
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOOL_CHOICE,
|
508
508
|
kwargs.get("tool_choice", ""))
|
509
509
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
510
|
-
kwargs.get("temperature", 1))
|
510
|
+
kwargs.get("temperature", 1.0))
|
511
511
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
512
|
-
kwargs.get("presence_penalty", 0))
|
512
|
+
kwargs.get("presence_penalty", 0.0))
|
513
513
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
514
|
-
kwargs.get("frequency_penalty", 0))
|
514
|
+
kwargs.get("frequency_penalty", 0.0))
|
515
515
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
516
516
|
kwargs.get("seed", ""))
|
517
517
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -123,15 +123,15 @@ def chat_completions(gen_ai_endpoint, version, environment, application_name,
|
|
123
123
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
124
124
|
kwargs.get("user", ""))
|
125
125
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
126
|
-
kwargs.get("top_p", 1))
|
126
|
+
kwargs.get("top_p", 1.0))
|
127
127
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
128
|
-
kwargs.get("max_tokens",
|
128
|
+
kwargs.get("max_tokens", -1))
|
129
129
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
130
|
-
kwargs.get("temperature", 1))
|
130
|
+
kwargs.get("temperature", 1.0))
|
131
131
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
132
|
-
kwargs.get("presence_penalty", 0))
|
132
|
+
kwargs.get("presence_penalty", 0.0))
|
133
133
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
134
|
-
kwargs.get("frequency_penalty", 0))
|
134
|
+
kwargs.get("frequency_penalty", 0.0))
|
135
135
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
136
136
|
kwargs.get("seed", ""))
|
137
137
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -225,17 +225,17 @@ def chat_completions(gen_ai_endpoint, version, environment, application_name,
|
|
225
225
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
226
226
|
kwargs.get("model", "gpt-3.5-turbo"))
|
227
227
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
228
|
-
kwargs.get("top_p", 1))
|
228
|
+
kwargs.get("top_p", 1.0))
|
229
229
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
230
|
-
kwargs.get("max_tokens",
|
230
|
+
kwargs.get("max_tokens", -1))
|
231
231
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
|
232
232
|
kwargs.get("user", ""))
|
233
233
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
|
234
|
-
kwargs.get("temperature", 1))
|
234
|
+
kwargs.get("temperature", 1.0))
|
235
235
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
236
|
-
kwargs.get("presence_penalty", 0))
|
236
|
+
kwargs.get("presence_penalty", 0.0))
|
237
237
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
238
|
-
kwargs.get("frequency_penalty", 0))
|
238
|
+
kwargs.get("frequency_penalty", 0.0))
|
239
239
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
|
240
240
|
kwargs.get("seed", ""))
|
241
241
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
@@ -87,7 +87,7 @@ def text_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
87
87
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
|
88
88
|
forward_params.get("top_p", "null"))
|
89
89
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
|
90
|
-
forward_params.get("max_length",
|
90
|
+
forward_params.get("max_length", -1))
|
91
91
|
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
|
92
92
|
prompt)
|
93
93
|
if trace_content:
|