Spaces:
Runtime error
Runtime error
Download dev-agent/app/validators/tool_validator.py from BeastGokul/MVP: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/tool_validator.py
- Command line
-
hf download hf://spaces/BeastGokul/MVP/dev-agent/app/validators/tool_validator.py
-
curl -L -o tool_validator.py https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/tool_validator.py
1.58 kB
| from ..schemas.agent_spec import AgentSpec | |
| from ..schemas.conversation import ValidationError, ValidationResult | |
| class ToolValidator: | |
| def validate(self, spec: AgentSpec) -> ValidationResult: | |
| errors = [] | |
| tool_names = {t.name for t in spec.tools} | |
| for step in spec.steps: | |
| if step.action in ("tool_call", "call_tool"): | |
| tool_name = step.input.get("tool_name") or step.input.get("tool") | |
| if not tool_name: | |
| errors.append(ValidationError( | |
| code="INVALID_TOOL_CALL", | |
| message=f"Step '{step.id}' of action '{step.action}' must specify 'tool_name' or 'tool' in its input config", | |
| path=f"steps.{step.id}.input" | |
| )) | |
| elif tool_name not in tool_names: | |
| errors.append(ValidationError( | |
| code="MISSING_TOOL", | |
| message=f"Step '{step.id}' references tool '{tool_name}' which is not defined in the tools list", | |
| path=f"steps.{step.id}.input.tool_name" | |
| )) | |
| # Check for duplicate tool names | |
| all_tool_names = [t.name for t in spec.tools] | |
| if len(all_tool_names) != len(set(all_tool_names)): | |
| errors.append(ValidationError( | |
| code="DUPLICATE_TOOL", | |
| message="Duplicate tool names found in tools list", | |
| path="tools" | |
| )) | |
| return ValidationResult(valid=len(errors) == 0, errors=errors) | |