Spaces:
Runtime error
Runtime error
Download dev-agent/app/validators/schema_validator.py from BeastGokul/MVP: direct link, hf CLI and curl.
- Browser
- Download file 997 Bytes
-
https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/schema_validator.py
- Command line
-
hf download hf://spaces/BeastGokul/MVP/dev-agent/app/validators/schema_validator.py
-
curl -L -o schema_validator.py https://huggingface.co/spaces/BeastGokul/MVP/resolve/main/dev-agent/app/validators/schema_validator.py
997 Bytes
| import pydantic | |
| from typing import List | |
| from ..schemas.agent_spec import AgentSpec | |
| from ..schemas.conversation import ValidationError, ValidationResult | |
| class SchemaValidator: | |
| def validate(self, spec_dict: dict) -> ValidationResult: | |
| errors = [] | |
| try: | |
| AgentSpec.model_validate(spec_dict) | |
| except pydantic.ValidationError as e: | |
| for err in e.errors(): | |
| loc_path = ".".join(str(loc) for loc in err.get("loc", [])) | |
| errors.append(ValidationError( | |
| code="SCHEMA_VALIDATION_FAILED", | |
| message=f"{loc_path}: {err.get('msg')}" if loc_path else err.get('msg'), | |
| path=loc_path or None | |
| )) | |
| except Exception as e: | |
| errors.append(ValidationError( | |
| code="SCHEMA_VALIDATION_FAILED", | |
| message=str(e), | |
| path=None | |
| )) | |
| return ValidationResult(valid=len(errors) == 0, errors=errors) | |