veris-ai 1.14.1__py3-none-any.whl → 1.14.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.
Potentially problematic release.
This version of veris-ai might be problematic. Click here for more details.
- veris_ai/api_client.py +16 -6
- veris_ai/tool_mock.py +5 -4
- {veris_ai-1.14.1.dist-info → veris_ai-1.14.2.dist-info}/METADATA +1 -1
- {veris_ai-1.14.1.dist-info → veris_ai-1.14.2.dist-info}/RECORD +6 -6
- {veris_ai-1.14.1.dist-info → veris_ai-1.14.2.dist-info}/WHEEL +0 -0
- {veris_ai-1.14.1.dist-info → veris_ai-1.14.2.dist-info}/licenses/LICENSE +0 -0
veris_ai/api_client.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
5
|
+
from contextvars import ContextVar
|
|
5
6
|
from typing import Any
|
|
6
7
|
|
|
7
8
|
import httpx
|
|
@@ -9,6 +10,9 @@ from urllib.parse import urljoin
|
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger(__name__)
|
|
11
12
|
|
|
13
|
+
# Context variable to store base_url for per-request multi-tenant scenarios
|
|
14
|
+
_base_url_context: ContextVar[str | None] = ContextVar("veris_base_url", default=None)
|
|
15
|
+
|
|
12
16
|
|
|
13
17
|
class SimulatorAPIClient:
|
|
14
18
|
"""Centralized client for making requests to VERIS simulation endpoints.
|
|
@@ -20,10 +24,9 @@ class SimulatorAPIClient:
|
|
|
20
24
|
changes reflected without recreating the singleton.
|
|
21
25
|
"""
|
|
22
26
|
|
|
23
|
-
def __init__(self, timeout: float | None = None
|
|
27
|
+
def __init__(self, timeout: float | None = None) -> None:
|
|
24
28
|
"""Initialize the API client with static timeout configuration."""
|
|
25
29
|
self._timeout = timeout or float(os.getenv("VERIS_MOCK_TIMEOUT", "300.0"))
|
|
26
|
-
self._base_url = base_url
|
|
27
30
|
|
|
28
31
|
@property
|
|
29
32
|
def base_url(self) -> str:
|
|
@@ -31,7 +34,12 @@ class SimulatorAPIClient:
|
|
|
31
34
|
return self._get_base_url()
|
|
32
35
|
|
|
33
36
|
def _get_base_url(self) -> str:
|
|
34
|
-
"""Resolve the base URL from environment.
|
|
37
|
+
"""Resolve the base URL from context, environment, or default.
|
|
38
|
+
|
|
39
|
+
Priority order:
|
|
40
|
+
1. Context variable (for per-request multi-tenant scenarios)
|
|
41
|
+
2. VERIS_API_URL environment variable
|
|
42
|
+
3. Default production URL
|
|
35
43
|
|
|
36
44
|
Behavior:
|
|
37
45
|
- If VERIS_API_URL is unset, default to the dev simulator URL.
|
|
@@ -39,7 +47,9 @@ class SimulatorAPIClient:
|
|
|
39
47
|
(do not fall back). This supports tests expecting connection
|
|
40
48
|
failures when an invalid endpoint is provided.
|
|
41
49
|
"""
|
|
42
|
-
|
|
50
|
+
# Priority: context > env var > default
|
|
51
|
+
context_url = _base_url_context.get()
|
|
52
|
+
return context_url or os.getenv("VERIS_API_URL") or "https://simulator.api.veris.ai"
|
|
43
53
|
|
|
44
54
|
def _build_headers(self) -> dict[str, str] | None:
|
|
45
55
|
"""Build headers including OpenTelemetry tracing and API key."""
|
|
@@ -107,7 +117,7 @@ def get_api_client() -> SimulatorAPIClient:
|
|
|
107
117
|
return _api_client
|
|
108
118
|
|
|
109
119
|
|
|
110
|
-
def set_api_client_params(
|
|
120
|
+
def set_api_client_params(timeout: float | None = None) -> None:
|
|
111
121
|
"""Set the global API client instance for testing purposes."""
|
|
112
122
|
global _api_client # noqa: PLW0603
|
|
113
|
-
_api_client = SimulatorAPIClient(
|
|
123
|
+
_api_client = SimulatorAPIClient(timeout=timeout)
|
veris_ai/tool_mock.py
CHANGED
|
@@ -16,7 +16,7 @@ from typing import (
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
from veris_ai.models import ResponseExpectation, ToolCallOptions
|
|
19
|
-
from veris_ai.api_client import
|
|
19
|
+
from veris_ai.api_client import _base_url_context, get_api_client
|
|
20
20
|
from veris_ai.utils import (
|
|
21
21
|
convert_to_type,
|
|
22
22
|
execute_callback,
|
|
@@ -93,7 +93,7 @@ class VerisSDK:
|
|
|
93
93
|
self._set_session_id(token_data["session_id"])
|
|
94
94
|
self._set_thread_id(token_data["thread_id"])
|
|
95
95
|
if token_data.get("api_url"):
|
|
96
|
-
|
|
96
|
+
_base_url_context.set(token_data["api_url"])
|
|
97
97
|
logger.info(
|
|
98
98
|
f"Session ID set to {token_data['session_id']}, "
|
|
99
99
|
f"Thread ID set to {token_data['thread_id']} - mocking enabled"
|
|
@@ -144,10 +144,11 @@ class VerisSDK:
|
|
|
144
144
|
_thread_id_context.set(None)
|
|
145
145
|
|
|
146
146
|
def clear_context(self) -> None:
|
|
147
|
-
"""Clear the session_id and
|
|
147
|
+
"""Clear the session_id, thread_id, and base_url from context variables."""
|
|
148
148
|
self._clear_session_id()
|
|
149
149
|
self._clear_thread_id()
|
|
150
|
-
|
|
150
|
+
_base_url_context.set(None)
|
|
151
|
+
logger.info("Session ID, Thread ID, and Base URL cleared - mocking disabled")
|
|
151
152
|
|
|
152
153
|
def clear_session_id(self) -> None:
|
|
153
154
|
"""DEPRECATED: Use clear_context() instead."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veris-ai
|
|
3
|
-
Version: 1.14.
|
|
3
|
+
Version: 1.14.2
|
|
4
4
|
Summary: A Python package for Veris AI tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
veris_ai/README.md,sha256=Mxg9fyNt6hFkQaFBYZq85Kw9akw4cN2uu6j_mXZtNCs,3871
|
|
2
2
|
veris_ai/__init__.py,sha256=enl_gEa6BQAjWvzCtsn_hFVJVVlJZ_dMsLL--E5W3nU,1907
|
|
3
3
|
veris_ai/agents_wrapper.py,sha256=gLUd_0TyCVsqqilQLvsSJIpsU5uu2CdjjWOQ4QJjoJk,12786
|
|
4
|
-
veris_ai/api_client.py,sha256=
|
|
4
|
+
veris_ai/api_client.py,sha256=LevQnX9oK4wU1ehXUJiBxoJAkgnrZi1dQf88PkQfLRM,5040
|
|
5
5
|
veris_ai/models.py,sha256=xKeheSJQle2tBeJG1DsGJzMDwv24p5jECjX6RAa39n4,495
|
|
6
6
|
veris_ai/observability.py,sha256=eSIXmk6fpOAoWM-sDbsvzyUASh1ZwU6tRIPduy09RxY,4206
|
|
7
|
-
veris_ai/tool_mock.py,sha256=
|
|
7
|
+
veris_ai/tool_mock.py,sha256=D3a-w5j8_3oFALZYCSXkBGqxCeF0JUSULypjNbPQXjo,25153
|
|
8
8
|
veris_ai/utils.py,sha256=qwPPxS0CrsS36OoN_924hricz9jGRXx9FSDgLok0wgY,18940
|
|
9
9
|
veris_ai/jaeger_interface/README.md,sha256=kd9rKcE5xf3EyNaiHu0tjn-0oES9sfaK6Ih-OhhTyCM,2821
|
|
10
10
|
veris_ai/jaeger_interface/__init__.py,sha256=KD7NSiMYRG_2uF6dOLKkGG5lNQe4K9ptEwucwMT4_aw,1128
|
|
11
11
|
veris_ai/jaeger_interface/client.py,sha256=yJrh86wRR0Dk3Gq12DId99WogcMIVbL0QQFqVSevvlE,8772
|
|
12
12
|
veris_ai/jaeger_interface/models.py,sha256=e64VV6IvOEFuzRUgvDAMQFyOZMRb56I-PUPZLBZ3rX0,1864
|
|
13
|
-
veris_ai-1.14.
|
|
14
|
-
veris_ai-1.14.
|
|
15
|
-
veris_ai-1.14.
|
|
16
|
-
veris_ai-1.14.
|
|
13
|
+
veris_ai-1.14.2.dist-info/METADATA,sha256=UbnAoKMupmF6CyK_D32FWZJLAyGtwYdDWCR4bIwoq8M,16684
|
|
14
|
+
veris_ai-1.14.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
+
veris_ai-1.14.2.dist-info/licenses/LICENSE,sha256=2g4i20atAgtD5einaKzhQrIB-JrPhyQgD3bC0wkHcCI,1065
|
|
16
|
+
veris_ai-1.14.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|