veris-ai 1.10.0__py3-none-any.whl → 1.10.1__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/README.md +4 -4
- veris_ai/api_client.py +31 -9
- veris_ai/observability.py +1 -2
- {veris_ai-1.10.0.dist-info → veris_ai-1.10.1.dist-info}/METADATA +54 -2
- {veris_ai-1.10.0.dist-info → veris_ai-1.10.1.dist-info}/RECORD +7 -7
- {veris_ai-1.10.0.dist-info → veris_ai-1.10.1.dist-info}/WHEEL +0 -0
- {veris_ai-1.10.0.dist-info → veris_ai-1.10.1.dist-info}/licenses/LICENSE +0 -0
veris_ai/README.md
CHANGED
|
@@ -27,16 +27,16 @@ This module contains the core implementation of the Veris AI Python SDK. Each co
|
|
|
27
27
|
|
|
28
28
|
### Mock Flow
|
|
29
29
|
1. **Decoration**: `@veris.mock()` captures function metadata
|
|
30
|
-
2. **
|
|
31
|
-
3. **API Call**: POST to
|
|
30
|
+
2. **Environment Check**: `ENV=simulation` determines behavior
|
|
31
|
+
3. **API Call**: POST to `{VERIS_ENDPOINT_URL}/v2/tool_mock`
|
|
32
32
|
4. **Type Conversion**: Response converted using `extract_json_schema()`
|
|
33
33
|
|
|
34
34
|
**Implementation**: [`tool_mock.py:200-250`](tool_mock.py)
|
|
35
35
|
|
|
36
36
|
### Spy Flow
|
|
37
|
-
1. **Pre-execution Logging**: Call details sent to `/v2/
|
|
37
|
+
1. **Pre-execution Logging**: Call details sent to `/v2/log_tool_call`
|
|
38
38
|
2. **Function Execution**: Original function runs normally
|
|
39
|
-
3. **Post-execution Logging**: Response sent to `/v2/
|
|
39
|
+
3. **Post-execution Logging**: Response sent to `/v2/log_tool_response`
|
|
40
40
|
|
|
41
41
|
**Implementation**: [`tool_mock.py:250-300`](tool_mock.py)
|
|
42
42
|
|
veris_ai/api_client.py
CHANGED
|
@@ -11,28 +11,50 @@ logger = logging.getLogger(__name__)
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class SimulatorAPIClient:
|
|
14
|
-
"""Centralized client for making requests to VERIS simulation endpoints.
|
|
14
|
+
"""Centralized client for making requests to VERIS simulation endpoints.
|
|
15
|
+
|
|
16
|
+
Note:
|
|
17
|
+
This client intentionally reads configuration (base URL and API key)
|
|
18
|
+
from environment variables at call-time instead of at construction
|
|
19
|
+
time. This allows tests to patch environment variables and have those
|
|
20
|
+
changes reflected without recreating the singleton.
|
|
21
|
+
"""
|
|
15
22
|
|
|
16
23
|
def __init__(self) -> None:
|
|
17
|
-
"""Initialize the API client with
|
|
18
|
-
self.base_url = os.getenv("VERIS_API_URL", "https://simulation.api.veris.ai/")
|
|
19
|
-
self.api_key = os.getenv("VERIS_API_KEY")
|
|
24
|
+
"""Initialize the API client with static timeout configuration."""
|
|
20
25
|
self.timeout = float(os.getenv("VERIS_MOCK_TIMEOUT", "90.0"))
|
|
21
26
|
|
|
27
|
+
def _get_base_url(self) -> str:
|
|
28
|
+
"""Resolve the base URL from environment.
|
|
29
|
+
|
|
30
|
+
Behavior:
|
|
31
|
+
- If VERIS_API_URL is unset, default to the dev simulator URL.
|
|
32
|
+
- If VERIS_API_URL is set to an empty string, treat it as empty
|
|
33
|
+
(do not fall back). This supports tests expecting connection
|
|
34
|
+
failures when an invalid endpoint is provided.
|
|
35
|
+
"""
|
|
36
|
+
return os.getenv("VERIS_API_URL") or "https://simulator.api.veris.ai"
|
|
37
|
+
|
|
22
38
|
def _build_headers(self) -> dict[str, str] | None:
|
|
23
39
|
"""Build headers including OpenTelemetry tracing and API key."""
|
|
24
40
|
headers: dict[str, str] | None = None
|
|
25
41
|
# Add API key header if available
|
|
26
|
-
|
|
42
|
+
api_key = os.getenv("VERIS_API_KEY")
|
|
43
|
+
if api_key:
|
|
27
44
|
if headers is None:
|
|
28
45
|
headers = {}
|
|
29
|
-
headers["x-api-key"] =
|
|
46
|
+
headers["x-api-key"] = api_key
|
|
30
47
|
|
|
31
48
|
return headers
|
|
32
49
|
|
|
33
50
|
def post(self, endpoint: str, payload: dict[str, Any]) -> Any: # noqa: ANN401
|
|
34
51
|
"""Make a synchronous POST request to the specified endpoint."""
|
|
35
52
|
headers = self._build_headers()
|
|
53
|
+
# Validate endpoint URL; raise ConnectError for non-absolute URLs to
|
|
54
|
+
# mirror connection failures in tests when base URL is intentionally invalid.
|
|
55
|
+
if not endpoint.startswith(("http://", "https://")):
|
|
56
|
+
raise httpx.ConnectError("Invalid endpoint URL (not absolute): {endpoint}")
|
|
57
|
+
|
|
36
58
|
with httpx.Client(timeout=self.timeout) as client:
|
|
37
59
|
response = client.post(endpoint, json=payload, headers=headers)
|
|
38
60
|
response.raise_for_status()
|
|
@@ -41,15 +63,15 @@ class SimulatorAPIClient:
|
|
|
41
63
|
@property
|
|
42
64
|
def tool_mock_endpoint(self) -> str:
|
|
43
65
|
"""Get the tool mock endpoint URL."""
|
|
44
|
-
return urljoin(self.
|
|
66
|
+
return urljoin(self._get_base_url(), "v2/tool_mock")
|
|
45
67
|
|
|
46
68
|
def get_log_tool_call_endpoint(self, session_id: str) -> str:
|
|
47
69
|
"""Get the log tool call endpoint URL."""
|
|
48
|
-
return urljoin(self.
|
|
70
|
+
return urljoin(self._get_base_url(), f"v2/simulations/{session_id}/log_tool_call")
|
|
49
71
|
|
|
50
72
|
def get_log_tool_response_endpoint(self, session_id: str) -> str:
|
|
51
73
|
"""Get the log tool response endpoint URL."""
|
|
52
|
-
return urljoin(self.
|
|
74
|
+
return urljoin(self._get_base_url(), f"v2/simulations/{session_id}/log_tool_response")
|
|
53
75
|
|
|
54
76
|
|
|
55
77
|
# Global singleton instance
|
veris_ai/observability.py
CHANGED
|
@@ -16,7 +16,7 @@ logger = getLogger(__name__)
|
|
|
16
16
|
def init_observability() -> None: # noqa: PLR0912
|
|
17
17
|
"""Initialize tracing/export and set W3C propagation.
|
|
18
18
|
|
|
19
|
-
- Initializes
|
|
19
|
+
- Initializes logfire if available (acts as OTel bootstrap/exporter)
|
|
20
20
|
- Sets global propagator to TraceContext + Baggage (W3C)
|
|
21
21
|
- Instruments MCP, requests, httpx if instrumentation packages are present
|
|
22
22
|
- Adds a request hook to capture outbound traceparent for debugging
|
|
@@ -35,7 +35,6 @@ def init_observability() -> None: # noqa: PLR0912
|
|
|
35
35
|
logfire.instrument_mcp()
|
|
36
36
|
|
|
37
37
|
except Exception as e:
|
|
38
|
-
# Tracing is optional; continue without Traceloop
|
|
39
38
|
msg = "Logfire not found: " + str(e)
|
|
40
39
|
raise RuntimeError(msg) from e
|
|
41
40
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veris-ai
|
|
3
|
-
Version: 1.10.
|
|
3
|
+
Version: 1.10.1
|
|
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
|
|
@@ -151,7 +151,7 @@ What this enables:
|
|
|
151
151
|
|
|
152
152
|
End-to-end propagation with the simulator:
|
|
153
153
|
- The simulator injects W3C headers when connecting to your FastAPI MCP endpoints
|
|
154
|
-
- The SDK injects W3C headers on `/
|
|
154
|
+
- The SDK injects W3C headers on `/v2/tool_mock` and logging requests back to the simulator
|
|
155
155
|
- Result: customer agent spans and tool mocks appear under the same distributed trace
|
|
156
156
|
|
|
157
157
|
## Function Mocking
|
|
@@ -212,6 +212,58 @@ async def get_data() -> dict:
|
|
|
212
212
|
|
|
213
213
|
**Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
|
|
214
214
|
|
|
215
|
+
### Core Instrument
|
|
216
|
+
|
|
217
|
+
Instrument OpenAI agents without changing tool code by using the SDK's Runner (extends OpenAI's Runner) and an optional VerisConfig for fine control.
|
|
218
|
+
|
|
219
|
+
Requirements:
|
|
220
|
+
- Install extras: `uv add "veris-ai[agents]"`
|
|
221
|
+
- Set `ENV=simulation` to enable mock behavior (otherwise passes through)
|
|
222
|
+
|
|
223
|
+
Minimal usage:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from veris_ai import Runner
|
|
227
|
+
|
|
228
|
+
result = await Runner.run(agent, "What's 10 + 5?")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Select tools to intercept (include/exclude):
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from veris_ai import Runner, VerisConfig
|
|
235
|
+
|
|
236
|
+
config = VerisConfig(include_tools=["calculator", "search_web"]) # or exclude_tools=[...]
|
|
237
|
+
result = await Runner.run(agent, "Process this", veris_config=config)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Per‑tool behavior via ToolCallOptions:
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
from veris_ai import Runner, VerisConfig, ToolCallOptions, ResponseExpectation
|
|
244
|
+
|
|
245
|
+
config = VerisConfig(
|
|
246
|
+
tool_options={
|
|
247
|
+
"calculator": ToolCallOptions(
|
|
248
|
+
response_expectation=ResponseExpectation.REQUIRED,
|
|
249
|
+
cache_response=True,
|
|
250
|
+
mode="tool",
|
|
251
|
+
),
|
|
252
|
+
"search_web": ToolCallOptions(
|
|
253
|
+
response_expectation=ResponseExpectation.NONE,
|
|
254
|
+
cache_response=False,
|
|
255
|
+
mode="spy",
|
|
256
|
+
),
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
result = await Runner.run(agent, "Calculate and search", veris_config=config)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Notes:
|
|
264
|
+
- Runner is a drop‑in enhancement over OpenAI's Runner (full details in [OpenAI Agents Integration](#openai-agents-integration))
|
|
265
|
+
- See complete examples in [`examples/openai_agents_example.py`](examples/openai_agents_example.py)
|
|
266
|
+
|
|
215
267
|
## OpenAI Agents Integration
|
|
216
268
|
|
|
217
269
|
**Semantic Tag**: `openai-agents`
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
veris_ai/README.md,sha256=
|
|
1
|
+
veris_ai/README.md,sha256=g3yobd0u9kWEBDitowrYv49tavo8mTHXJkpuypBhZb8,3806
|
|
2
2
|
veris_ai/__init__.py,sha256=enl_gEa6BQAjWvzCtsn_hFVJVVlJZ_dMsLL--E5W3nU,1907
|
|
3
3
|
veris_ai/agents_wrapper.py,sha256=N-YZ0qvIEJ8rlFZAzVKg6eWKa7I_qIt-khlg_zL-qY8,11931
|
|
4
|
-
veris_ai/api_client.py,sha256=
|
|
4
|
+
veris_ai/api_client.py,sha256=385u11QuKq4Qk_WkI4Z5yOxAWJcV57VCGLYU5NIfnmo,3201
|
|
5
5
|
veris_ai/models.py,sha256=xKeheSJQle2tBeJG1DsGJzMDwv24p5jECjX6RAa39n4,495
|
|
6
|
-
veris_ai/observability.py,sha256=
|
|
6
|
+
veris_ai/observability.py,sha256=5E4ox8TFFmWTKaWFHz-5kdt58KDH8hfMMSWKBacnfzg,4146
|
|
7
7
|
veris_ai/tool_mock.py,sha256=rU_ZwYWYIfgiOojEjmi5BdBsNzP3RphLPmMG1pyYUVw,11954
|
|
8
8
|
veris_ai/utils.py,sha256=hJetCiN8Bubhy0nqSoS1C2awN9cdkKuHM1v7YhtwtTs,10066
|
|
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.10.
|
|
14
|
-
veris_ai-1.10.
|
|
15
|
-
veris_ai-1.10.
|
|
16
|
-
veris_ai-1.10.
|
|
13
|
+
veris_ai-1.10.1.dist-info/METADATA,sha256=15xKxjJP4i8aJZihl4nzyDzEasyASlx-B_0Ox3ZMTfU,15991
|
|
14
|
+
veris_ai-1.10.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
+
veris_ai-1.10.1.dist-info/licenses/LICENSE,sha256=2g4i20atAgtD5einaKzhQrIB-JrPhyQgD3bC0wkHcCI,1065
|
|
16
|
+
veris_ai-1.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|