opentelemetry-instrumentation-openai 0.16.6__tar.gz → 0.16.8__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.16.6 → opentelemetry_instrumentation_openai-0.16.8}/PKG-INFO +1 -1
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +14 -10
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/utils.py +7 -0
- opentelemetry_instrumentation_openai-0.16.8/opentelemetry/instrumentation/openai/version.py +1 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/pyproject.toml +1 -1
- opentelemetry_instrumentation_openai-0.16.6/opentelemetry/instrumentation/openai/version.py +0 -1
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/README.md +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/config.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -0
{opentelemetry_instrumentation_openai-0.16.6 → opentelemetry_instrumentation_openai-0.16.8}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentelemetry-instrumentation-openai
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.8
|
|
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
|
|
@@ -30,7 +30,7 @@ from opentelemetry.instrumentation.openai.shared import (
|
|
|
30
30
|
from opentelemetry.trace import SpanKind, Tracer
|
|
31
31
|
from opentelemetry.trace.status import Status, StatusCode
|
|
32
32
|
|
|
33
|
-
from opentelemetry.instrumentation.openai.utils import is_openai_v1
|
|
33
|
+
from opentelemetry.instrumentation.openai.utils import is_openai_v1, is_azure_openai
|
|
34
34
|
|
|
35
35
|
SPAN_NAME = "openai.chat"
|
|
36
36
|
LLM_REQUEST_TYPE = LLMRequestTypeValues.CHAT
|
|
@@ -303,6 +303,11 @@ def _set_completions(span, choices):
|
|
|
303
303
|
span, f"{prefix}.finish_reason", choice.get("finish_reason")
|
|
304
304
|
)
|
|
305
305
|
|
|
306
|
+
if choice.get("finish_reason") == "content_filter":
|
|
307
|
+
_set_span_attribute(span, f"{prefix}.role", "assistant")
|
|
308
|
+
_set_span_attribute(span, f"{prefix}.content", "FILTERED")
|
|
309
|
+
return
|
|
310
|
+
|
|
306
311
|
message = choice.get("message")
|
|
307
312
|
if not message:
|
|
308
313
|
return
|
|
@@ -428,9 +433,10 @@ def _build_from_streaming_response(
|
|
|
428
433
|
"stream": True,
|
|
429
434
|
}
|
|
430
435
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
436
|
+
if not is_azure_openai(instance):
|
|
437
|
+
_set_streaming_token_metrics(
|
|
438
|
+
request_kwargs, complete_response, span, token_counter, shared_attributes
|
|
439
|
+
)
|
|
434
440
|
|
|
435
441
|
# choice metrics
|
|
436
442
|
if choice_counter and complete_response.get("choices"):
|
|
@@ -495,9 +501,10 @@ async def _abuild_from_streaming_response(
|
|
|
495
501
|
"stream": True,
|
|
496
502
|
}
|
|
497
503
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
504
|
+
if not is_azure_openai(instance):
|
|
505
|
+
_set_streaming_token_metrics(
|
|
506
|
+
request_kwargs, complete_response, span, token_counter, shared_attributes
|
|
507
|
+
)
|
|
501
508
|
|
|
502
509
|
# choice metrics
|
|
503
510
|
if choice_counter and complete_response.get("choices"):
|
|
@@ -546,6 +553,3 @@ def _accumulate_stream_items(item, complete_response):
|
|
|
546
553
|
complete_choice["message"]["content"] += delta.get("content")
|
|
547
554
|
if delta and delta.get("role"):
|
|
548
555
|
complete_choice["message"]["role"] = delta.get("role")
|
|
549
|
-
|
|
550
|
-
if choice.get("content_filter_results"):
|
|
551
|
-
complete_choice["message"]["content"] = "FILTERED"
|
|
@@ -3,6 +3,7 @@ from contextlib import asynccontextmanager
|
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
5
5
|
|
|
6
|
+
import openai
|
|
6
7
|
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,6 +11,12 @@ def is_openai_v1():
|
|
|
10
11
|
return version("openai") >= "1.0.0"
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
def is_azure_openai(instance):
|
|
15
|
+
return is_openai_v1() and isinstance(
|
|
16
|
+
instance._client, (openai.AsyncAzureOpenAI, openai.AzureOpenAI)
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
13
20
|
def is_metrics_enabled() -> bool:
|
|
14
21
|
return (os.getenv("TRACELOOP_METRICS_ENABLED") or "true").lower() == "true"
|
|
15
22
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.16.8"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.16.6"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|