- Issue created by @marcus_johansson
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
In this issue, I showed how you can create a value object and validate it using Symfony Validator. It's a pretty clean solution IMO. ๐ Create an 'embedding' object that can be validated Active
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Some example code:
Create a plain old value object with some constraint attributes:
use Symfony\Component\Validator\Constraints as Assert; class Embedding { public function __construct( #[Assert\Regex( pattern: '/^[A-Za-z0-9_-]+:[A-Za-z0-9_-]+$/', message: 'Id should be in the format "prefix:suffix"', )] readonly public string $id, #[Assert\NotBlank(message: 'Values should not be empty')] public array $values, #[Assert\NotBlank(message: 'Metadata should not be empty')] protected array $metadata, ) {}
Create a Symfony validator that looks for the attributes:
$validator = \Symfony\Component\Validator\Validation::createValidatorBuilder() ->enableAttributeMapping() ->getValidator();
Validate the object:
$embedding = new Embedding( 'model1:embedding1', [0.1, 0.2, 0.3], ['source' => 'test'] ); /** @var \Symfony\Component\Validator\ConstraintViolationListInterface $violations */ $violations = $validator->validate($embedding);
- ๐ฉ๐ชGermany marcus_johansson
I think we can add symfony validation, on the inputs. The major issue is that there is no way to assert a json-schema asfaik? The question is if we should also add that validation here, if we are doing validation?
The provider usually responds with a human readable error message that gets logged, but it would be nice to be consistent.
It would add an external library, but going forward structured outputs will play a big role in ECA, Agent outputs and most likely Automators.
- Merge request !873Add StructuredOutputSchema DTO and improve ChatInput validation. โ (Open) created by abhisekmazumdar