Skip to content

Commit b5c8ded

Browse files
committed
refactor: applied review suggestions
1 parent 35569cf commit b5c8ded

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/rai_bench/rai_bench/tool_calling_agent/mocked_tools.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def validate_with_custom(self, service_type: str, args: Dict[str, Any]):
365365
try:
366366
model.model_validate(args)
367367
except ValidationError as e:
368-
raise ValueError(f"Pydantic validation failed: {e}")
368+
raise ValueError(f"Pydantic validation failed: {e}") from e
369369

370370
def validate(self, service_type: str, args: Dict[str, Any]):
371371
"""
@@ -380,7 +380,7 @@ def validate(self, service_type: str, args: Dict[str, Any]):
380380
if service_type in self.custom_models:
381381
self.validate_with_custom(service_type, args)
382382
else:
383-
return self.validate_with_ros2(service_type, args)
383+
self.validate_with_ros2(service_type, args)
384384

385385

386386
class MockCallROS2ServiceTool(CallROS2ServiceTool):
@@ -402,6 +402,18 @@ def _run(
402402
service_args: Optional[Dict[str, Any]] = None,
403403
timeout_sec: float = 1.0,
404404
) -> str:
405+
"""
406+
Execute the mocked ROS2 service call with validation of service type and its args.
407+
408+
Parameters
409+
----------
410+
service_name : str
411+
Name of the service to call
412+
service_type : str
413+
Type of the service
414+
service_args : Optional[Dict[str, Any]], optional
415+
Arguments for the service call, by default None
416+
"""
405417
if service_name not in self.available_services:
406418
raise ValueError(
407419
f"Service {service_name} is not available within {timeout_sec} seconds. Check if the service exists."

0 commit comments

Comments
 (0)