veris-ai 1.12.1__tar.gz → 1.12.3__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 veris-ai might be problematic. Click here for more details.
- {veris_ai-1.12.1 → veris_ai-1.12.3}/.github/workflows/test.yml +1 -1
- veris_ai-1.12.3/CHANGELOG.md +13 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/PKG-INFO +8 -1
- {veris_ai-1.12.1 → veris_ai-1.12.3}/README.md +7 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/pyproject.toml +1 -1
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/agents_wrapper.py +15 -4
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/api_client.py +18 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/tool_mock.py +130 -4
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_agents_wrapper_simple.py +15 -4
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_mcp_protocol_server_mocked.py +8 -2
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_tool_mock.py +24 -20
- {veris_ai-1.12.1 → veris_ai-1.12.3}/uv.lock +1 -1
- veris_ai-1.12.1/CHANGELOG.md +0 -56
- {veris_ai-1.12.1 → veris_ai-1.12.3}/.cursor/rules/documentation-management.mdc +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/.github/workflows/release.yml +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/.gitignore +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/.pre-commit-config.yaml +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/CLAUDE.md +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/LICENSE +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/examples/README.md +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/examples/__init__.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/examples/import_options.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/examples/openai_agents_example.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/README.md +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/__init__.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/jaeger_interface/README.md +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/jaeger_interface/__init__.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/jaeger_interface/client.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/jaeger_interface/models.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/models.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/observability.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/src/veris_ai/utils.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/README.md +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/__init__.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/conftest.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/fixtures/__init__.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/fixtures/http_server.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/fixtures/simple_app.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_agents_wrapper_extract.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_helpers.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_token_decoding.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_utils.py +0 -0
- {veris_ai-1.12.1 → veris_ai-1.12.3}/tests/test_veris_runner_tool_options.py +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## v0.1.1 (2025-04-17)
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- Updates to package for publishing ([#1](https://github.com/veris-ai/veris-python-sdk/pull/1),
|
|
13
|
+
[`c6f460e`](https://github.com/veris-ai/veris-python-sdk/commit/c6f460ea6e2f8472c120370a14f67f1d8c28626c))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veris-ai
|
|
3
|
-
Version: 1.12.
|
|
3
|
+
Version: 1.12.3
|
|
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
|
|
@@ -41,6 +41,13 @@ Description-Content-Type: text/markdown
|
|
|
41
41
|
|
|
42
42
|
# Veris AI Python SDK
|
|
43
43
|
|
|
44
|
+
[](https://badge.fury.io/py/veris-ai)
|
|
45
|
+
[](https://pypi.org/project/veris-ai/)
|
|
46
|
+
[](https://pepy.tech/project/veris-ai)
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
[](https://github.com/veris-ai/veris-python-sdk/actions/workflows/test.yml)
|
|
49
|
+
[](https://github.com/astral-sh/ruff)
|
|
50
|
+
|
|
44
51
|
For more information visit us at https://veris.ai
|
|
45
52
|
|
|
46
53
|
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Veris AI Python SDK
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/py/veris-ai)
|
|
4
|
+
[](https://pypi.org/project/veris-ai/)
|
|
5
|
+
[](https://pepy.tech/project/veris-ai)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/veris-ai/veris-python-sdk/actions/workflows/test.yml)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
|
|
3
10
|
For more information visit us at https://veris.ai
|
|
4
11
|
|
|
5
12
|
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""OpenAI Agents wrapper for automatic tool mocking via Veris SDK."""
|
|
2
2
|
|
|
3
|
+
import inspect
|
|
3
4
|
import json
|
|
4
5
|
import logging
|
|
5
6
|
from collections.abc import Callable
|
|
@@ -9,7 +10,7 @@ from agents import RunContextWrapper, RunResult, Runner as OpenAIRunner
|
|
|
9
10
|
from pydantic import BaseModel
|
|
10
11
|
|
|
11
12
|
from veris_ai import veris
|
|
12
|
-
from veris_ai.tool_mock import mock_tool_call
|
|
13
|
+
from veris_ai.tool_mock import mock_tool_call, mock_tool_call_async
|
|
13
14
|
from veris_ai.models import ToolCallOptions
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
@@ -83,14 +84,26 @@ def _wrap(
|
|
|
83
84
|
) -> Any: # noqa: ANN401
|
|
84
85
|
"""Wrapped on_invoke_tool that intercepts the tool function."""
|
|
85
86
|
session_id = veris.session_id
|
|
87
|
+
thread_id = veris.thread_id
|
|
86
88
|
the_func = tool_functions.get(tool_id)
|
|
87
89
|
if the_func and session_id:
|
|
88
|
-
#
|
|
90
|
+
# Check if async or sync, call appropriate version
|
|
91
|
+
if inspect.iscoroutinefunction(the_func):
|
|
92
|
+
# Use async version (non-blocking)
|
|
93
|
+
return await mock_tool_call_async(
|
|
94
|
+
the_func,
|
|
95
|
+
session_id,
|
|
96
|
+
json.loads(parameters),
|
|
97
|
+
tool_options.get(tool_name_inner),
|
|
98
|
+
thread_id=thread_id,
|
|
99
|
+
)
|
|
100
|
+
# Use sync version for sync functions
|
|
89
101
|
return mock_tool_call(
|
|
90
102
|
the_func,
|
|
91
103
|
session_id,
|
|
92
104
|
json.loads(parameters),
|
|
93
105
|
tool_options.get(tool_name_inner),
|
|
106
|
+
thread_id=thread_id,
|
|
94
107
|
)
|
|
95
108
|
# Fall back to original if we couldn't extract the function
|
|
96
109
|
return await orig_invoke(ctx, parameters)
|
|
@@ -189,8 +202,6 @@ def _find_user_function_in_closure(closure: tuple) -> Callable | None:
|
|
|
189
202
|
Returns:
|
|
190
203
|
The user function if found, None otherwise
|
|
191
204
|
"""
|
|
192
|
-
import inspect
|
|
193
|
-
|
|
194
205
|
# List of module prefixes that indicate library/framework code
|
|
195
206
|
library_modules = ("json", "inspect", "agents", "pydantic", "openai", "typing")
|
|
196
207
|
|
|
@@ -60,6 +60,24 @@ class SimulatorAPIClient:
|
|
|
60
60
|
response.raise_for_status()
|
|
61
61
|
return response.json() if response.content else None
|
|
62
62
|
|
|
63
|
+
async def post_async(self, endpoint: str, payload: dict[str, Any]) -> Any: # noqa: ANN401
|
|
64
|
+
"""Make an asynchronous POST request to the specified endpoint.
|
|
65
|
+
|
|
66
|
+
This method uses httpx.AsyncClient and is safe to call from async functions
|
|
67
|
+
without blocking the event loop.
|
|
68
|
+
"""
|
|
69
|
+
headers = self._build_headers()
|
|
70
|
+
# Validate endpoint URL; raise ConnectError for non-absolute URLs to
|
|
71
|
+
# mirror connection failures in tests when base URL is intentionally invalid.
|
|
72
|
+
if not endpoint.startswith(("http://", "https://")):
|
|
73
|
+
error_msg = f"Invalid endpoint URL (not absolute): {endpoint}"
|
|
74
|
+
raise httpx.ConnectError(error_msg)
|
|
75
|
+
|
|
76
|
+
async with httpx.AsyncClient(timeout=self.timeout) as client:
|
|
77
|
+
response = await client.post(endpoint, json=payload, headers=headers)
|
|
78
|
+
response.raise_for_status()
|
|
79
|
+
return response.json() if response.content else None
|
|
80
|
+
|
|
63
81
|
@property
|
|
64
82
|
def tool_mock_endpoint(self) -> str:
|
|
65
83
|
"""Get the tool mock endpoint URL."""
|
|
@@ -206,14 +206,14 @@ class VerisSDK:
|
|
|
206
206
|
return await func(*args, **kwargs)
|
|
207
207
|
parameters = get_function_parameters(func, args, kwargs)
|
|
208
208
|
logger.info(f"Spying on function: {func.__name__}")
|
|
209
|
-
|
|
209
|
+
await log_tool_call_async(
|
|
210
210
|
session_id=session_id,
|
|
211
211
|
function_name=func.__name__,
|
|
212
212
|
parameters=parameters,
|
|
213
213
|
docstring=inspect.getdoc(func) or "",
|
|
214
214
|
)
|
|
215
215
|
result = await func(*args, **kwargs)
|
|
216
|
-
|
|
216
|
+
await log_tool_response_async(session_id=session_id, response=result)
|
|
217
217
|
return result
|
|
218
218
|
|
|
219
219
|
@wraps(func)
|
|
@@ -275,7 +275,7 @@ class VerisSDK:
|
|
|
275
275
|
return await func(*args, **kwargs)
|
|
276
276
|
parameters = get_function_parameters(func, args, kwargs)
|
|
277
277
|
thread_id = _thread_id_context.get()
|
|
278
|
-
return
|
|
278
|
+
return await mock_tool_call_async(
|
|
279
279
|
func,
|
|
280
280
|
session_id,
|
|
281
281
|
parameters,
|
|
@@ -358,7 +358,7 @@ def mock_tool_call(
|
|
|
358
358
|
options: ToolCallOptions | None = None,
|
|
359
359
|
thread_id: str | None = None,
|
|
360
360
|
) -> object:
|
|
361
|
-
"""Mock tool call.
|
|
361
|
+
"""Mock tool call (synchronous).
|
|
362
362
|
|
|
363
363
|
Args:
|
|
364
364
|
func: Function being mocked
|
|
@@ -424,6 +424,84 @@ def mock_tool_call(
|
|
|
424
424
|
return convert_to_type(mock_result, return_type_obj)
|
|
425
425
|
|
|
426
426
|
|
|
427
|
+
@tenacity.retry(
|
|
428
|
+
stop=tenacity.stop_after_attempt(3),
|
|
429
|
+
wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
|
|
430
|
+
reraise=True,
|
|
431
|
+
)
|
|
432
|
+
async def mock_tool_call_async(
|
|
433
|
+
func: Callable,
|
|
434
|
+
session_id: str, # noqa: ARG001
|
|
435
|
+
parameters: dict[str, dict[str, str]],
|
|
436
|
+
options: ToolCallOptions | None = None,
|
|
437
|
+
thread_id: str | None = None,
|
|
438
|
+
) -> object:
|
|
439
|
+
"""Mock tool call (asynchronous).
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
func: Function being mocked
|
|
443
|
+
session_id: Session ID (kept for backwards compatibility, not used)
|
|
444
|
+
parameters: Function parameters
|
|
445
|
+
options: Tool call options
|
|
446
|
+
thread_id: Thread ID to use as session_id in API request (required)
|
|
447
|
+
|
|
448
|
+
Raises:
|
|
449
|
+
ValueError: If thread_id is not provided
|
|
450
|
+
"""
|
|
451
|
+
if thread_id is None:
|
|
452
|
+
raise ValueError(
|
|
453
|
+
"thread_id is required for mocking. "
|
|
454
|
+
"Use parse_token() to set both session_id and thread_id."
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
options = options or ToolCallOptions()
|
|
458
|
+
api_client = get_api_client()
|
|
459
|
+
endpoint = api_client.tool_mock_endpoint
|
|
460
|
+
|
|
461
|
+
logger.info(f"Simulating function: {func.__name__}")
|
|
462
|
+
|
|
463
|
+
type_hints = get_type_hints(func)
|
|
464
|
+
|
|
465
|
+
# Extract return type object (not just the name)
|
|
466
|
+
return_type_obj = type_hints.pop("return", Any)
|
|
467
|
+
# Get function docstring
|
|
468
|
+
docstring = inspect.getdoc(func) or ""
|
|
469
|
+
|
|
470
|
+
# Use thread_id as session_id in the payload
|
|
471
|
+
payload_session_id = thread_id
|
|
472
|
+
# Clean up parameters for V3 - just send values, not the nested dict
|
|
473
|
+
clean_params: dict[str, Any] = {}
|
|
474
|
+
for key, value in parameters.items():
|
|
475
|
+
if isinstance(value, dict) and "value" in value:
|
|
476
|
+
# Extract just the value from the nested structure
|
|
477
|
+
clean_params[key] = value["value"]
|
|
478
|
+
else:
|
|
479
|
+
# Already clean or unexpected format
|
|
480
|
+
clean_params[key] = value
|
|
481
|
+
|
|
482
|
+
# Determine response expectation
|
|
483
|
+
payload = {
|
|
484
|
+
"session_id": payload_session_id,
|
|
485
|
+
"response_expectation": options.response_expectation.value,
|
|
486
|
+
"cache_response": bool(options.cache_response),
|
|
487
|
+
"tool_call": {
|
|
488
|
+
"function_name": func.__name__,
|
|
489
|
+
"parameters": clean_params,
|
|
490
|
+
"return_type": json.dumps(extract_json_schema(return_type_obj)),
|
|
491
|
+
"docstring": docstring,
|
|
492
|
+
},
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
mock_result = await api_client.post_async(endpoint, payload)
|
|
496
|
+
logger.info(f"Mock response: {mock_result}")
|
|
497
|
+
|
|
498
|
+
if isinstance(mock_result, str):
|
|
499
|
+
with suppress(json.JSONDecodeError):
|
|
500
|
+
mock_result = json.loads(mock_result)
|
|
501
|
+
return convert_to_type(mock_result, return_type_obj)
|
|
502
|
+
return convert_to_type(mock_result, return_type_obj)
|
|
503
|
+
|
|
504
|
+
|
|
427
505
|
def log_tool_call(
|
|
428
506
|
session_id: str,
|
|
429
507
|
function_name: str,
|
|
@@ -456,6 +534,38 @@ def log_tool_call(
|
|
|
456
534
|
logger.warning(f"Failed to log tool call for {function_name}: {e}")
|
|
457
535
|
|
|
458
536
|
|
|
537
|
+
async def log_tool_call_async(
|
|
538
|
+
session_id: str,
|
|
539
|
+
function_name: str,
|
|
540
|
+
parameters: dict[str, dict[str, str]],
|
|
541
|
+
docstring: str,
|
|
542
|
+
) -> None:
|
|
543
|
+
"""Log tool call asynchronously to the VERIS logging endpoint."""
|
|
544
|
+
api_client = get_api_client()
|
|
545
|
+
endpoint = api_client.get_log_tool_call_endpoint(session_id)
|
|
546
|
+
|
|
547
|
+
# Clean up parameters for V3 - just send values, not the nested dict
|
|
548
|
+
clean_params: dict[str, Any] = {}
|
|
549
|
+
for key, value in parameters.items():
|
|
550
|
+
if isinstance(value, dict) and "value" in value:
|
|
551
|
+
# Extract just the value from the nested structure
|
|
552
|
+
clean_params[key] = value["value"]
|
|
553
|
+
else:
|
|
554
|
+
# Already clean or unexpected format
|
|
555
|
+
clean_params[key] = value
|
|
556
|
+
|
|
557
|
+
payload = {
|
|
558
|
+
"function_name": function_name,
|
|
559
|
+
"parameters": clean_params,
|
|
560
|
+
"docstring": docstring,
|
|
561
|
+
}
|
|
562
|
+
try:
|
|
563
|
+
await api_client.post_async(endpoint, payload)
|
|
564
|
+
logger.debug(f"Tool call logged for {function_name}")
|
|
565
|
+
except Exception as e:
|
|
566
|
+
logger.warning(f"Failed to log tool call for {function_name}: {e}")
|
|
567
|
+
|
|
568
|
+
|
|
459
569
|
def log_tool_response(session_id: str, response: Any) -> None: # noqa: ANN401
|
|
460
570
|
"""Log tool response synchronously to the VERIS logging endpoint."""
|
|
461
571
|
api_client = get_api_client()
|
|
@@ -472,4 +582,20 @@ def log_tool_response(session_id: str, response: Any) -> None: # noqa: ANN401
|
|
|
472
582
|
logger.warning(f"Failed to log tool response: {e}")
|
|
473
583
|
|
|
474
584
|
|
|
585
|
+
async def log_tool_response_async(session_id: str, response: Any) -> None: # noqa: ANN401
|
|
586
|
+
"""Log tool response asynchronously to the VERIS logging endpoint."""
|
|
587
|
+
api_client = get_api_client()
|
|
588
|
+
endpoint = api_client.get_log_tool_response_endpoint(session_id)
|
|
589
|
+
|
|
590
|
+
payload = {
|
|
591
|
+
"response": json.dumps(response, default=str),
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
try:
|
|
595
|
+
await api_client.post_async(endpoint, payload)
|
|
596
|
+
logger.debug("Tool response logged")
|
|
597
|
+
except Exception as e:
|
|
598
|
+
logger.warning(f"Failed to log tool response: {e}")
|
|
599
|
+
|
|
600
|
+
|
|
475
601
|
veris = VerisSDK()
|
|
@@ -87,18 +87,29 @@ def mock_veris_endpoint():
|
|
|
87
87
|
"""Fixture that mocks the veris SDK's HTTP request method."""
|
|
88
88
|
calls = []
|
|
89
89
|
|
|
90
|
-
def
|
|
91
|
-
"""Mock the
|
|
90
|
+
async def mock_request_async(endpoint, payload):
|
|
91
|
+
"""Mock the post_async method."""
|
|
92
92
|
# Record the call
|
|
93
93
|
calls.append({"endpoint": endpoint, "payload": payload})
|
|
94
94
|
|
|
95
95
|
# Return a distinctive mocked value
|
|
96
96
|
return {"result": 999}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
def mock_request_sync(endpoint, payload):
|
|
99
|
+
"""Mock the post method."""
|
|
100
|
+
# Record the call
|
|
101
|
+
calls.append({"endpoint": endpoint, "payload": payload})
|
|
102
|
+
|
|
103
|
+
# Return a distinctive mocked value
|
|
104
|
+
return {"result": 999}
|
|
105
|
+
|
|
106
|
+
# Patch both sync and async methods of the API client
|
|
99
107
|
from veris_ai.api_client import get_api_client
|
|
100
108
|
|
|
101
|
-
with
|
|
109
|
+
with (
|
|
110
|
+
patch.object(get_api_client(), "post", side_effect=mock_request_sync),
|
|
111
|
+
patch.object(get_api_client(), "post_async", side_effect=mock_request_async),
|
|
112
|
+
):
|
|
102
113
|
yield {"calls": calls}
|
|
103
114
|
|
|
104
115
|
|
|
@@ -62,10 +62,16 @@ def run_server_with_mock(server_port: int) -> None: # noqa: C901
|
|
|
62
62
|
# Return error response if something goes wrong
|
|
63
63
|
return {"error": str(e)}
|
|
64
64
|
|
|
65
|
-
# Patch the API client's post
|
|
65
|
+
# Patch the API client's post methods (both sync and async)
|
|
66
66
|
from veris_ai.api_client import get_api_client
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
async def mock_post_async(endpoint, payload):
|
|
69
|
+
return mock_post(endpoint, payload)
|
|
70
|
+
|
|
71
|
+
with (
|
|
72
|
+
patch.object(get_api_client(), "post", side_effect=mock_post),
|
|
73
|
+
patch.object(get_api_client(), "post_async", side_effect=mock_post_async),
|
|
74
|
+
):
|
|
69
75
|
# Configure the server
|
|
70
76
|
fastapi = make_simple_fastapi_app()
|
|
71
77
|
veris.set_fastapi_mcp(
|
|
@@ -37,7 +37,7 @@ async def test_mock_decorator_simulation_mode(simulation_env):
|
|
|
37
37
|
|
|
38
38
|
mock_response = {"result": {"mocked": True}}
|
|
39
39
|
|
|
40
|
-
with patch.object(get_api_client(), "
|
|
40
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response):
|
|
41
41
|
result = await test_func("test", 42)
|
|
42
42
|
assert result == {"result": {"mocked": True}}
|
|
43
43
|
|
|
@@ -60,7 +60,7 @@ async def test_mock_with_context(simulation_env):
|
|
|
60
60
|
|
|
61
61
|
mock_response = {"result": {"mocked": True}}
|
|
62
62
|
|
|
63
|
-
with patch.object(get_api_client(), "
|
|
63
|
+
with patch.object(get_api_client(), "post_async") as mock_request:
|
|
64
64
|
mock_request.return_value = mock_response
|
|
65
65
|
token = create_test_token("test-session-id", "test-thread-id")
|
|
66
66
|
veris.parse_token(token)
|
|
@@ -98,7 +98,9 @@ async def test_mock_http_error(simulation_env):
|
|
|
98
98
|
return {"result": "real"}
|
|
99
99
|
|
|
100
100
|
with (
|
|
101
|
-
patch.object(
|
|
101
|
+
patch.object(
|
|
102
|
+
get_api_client(), "post_async", side_effect=httpx.HTTPError("Mock HTTP Error")
|
|
103
|
+
),
|
|
102
104
|
pytest.raises(httpx.HTTPError),
|
|
103
105
|
):
|
|
104
106
|
await test_func("test")
|
|
@@ -147,7 +149,7 @@ async def test_mock_string_json_response(simulation_env):
|
|
|
147
149
|
|
|
148
150
|
mock_response = {"result": '{"key": "value"}'}
|
|
149
151
|
|
|
150
|
-
with patch.object(get_api_client(), "
|
|
152
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response):
|
|
151
153
|
result = await test_func()
|
|
152
154
|
assert result == {"result": '{"key": "value"}'}
|
|
153
155
|
|
|
@@ -192,12 +194,14 @@ async def test_context_var_persistence_in_call(simulation_env):
|
|
|
192
194
|
|
|
193
195
|
mock_response = {"result": {"mocked": True}}
|
|
194
196
|
|
|
195
|
-
def mock_request_func(endpoint, payload):
|
|
197
|
+
async def mock_request_func(endpoint, payload):
|
|
196
198
|
# Capture session_id during HTTP call
|
|
197
199
|
captured_session_ids.append(veris.session_id)
|
|
198
200
|
return mock_response
|
|
199
201
|
|
|
200
|
-
with patch.object(
|
|
202
|
+
with patch.object(
|
|
203
|
+
get_api_client(), "post_async", side_effect=mock_request_func
|
|
204
|
+
) as mock_request:
|
|
201
205
|
# Set session_id and call function
|
|
202
206
|
token = create_test_token("test-session-123", "test-thread-123")
|
|
203
207
|
veris.parse_token(token)
|
|
@@ -268,10 +272,10 @@ async def test_spy_decorator_with_session(simulation_env):
|
|
|
268
272
|
"""A test function that returns a dict."""
|
|
269
273
|
return {"value": x, "message": y}
|
|
270
274
|
|
|
271
|
-
# Mock the logging functions
|
|
275
|
+
# Mock the async logging functions
|
|
272
276
|
with (
|
|
273
|
-
patch("veris_ai.tool_mock.
|
|
274
|
-
patch("veris_ai.tool_mock.
|
|
277
|
+
patch("veris_ai.tool_mock.log_tool_call_async") as mock_log_call,
|
|
278
|
+
patch("veris_ai.tool_mock.log_tool_response_async") as mock_log_response,
|
|
275
279
|
):
|
|
276
280
|
token = create_test_token("spy-session-123")
|
|
277
281
|
veris.parse_token(token)
|
|
@@ -307,8 +311,8 @@ async def test_spy_decorator_without_session():
|
|
|
307
311
|
veris.clear_context()
|
|
308
312
|
|
|
309
313
|
with (
|
|
310
|
-
patch("veris_ai.tool_mock.
|
|
311
|
-
patch("veris_ai.tool_mock.
|
|
314
|
+
patch("veris_ai.tool_mock.log_tool_call_async") as mock_log_call,
|
|
315
|
+
patch("veris_ai.tool_mock.log_tool_response_async") as mock_log_response,
|
|
312
316
|
):
|
|
313
317
|
result = await test_func(21)
|
|
314
318
|
|
|
@@ -407,8 +411,8 @@ async def test_spy_decorator_with_exception():
|
|
|
407
411
|
return x * 2
|
|
408
412
|
|
|
409
413
|
with (
|
|
410
|
-
patch("veris_ai.tool_mock.
|
|
411
|
-
patch("veris_ai.tool_mock.
|
|
414
|
+
patch("veris_ai.tool_mock.log_tool_call_async") as mock_log_call,
|
|
415
|
+
patch("veris_ai.tool_mock.log_tool_response_async") as mock_log_response,
|
|
412
416
|
):
|
|
413
417
|
token = create_test_token("exception-spy-session")
|
|
414
418
|
veris.parse_token(token)
|
|
@@ -525,7 +529,7 @@ async def test_mock_decorator_tool_mode(simulation_env):
|
|
|
525
529
|
|
|
526
530
|
mock_response = {"result": "mocked"}
|
|
527
531
|
|
|
528
|
-
with patch.object(get_api_client(), "
|
|
532
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response):
|
|
529
533
|
result = await test_func()
|
|
530
534
|
assert result == {"result": "mocked"}
|
|
531
535
|
|
|
@@ -540,7 +544,7 @@ async def test_mock_decorator_function_mode(simulation_env):
|
|
|
540
544
|
|
|
541
545
|
mock_response = {"mocked": True, "data": [1, 2, 3]}
|
|
542
546
|
|
|
543
|
-
with patch.object(get_api_client(), "
|
|
547
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response):
|
|
544
548
|
result = await test_func()
|
|
545
549
|
assert result == mock_response
|
|
546
550
|
|
|
@@ -555,7 +559,7 @@ async def test_mock_decorator_with_expects_response(simulation_env):
|
|
|
555
559
|
|
|
556
560
|
mock_response = {"result": {"mocked": True}}
|
|
557
561
|
|
|
558
|
-
with patch.object(get_api_client(), "
|
|
562
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response) as mock_request:
|
|
559
563
|
result = await test_func()
|
|
560
564
|
# Verify the request payload included expects_response
|
|
561
565
|
mock_request.assert_called_once()
|
|
@@ -574,7 +578,7 @@ async def test_mock_decorator_with_cache_response(simulation_env):
|
|
|
574
578
|
|
|
575
579
|
mock_response = {"result": {"cached": True}}
|
|
576
580
|
|
|
577
|
-
with patch.object(get_api_client(), "
|
|
581
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response) as mock_request:
|
|
578
582
|
result = await test_func(42)
|
|
579
583
|
# Verify the request payload included cache_response
|
|
580
584
|
mock_request.assert_called_once()
|
|
@@ -593,7 +597,7 @@ async def test_mock_decorator_all_parameters(simulation_env):
|
|
|
593
597
|
|
|
594
598
|
mock_response = {"status": "mocked", "values": [1, 2, 3]}
|
|
595
599
|
|
|
596
|
-
with patch.object(get_api_client(), "
|
|
600
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response) as mock_request:
|
|
597
601
|
result = await test_func("test", 3)
|
|
598
602
|
# Verify the request payload
|
|
599
603
|
mock_request.assert_called_once()
|
|
@@ -614,7 +618,7 @@ async def test_mock_decorator_function_mode_defaults_expects_response(simulation
|
|
|
614
618
|
|
|
615
619
|
mock_response = {"result": {"mocked": True}}
|
|
616
620
|
|
|
617
|
-
with patch.object(get_api_client(), "
|
|
621
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response) as mock_request:
|
|
618
622
|
await test_func()
|
|
619
623
|
# Verify expects_response is False for function mode by default
|
|
620
624
|
mock_request.assert_called_once()
|
|
@@ -633,7 +637,7 @@ async def test_mock_decorator_json_schema_in_payload(simulation_env):
|
|
|
633
637
|
|
|
634
638
|
mock_response = [{"mocked": True}]
|
|
635
639
|
|
|
636
|
-
with patch.object(get_api_client(), "
|
|
640
|
+
with patch.object(get_api_client(), "post_async", return_value=mock_response) as mock_request:
|
|
637
641
|
await test_func()
|
|
638
642
|
# Verify the JSON schema was included in the payload
|
|
639
643
|
mock_request.assert_called_once()
|
veris_ai-1.12.1/CHANGELOG.md
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# CHANGELOG
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## v0.2.1 (2025-04-18)
|
|
9
|
-
|
|
10
|
-
### Bug Fixes
|
|
11
|
-
|
|
12
|
-
- Fixes to type conversion for outputs
|
|
13
|
-
([`b8e8e3b`](https://github.com/veris-ai/veris-python-sdk/commit/b8e8e3bbd606654ae3c342f07f7d27c8c9fefa6d))
|
|
14
|
-
|
|
15
|
-
- Update some comment for testing
|
|
16
|
-
([`bf204e7`](https://github.com/veris-ai/veris-python-sdk/commit/bf204e711c6c54da613d2f59a64f8d90e2ba7659))
|
|
17
|
-
|
|
18
|
-
### Continuous Integration
|
|
19
|
-
|
|
20
|
-
- Separate release and publish workflows
|
|
21
|
-
([`0a2ea8b`](https://github.com/veris-ai/veris-python-sdk/commit/0a2ea8bbb393fda6ef60161ff290f37df0a2faa5))
|
|
22
|
-
|
|
23
|
-
- Update ci and warnings for semantic-release
|
|
24
|
-
([`fcbe2cc`](https://github.com/veris-ai/veris-python-sdk/commit/fcbe2cccd22821cf5760126abb6174aa1f63082f))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## v0.2.0 (2025-04-18)
|
|
28
|
-
|
|
29
|
-
### Chores
|
|
30
|
-
|
|
31
|
-
- Update changelog for 0.1.1
|
|
32
|
-
([`24d7139`](https://github.com/veris-ai/veris-python-sdk/commit/24d713943737abcea6394258e5129ae0a55cb869))
|
|
33
|
-
|
|
34
|
-
- Update semantic release config
|
|
35
|
-
([`6f745e0`](https://github.com/veris-ai/veris-python-sdk/commit/6f745e09263703cfe034ba688b96e4da50759889))
|
|
36
|
-
|
|
37
|
-
### Continuous Integration
|
|
38
|
-
|
|
39
|
-
- Add workflows for release ([#3](https://github.com/veris-ai/veris-python-sdk/pull/3),
|
|
40
|
-
[`3c160e7`](https://github.com/veris-ai/veris-python-sdk/commit/3c160e7e928ed1efb42825b767084df5d451edb5))
|
|
41
|
-
|
|
42
|
-
- Fix publish ci workflow ([#4](https://github.com/veris-ai/veris-python-sdk/pull/4),
|
|
43
|
-
[`47f23e1`](https://github.com/veris-ai/veris-python-sdk/commit/47f23e19cd04b60ab0ae087b6d70b4748350393c))
|
|
44
|
-
|
|
45
|
-
### Features
|
|
46
|
-
|
|
47
|
-
- Remove dependencies and use linter ([#2](https://github.com/veris-ai/veris-python-sdk/pull/2),
|
|
48
|
-
[`4b8c43b`](https://github.com/veris-ai/veris-python-sdk/commit/4b8c43b551265ff9c994f53d29a7ef185b7e3286))
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## v0.1.1 (2025-04-17)
|
|
52
|
-
|
|
53
|
-
### Features
|
|
54
|
-
|
|
55
|
-
- Updates to package for publishing ([#1](https://github.com/veris-ai/veris-python-sdk/pull/1),
|
|
56
|
-
[`c6f460e`](https://github.com/veris-ai/veris-python-sdk/commit/c6f460ea6e2f8472c120370a14f67f1d8c28626c))
|
|
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
|