aidial-sdk 0.45.0.dev1__tar.gz → 0.46.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.
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/PKG-INFO +9 -9
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/telemetry/init.py +37 -9
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/telemetry/types.py +4 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/pyproject.toml +11 -11
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/LICENSE +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/README.md +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/_errors.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/_pydantic/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/_pydantic/_compat.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/_pydantic/_model_config.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/application.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/_cache.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/_types.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/base.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/choice.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/choice_base.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/chunks.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/enums.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/form.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/function_call.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/function_tool_call.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/request.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/response.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/stage.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/_headers.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/configuration.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/from_request_mixin.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/rate.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/tokenize.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/deployment/truncate_prompt.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/embeddings/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/embeddings/base.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/embeddings/request.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/embeddings/response.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/exceptions.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/header_propagator.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/py.typed +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/pydantic/v2.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/pydantic_v1/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/response_headers.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/telemetry/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/telemetry/_context.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/__init__.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_attachment.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_cancel_scope.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_content_stream.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_disconnect_middleware.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_indexed_list.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_json_log_formatter.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_logging.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/_reflection.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/env.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/errors.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/json.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/log_config.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/logging.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/merge_chunks.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/pydantic.py +0 -0
- {aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/utils/streaming.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aidial-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.46.0
|
|
4
4
|
Summary: Framework to create applications and model adapters for AI DIAL
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -19,14 +19,14 @@ Requires-Dist: fastapi (>=0.51,<1.0)
|
|
|
19
19
|
Requires-Dist: httpx (>=0.25.0,<1.0) ; extra == "httpx"
|
|
20
20
|
Requires-Dist: opentelemetry-api (>=1.22.0,<2.0) ; extra == "telemetry"
|
|
21
21
|
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.22.0,<2.0) ; extra == "telemetry"
|
|
22
|
-
Requires-Dist: opentelemetry-exporter-prometheus (>=0.
|
|
23
|
-
Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0.
|
|
24
|
-
Requires-Dist: opentelemetry-instrumentation-fastapi (>=0.
|
|
25
|
-
Requires-Dist: opentelemetry-instrumentation-httpx (>=0.
|
|
26
|
-
Requires-Dist: opentelemetry-instrumentation-logging (>=0.
|
|
27
|
-
Requires-Dist: opentelemetry-instrumentation-requests (>=0.
|
|
28
|
-
Requires-Dist: opentelemetry-instrumentation-system-metrics (>=0.
|
|
29
|
-
Requires-Dist: opentelemetry-instrumentation-urllib (>=0.
|
|
22
|
+
Requires-Dist: opentelemetry-exporter-prometheus (>=0.64b0) ; extra == "telemetry"
|
|
23
|
+
Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0.64b0) ; extra == "telemetry"
|
|
24
|
+
Requires-Dist: opentelemetry-instrumentation-fastapi (>=0.64b0) ; extra == "telemetry"
|
|
25
|
+
Requires-Dist: opentelemetry-instrumentation-httpx (>=0.64b0) ; extra == "telemetry"
|
|
26
|
+
Requires-Dist: opentelemetry-instrumentation-logging (>=0.64b0) ; extra == "telemetry"
|
|
27
|
+
Requires-Dist: opentelemetry-instrumentation-requests (>=0.64b0) ; extra == "telemetry"
|
|
28
|
+
Requires-Dist: opentelemetry-instrumentation-system-metrics (>=0.64b0) ; extra == "telemetry"
|
|
29
|
+
Requires-Dist: opentelemetry-instrumentation-urllib (>=0.64b0) ; extra == "telemetry"
|
|
30
30
|
Requires-Dist: opentelemetry-sdk (>=1.22.0,<2.0) ; extra == "telemetry"
|
|
31
31
|
Requires-Dist: prometheus-client (>=0.17.1,<1.0) ; extra == "telemetry"
|
|
32
32
|
Requires-Dist: pydantic (>=1.10.17,<3)
|
|
@@ -18,7 +18,7 @@ from opentelemetry.instrumentation.system_metrics import (
|
|
|
18
18
|
)
|
|
19
19
|
from opentelemetry.instrumentation.urllib import URLLibInstrumentor
|
|
20
20
|
from opentelemetry.metrics import set_meter_provider
|
|
21
|
-
from opentelemetry.sdk._logs import LoggerProvider
|
|
21
|
+
from opentelemetry.sdk._logs import LoggerProvider
|
|
22
22
|
from opentelemetry.sdk._logs.export import (
|
|
23
23
|
BatchLogRecordProcessor,
|
|
24
24
|
ConsoleLogRecordExporter,
|
|
@@ -37,6 +37,8 @@ from prometheus_client import start_http_server
|
|
|
37
37
|
from aidial_sdk.telemetry.types import TelemetryConfig
|
|
38
38
|
from aidial_sdk.utils._logging import remove_stream_handlers
|
|
39
39
|
|
|
40
|
+
_log = logging.getLogger(__name__)
|
|
41
|
+
|
|
40
42
|
|
|
41
43
|
def init_telemetry(app: FastAPI | None, config: TelemetryConfig):
|
|
42
44
|
resource = Resource.create(
|
|
@@ -84,13 +86,6 @@ def init_telemetry(app: FastAPI | None, config: TelemetryConfig):
|
|
|
84
86
|
except ImportError:
|
|
85
87
|
pass
|
|
86
88
|
|
|
87
|
-
set_logging_format = config.tracing.logging
|
|
88
|
-
if set_logging_format:
|
|
89
|
-
# Remove any competing handlers to avoid duplicate logging
|
|
90
|
-
remove_stream_handlers(logging.getLogger(), sys.stderr)
|
|
91
|
-
|
|
92
|
-
LoggingInstrumentor().instrument(set_logging_format=set_logging_format)
|
|
93
|
-
|
|
94
89
|
if config.logs is not None:
|
|
95
90
|
# Adding a handler to the root logger which exports the logs to OTLP or to the console as JSON.
|
|
96
91
|
provider = LoggerProvider(resource=resource)
|
|
@@ -118,7 +113,24 @@ def init_telemetry(app: FastAPI | None, config: TelemetryConfig):
|
|
|
118
113
|
)
|
|
119
114
|
|
|
120
115
|
set_logger_provider(provider)
|
|
121
|
-
|
|
116
|
+
|
|
117
|
+
if config.tracing is not None or config.logs is not None:
|
|
118
|
+
# OTel's text format writes to stderr, which `console_export` takes over.
|
|
119
|
+
set_logging_format = (
|
|
120
|
+
config.tracing is not None
|
|
121
|
+
and config.tracing.logging
|
|
122
|
+
and not (config.logs is not None and config.logs.console_export)
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
if set_logging_format:
|
|
126
|
+
# Remove any competing handlers to avoid duplicate logging
|
|
127
|
+
remove_stream_handlers(logging.getLogger(), sys.stderr)
|
|
128
|
+
|
|
129
|
+
LoggingInstrumentor().instrument(
|
|
130
|
+
set_logging_format=set_logging_format,
|
|
131
|
+
inject_trace_context=config.tracing is not None,
|
|
132
|
+
enable_log_auto_instrumentation=config.logs is not None,
|
|
133
|
+
)
|
|
122
134
|
|
|
123
135
|
if config.metrics is not None:
|
|
124
136
|
metric_readers = []
|
|
@@ -142,4 +154,20 @@ def init_telemetry(app: FastAPI | None, config: TelemetryConfig):
|
|
|
142
154
|
|
|
143
155
|
if app and (config.tracing is not None or config.metrics is not None):
|
|
144
156
|
# FastAPI instrumentor reports both metrics and traces
|
|
157
|
+
excl = config.tracing.excluded_asgi_spans if config.tracing else []
|
|
158
|
+
_instrument_fastapi_app(app, excl)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _instrument_fastapi_app(app: FastAPI, exclude_spans: list[str]) -> None:
|
|
162
|
+
if not exclude_spans:
|
|
163
|
+
FastAPIInstrumentor.instrument_app(app)
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
try:
|
|
167
|
+
FastAPIInstrumentor.instrument_app(app, exclude_spans=exclude_spans) # type: ignore
|
|
168
|
+
except TypeError:
|
|
169
|
+
_log.warning(
|
|
170
|
+
"OTEL_PYTHON_FASTAPI_EXCLUDE_SPANS is ignored: it requires "
|
|
171
|
+
"opentelemetry-instrumentation-fastapi>=0.48b0."
|
|
172
|
+
)
|
|
145
173
|
FastAPIInstrumentor.instrument_app(app)
|
|
@@ -16,6 +16,9 @@ OTEL_EXPORTER_PROMETHEUS_PORT = int(
|
|
|
16
16
|
OTEL_PYTHON_LOG_CORRELATION = (
|
|
17
17
|
os.getenv("OTEL_PYTHON_LOG_CORRELATION", "false").lower() == "true"
|
|
18
18
|
)
|
|
19
|
+
OTEL_PYTHON_FASTAPI_EXCLUDE_SPANS = env_var_list(
|
|
20
|
+
"OTEL_PYTHON_FASTAPI_EXCLUDE_SPANS"
|
|
21
|
+
)
|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
class LogsConfig(BaseModel):
|
|
@@ -30,6 +33,7 @@ class LogsConfig(BaseModel):
|
|
|
30
33
|
class TracingConfig(BaseModel):
|
|
31
34
|
otlp_export: bool = "otlp" in OTEL_TRACES_EXPORTER
|
|
32
35
|
logging: bool = OTEL_PYTHON_LOG_CORRELATION
|
|
36
|
+
excluded_asgi_spans: list[str] = OTEL_PYTHON_FASTAPI_EXCLUDE_SPANS
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
class MetricsConfig(BaseModel):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "aidial-sdk"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.46.0"
|
|
4
4
|
description = "Framework to create applications and model adapters for AI DIAL"
|
|
5
5
|
authors = [{ name = "EPAM RAIL", email = "SpecialEPM-DIALDevTeam@epam.com" }]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -23,14 +23,14 @@ telemetry = [
|
|
|
23
23
|
"opentelemetry-sdk (>=1.22.0,<2.0)",
|
|
24
24
|
"opentelemetry-api (>=1.22.0,<2.0)",
|
|
25
25
|
"opentelemetry-exporter-otlp-proto-grpc (>=1.22.0,<2.0)",
|
|
26
|
-
"opentelemetry-instrumentation-aiohttp-client (>=0.
|
|
27
|
-
"opentelemetry-instrumentation-fastapi (>=0.
|
|
28
|
-
"opentelemetry-instrumentation-httpx (>=0.
|
|
29
|
-
"opentelemetry-instrumentation-logging (>=0.
|
|
30
|
-
"opentelemetry-instrumentation-requests (>=0.
|
|
31
|
-
"opentelemetry-instrumentation-system-metrics (>=0.
|
|
32
|
-
"opentelemetry-instrumentation-urllib (>=0.
|
|
33
|
-
"opentelemetry-exporter-prometheus (>=0.
|
|
26
|
+
"opentelemetry-instrumentation-aiohttp-client (>=0.64b0)",
|
|
27
|
+
"opentelemetry-instrumentation-fastapi (>=0.64b0)",
|
|
28
|
+
"opentelemetry-instrumentation-httpx (>=0.64b0)",
|
|
29
|
+
"opentelemetry-instrumentation-logging (>=0.64b0)",
|
|
30
|
+
"opentelemetry-instrumentation-requests (>=0.64b0)",
|
|
31
|
+
"opentelemetry-instrumentation-system-metrics (>=0.64b0)",
|
|
32
|
+
"opentelemetry-instrumentation-urllib (>=0.64b0)",
|
|
33
|
+
"opentelemetry-exporter-prometheus (>=0.64b0)",
|
|
34
34
|
"prometheus-client (>=0.17.1,<1.0)",
|
|
35
35
|
]
|
|
36
36
|
httpx = ["httpx (>=0.25.0,<1.0)"]
|
|
@@ -42,11 +42,11 @@ nox = "^2023.4.22"
|
|
|
42
42
|
pillow = "^12.3.0"
|
|
43
43
|
httpx = "^0.25.0"
|
|
44
44
|
respx = "^0.21.1"
|
|
45
|
-
aiohttp = "^3.14.
|
|
45
|
+
aiohttp = "^3.14.4"
|
|
46
46
|
aiointercept = "^0.1.7"
|
|
47
47
|
requests = "^2.33"
|
|
48
48
|
responses = "^0.25.3"
|
|
49
|
-
httpx2 = "^2.12.0"
|
|
49
|
+
httpx2 = "^2.12.0" # required for Starlette.TestClient
|
|
50
50
|
openai = "^2.46.0" # third-party logger for log-takeover tests
|
|
51
51
|
|
|
52
52
|
[tool.poetry.group.lint.dependencies]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aidial_sdk-0.45.0.dev1 → aidial_sdk-0.46.0}/aidial_sdk/chat_completion/function_tool_call.py
RENAMED
|
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
|
|
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
|
|
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
|
|
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
|