opentelemetry-instrumentation-openai 0.5.3__tar.gz → 0.7.0__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.5.3 → opentelemetry_instrumentation_openai-0.7.0}/PKG-INFO +1 -1
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/shared/__init__.py +9 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +3 -2
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +3 -2
- opentelemetry_instrumentation_openai-0.7.0/opentelemetry/instrumentation/openai/version.py +1 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/pyproject.toml +1 -1
- opentelemetry_instrumentation_openai-0.5.3/opentelemetry/instrumentation/openai/version.py +0 -1
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/README.md +0 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/utils.py +0 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
|
@@ -4,6 +4,8 @@ import json
|
|
|
4
4
|
import types
|
|
5
5
|
import logging
|
|
6
6
|
|
|
7
|
+
from importlib.metadata import version
|
|
8
|
+
|
|
7
9
|
from opentelemetry import context as context_api
|
|
8
10
|
|
|
9
11
|
from opentelemetry.semconv.ai import SpanAttributes
|
|
@@ -135,3 +137,10 @@ def is_streaming_response(response):
|
|
|
135
137
|
return isinstance(response, openai.Stream)
|
|
136
138
|
|
|
137
139
|
return isinstance(response, types.GeneratorType) or isinstance(response, types.AsyncGeneratorType)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def model_as_dict(model):
|
|
143
|
+
if version("pydantic") < "2.0.0":
|
|
144
|
+
return model.dict()
|
|
145
|
+
|
|
146
|
+
return model.model_dump()
|
|
@@ -16,6 +16,7 @@ from opentelemetry.instrumentation.openai.shared import (
|
|
|
16
16
|
_set_response_attributes,
|
|
17
17
|
is_streaming_response,
|
|
18
18
|
should_send_prompts,
|
|
19
|
+
model_as_dict,
|
|
19
20
|
)
|
|
20
21
|
from opentelemetry.trace import SpanKind
|
|
21
22
|
from opentelemetry.trace.status import Status, StatusCode
|
|
@@ -77,7 +78,7 @@ def _handle_request(span, kwargs):
|
|
|
77
78
|
|
|
78
79
|
def _handle_response(response, span):
|
|
79
80
|
if is_openai_v1():
|
|
80
|
-
response_dict = response
|
|
81
|
+
response_dict = model_as_dict(response)
|
|
81
82
|
else:
|
|
82
83
|
response_dict = response
|
|
83
84
|
|
|
@@ -173,7 +174,7 @@ async def _abuild_from_streaming_response(span, response):
|
|
|
173
174
|
|
|
174
175
|
def _accumulate_stream_items(item, complete_response):
|
|
175
176
|
if is_openai_v1():
|
|
176
|
-
item = item
|
|
177
|
+
item = model_as_dict(item)
|
|
177
178
|
|
|
178
179
|
for choice in item.get("choices"):
|
|
179
180
|
index = choice.get("index")
|
|
@@ -16,6 +16,7 @@ from opentelemetry.instrumentation.openai.shared import (
|
|
|
16
16
|
_set_response_attributes,
|
|
17
17
|
is_streaming_response,
|
|
18
18
|
should_send_prompts,
|
|
19
|
+
model_as_dict,
|
|
19
20
|
)
|
|
20
21
|
|
|
21
22
|
from opentelemetry.instrumentation.openai.utils import is_openai_v1
|
|
@@ -74,7 +75,7 @@ def _handle_request(span, kwargs):
|
|
|
74
75
|
|
|
75
76
|
def _handle_response(response, span):
|
|
76
77
|
if is_openai_v1():
|
|
77
|
-
response_dict = response
|
|
78
|
+
response_dict = model_as_dict(response)
|
|
78
79
|
else:
|
|
79
80
|
response_dict = response
|
|
80
81
|
|
|
@@ -119,7 +120,7 @@ def _build_from_streaming_response(span, response):
|
|
|
119
120
|
for item in response:
|
|
120
121
|
item_to_yield = item
|
|
121
122
|
if is_openai_v1():
|
|
122
|
-
item = item
|
|
123
|
+
item = model_as_dict(item)
|
|
123
124
|
|
|
124
125
|
for choice in item.get("choices"):
|
|
125
126
|
index = choice.get("index")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0"
|
|
@@ -11,7 +11,7 @@ addopts = "--cov --cov-report html:'../../coverage/packages/opentelemetry-instru
|
|
|
11
11
|
|
|
12
12
|
[tool.poetry]
|
|
13
13
|
name = "opentelemetry-instrumentation-openai"
|
|
14
|
-
version = "0.
|
|
14
|
+
version = "0.7.0"
|
|
15
15
|
description = "OpenTelemetry OpenAI instrumentation"
|
|
16
16
|
authors = [
|
|
17
17
|
"Gal Kleinman <gal@traceloop.com>",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.3"
|
{opentelemetry_instrumentation_openai-0.5.3 → opentelemetry_instrumentation_openai-0.7.0}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|