veris-ai 1.13.0__py3-none-any.whl → 1.14.0__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/tool_mock.py CHANGED
@@ -20,10 +20,12 @@ from veris_ai.api_client import get_api_client
20
20
  from veris_ai.utils import (
21
21
  convert_to_type,
22
22
  execute_callback,
23
+ execute_combined_callback,
23
24
  extract_json_schema,
24
25
  get_function_parameters,
25
26
  get_input_parameters,
26
27
  launch_callback_task,
28
+ launch_combined_callback_task,
27
29
  )
28
30
 
29
31
  logger = logging.getLogger(__name__)
@@ -245,13 +247,14 @@ class VerisSDK:
245
247
 
246
248
  return decorator
247
249
 
248
- def mock( # noqa: C901, PLR0915
250
+ def mock( # noqa: C901, PLR0915, PLR0913
249
251
  self,
250
252
  mode: Literal["tool", "function"] = "tool",
251
253
  expects_response: bool | None = None,
252
254
  cache_response: bool | None = None,
253
255
  input_callback: Callable[..., Any] | None = None,
254
256
  output_callback: Callable[[Any], Any] | None = None,
257
+ combined_callback: Callable[..., Any] | None = None,
255
258
  ) -> Callable:
256
259
  """Decorator for mocking tool calls.
257
260
 
@@ -261,6 +264,7 @@ class VerisSDK:
261
264
  cache_response: Whether to cache the response
262
265
  input_callback: Callable that receives input parameters as individual arguments
263
266
  output_callback: Callable that receives the output value
267
+ combined_callback: Callable that receives both input parameters and mock_output
264
268
  """
265
269
  response_expectation = (
266
270
  ResponseExpectation.NONE
@@ -306,6 +310,7 @@ class VerisSDK:
306
310
  input_params = get_input_parameters(func, args, kwargs)
307
311
  launch_callback_task(input_callback, input_params, unpack=True)
308
312
  launch_callback_task(output_callback, result, unpack=False)
313
+ launch_combined_callback_task(combined_callback, input_params, result)
309
314
 
310
315
  return result
311
316
 
@@ -337,6 +342,7 @@ class VerisSDK:
337
342
  input_params = get_input_parameters(func, args, kwargs)
338
343
  execute_callback(input_callback, input_params, unpack=True)
339
344
  execute_callback(output_callback, result, unpack=False)
345
+ execute_combined_callback(combined_callback, input_params, result)
340
346
 
341
347
  return result
342
348
 
@@ -350,6 +356,7 @@ class VerisSDK:
350
356
  return_value: Any, # noqa: ANN401
351
357
  input_callback: Callable[..., Any] | None = None,
352
358
  output_callback: Callable[[Any], Any] | None = None,
359
+ combined_callback: Callable[..., Any] | None = None,
353
360
  ) -> Callable:
354
361
  """Decorator for stubbing tool calls.
355
362
 
@@ -357,6 +364,7 @@ class VerisSDK:
357
364
  return_value: The value to return when the function is stubbed
358
365
  input_callback: Callable that receives input parameters as individual arguments
359
366
  output_callback: Callable that receives the output value
367
+ combined_callback: Callable that receives both input parameters and mock_output
360
368
  """
361
369
 
362
370
  def decorator(func: Callable) -> Callable:
@@ -380,6 +388,7 @@ class VerisSDK:
380
388
  input_params = get_input_parameters(func, args, kwargs)
381
389
  launch_callback_task(input_callback, input_params, unpack=True)
382
390
  launch_callback_task(output_callback, return_value, unpack=False)
391
+ launch_combined_callback_task(combined_callback, input_params, return_value)
383
392
 
384
393
  return return_value
385
394
 
@@ -397,6 +406,7 @@ class VerisSDK:
397
406
  input_params = get_input_parameters(func, args, kwargs)
398
407
  execute_callback(input_callback, input_params, unpack=True)
399
408
  execute_callback(output_callback, return_value, unpack=False)
409
+ execute_combined_callback(combined_callback, input_params, return_value)
400
410
 
401
411
  return return_value
402
412
 
veris_ai/utils.py CHANGED
@@ -489,3 +489,75 @@ def launch_callback_task(
489
489
  except RuntimeError:
490
490
  # If no event loop is running, log a warning
491
491
  logger.warning("Cannot launch callback task: no event loop running")
492
+
493
+
494
+ def execute_combined_callback(
495
+ callback: Callable | None,
496
+ input_params: dict[str, Any],
497
+ mock_output: Any, # noqa: ANN401
498
+ ) -> None:
499
+ """Execute a combined callback synchronously with input parameters and mock output.
500
+
501
+ Args:
502
+ callback: The callback callable to execute
503
+ input_params: Dictionary of input parameters
504
+ mock_output: The output from the mock/stub call
505
+
506
+ Note:
507
+ Exceptions in callbacks are caught and logged to prevent breaking the main flow.
508
+ """
509
+ if callback is None:
510
+ return
511
+
512
+ try:
513
+ # Combine input params with mock_output
514
+ combined_data = {**input_params, "mock_output": mock_output}
515
+ # Filter parameters to match callback signature
516
+ filtered_data = filter_callback_parameters(callback, combined_data)
517
+ callback(**filtered_data)
518
+ except Exception as e:
519
+ logger.warning(f"Combined callback execution failed: {e}", exc_info=True)
520
+
521
+
522
+ def launch_combined_callback_task(
523
+ callback: Callable | None,
524
+ input_params: dict[str, Any],
525
+ mock_output: Any, # noqa: ANN401
526
+ ) -> None:
527
+ """Launch a combined callback as a background task (fire-and-forget).
528
+
529
+ Args:
530
+ callback: The callback callable to execute (can be sync or async)
531
+ input_params: Dictionary of input parameters
532
+ mock_output: The output from the mock/stub call
533
+
534
+ Note:
535
+ This launches the callback without blocking. Errors are logged but won't
536
+ affect the main execution flow.
537
+ """
538
+ if callback is None:
539
+ return
540
+
541
+ async def _run_callback() -> None:
542
+ """Wrapper to run combined callback with error handling."""
543
+ try:
544
+ # Combine input params with mock_output
545
+ combined_data = {**input_params, "mock_output": mock_output}
546
+ # Filter parameters to match callback signature
547
+ filtered_data = filter_callback_parameters(callback, combined_data)
548
+
549
+ if inspect.iscoroutinefunction(callback):
550
+ await callback(**filtered_data)
551
+ else:
552
+ result = callback(**filtered_data)
553
+ if inspect.iscoroutine(result):
554
+ await result
555
+ except Exception as e:
556
+ logger.warning(f"Combined callback execution failed: {e}", exc_info=True)
557
+
558
+ # Create task without awaiting (fire-and-forget)
559
+ try:
560
+ asyncio.create_task(_run_callback())
561
+ except RuntimeError:
562
+ # If no event loop is running, log a warning
563
+ logger.warning("Cannot launch combined callback task: no event loop running")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: veris-ai
3
- Version: 1.13.0
3
+ Version: 1.14.0
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
@@ -4,13 +4,13 @@ veris_ai/agents_wrapper.py,sha256=gLUd_0TyCVsqqilQLvsSJIpsU5uu2CdjjWOQ4QJjoJk,12
4
4
  veris_ai/api_client.py,sha256=I1XyQ7J0ZU_JK9sZjF3XqFv5gGsrdKF38euOZmW8BG0,4150
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=olb_ywR88meK_FyoDVHpVnIi0h0B9oWM5IHV7k3hcko,24240
8
- veris_ai/utils.py,sha256=2fzXcsKQGLm1Q1ntjtuC_Z5l6Atj56zQE723m3zXdGg,16357
7
+ veris_ai/tool_mock.py,sha256=uFVSMqalSrXbhG1S2BuwK5mttRui4kV48Exvsy2BHOE,24973
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.13.0.dist-info/METADATA,sha256=5yQZuNyfZdG4QiJd30nTHkwm_e2B8WRp4DbCXequnmk,16684
14
- veris_ai-1.13.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- veris_ai-1.13.0.dist-info/licenses/LICENSE,sha256=2g4i20atAgtD5einaKzhQrIB-JrPhyQgD3bC0wkHcCI,1065
16
- veris_ai-1.13.0.dist-info/RECORD,,
13
+ veris_ai-1.14.0.dist-info/METADATA,sha256=2heFuh9Ox9ok24zrdvse_dB1SF6UUOkOGbBcZXpkkP0,16684
14
+ veris_ai-1.14.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ veris_ai-1.14.0.dist-info/licenses/LICENSE,sha256=2g4i20atAgtD5einaKzhQrIB-JrPhyQgD3bC0wkHcCI,1065
16
+ veris_ai-1.14.0.dist-info/RECORD,,