opentelemetry-instrumentation-openai 0.14.1__tar.gz → 0.14.3__tar.gz
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.
Potentially problematic release.
This version of opentelemetry-instrumentation-openai might be problematic. Click here for more details.
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/PKG-INFO +2 -2
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/shared/__init__.py +17 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +26 -9
- opentelemetry_instrumentation_openai-0.14.3/opentelemetry/instrumentation/openai/version.py +1 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/pyproject.toml +2 -2
- opentelemetry_instrumentation_openai-0.14.1/opentelemetry/instrumentation/openai/version.py +0 -1
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/README.md +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/utils.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
{opentelemetry_instrumentation_openai-0.14.1 → opentelemetry_instrumentation_openai-0.14.3}/PKG-INFO
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentelemetry-instrumentation-openai
|
|
3
|
-
Version: 0.14.
|
|
3
|
+
Version: 0.14.3
|
|
4
4
|
Summary: OpenTelemetry OpenAI instrumentation
|
|
5
5
|
Home-page: https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-openai
|
|
6
6
|
License: Apache-2.0
|
|
7
7
|
Author: Gal Kleinman
|
|
8
8
|
Author-email: gal@traceloop.com
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.9,<4
|
|
10
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -90,6 +90,23 @@ def _set_functions_attributes(span, functions):
|
|
|
90
90
|
)
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
def set_tools_attributes(span, tools):
|
|
94
|
+
if not tools:
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
for i, tool in enumerate(tools):
|
|
98
|
+
function = tool.get("function")
|
|
99
|
+
if not function:
|
|
100
|
+
continue
|
|
101
|
+
|
|
102
|
+
prefix = f"{SpanAttributes.LLM_REQUEST_FUNCTIONS}.{i}"
|
|
103
|
+
_set_span_attribute(span, f"{prefix}.name", function.get("name"))
|
|
104
|
+
_set_span_attribute(span, f"{prefix}.description", function.get("description"))
|
|
105
|
+
_set_span_attribute(
|
|
106
|
+
span, f"{prefix}.parameters", json.dumps(function.get("parameters"))
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
93
110
|
def _set_request_attributes(span, kwargs):
|
|
94
111
|
if not span.is_recording():
|
|
95
112
|
return
|
|
@@ -16,6 +16,7 @@ from opentelemetry.instrumentation.openai.shared import (
|
|
|
16
16
|
_set_request_attributes,
|
|
17
17
|
_set_span_attribute,
|
|
18
18
|
_set_functions_attributes,
|
|
19
|
+
set_tools_attributes,
|
|
19
20
|
_set_response_attributes,
|
|
20
21
|
is_streaming_response,
|
|
21
22
|
should_send_prompts,
|
|
@@ -137,7 +138,10 @@ def _handle_request(span, kwargs, instance):
|
|
|
137
138
|
_set_client_attributes(span, instance)
|
|
138
139
|
if should_send_prompts():
|
|
139
140
|
_set_prompts(span, kwargs.get("messages"))
|
|
140
|
-
|
|
141
|
+
if kwargs.get("functions"):
|
|
142
|
+
_set_functions_attributes(span, kwargs.get("functions"))
|
|
143
|
+
elif kwargs.get("tools"):
|
|
144
|
+
set_tools_attributes(span, kwargs.get("tools"))
|
|
141
145
|
|
|
142
146
|
|
|
143
147
|
def _handle_response(
|
|
@@ -253,15 +257,28 @@ def _set_completions(span, choices):
|
|
|
253
257
|
_set_span_attribute(span, f"{prefix}.content", message.get("content"))
|
|
254
258
|
|
|
255
259
|
function_call = message.get("function_call")
|
|
256
|
-
if
|
|
257
|
-
|
|
260
|
+
if function_call:
|
|
261
|
+
_set_span_attribute(
|
|
262
|
+
span, f"{prefix}.function_call.name", function_call.get("name")
|
|
263
|
+
)
|
|
264
|
+
_set_span_attribute(
|
|
265
|
+
span,
|
|
266
|
+
f"{prefix}.function_call.arguments",
|
|
267
|
+
function_call.get("arguments"),
|
|
268
|
+
)
|
|
258
269
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
270
|
+
tool_calls = message.get("tool_calls")
|
|
271
|
+
if tool_calls:
|
|
272
|
+
_set_span_attribute(
|
|
273
|
+
span,
|
|
274
|
+
f"{prefix}.function_call.name",
|
|
275
|
+
tool_calls[0].get("function").get("name"),
|
|
276
|
+
)
|
|
277
|
+
_set_span_attribute(
|
|
278
|
+
span,
|
|
279
|
+
f"{prefix}.function_call.arguments",
|
|
280
|
+
tool_calls[0].get("function").get("arguments"),
|
|
281
|
+
)
|
|
265
282
|
|
|
266
283
|
|
|
267
284
|
def _build_from_streaming_response(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.14.3"
|
|
@@ -8,7 +8,7 @@ show_missing = true
|
|
|
8
8
|
|
|
9
9
|
[tool.poetry]
|
|
10
10
|
name = "opentelemetry-instrumentation-openai"
|
|
11
|
-
version = "0.14.
|
|
11
|
+
version = "0.14.3"
|
|
12
12
|
description = "OpenTelemetry OpenAI instrumentation"
|
|
13
13
|
authors = [
|
|
14
14
|
"Gal Kleinman <gal@traceloop.com>",
|
|
@@ -23,7 +23,7 @@ readme = "README.md"
|
|
|
23
23
|
include = "opentelemetry/instrumentation/openai"
|
|
24
24
|
|
|
25
25
|
[tool.poetry.dependencies]
|
|
26
|
-
python = ">=3.
|
|
26
|
+
python = ">=3.9,<4"
|
|
27
27
|
opentelemetry-api = "^1.23.0"
|
|
28
28
|
opentelemetry-instrumentation = "0.44b0"
|
|
29
29
|
opentelemetry-semantic-conventions-ai = "^0.0.23"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.14.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|