Require At Least One Source Citation
@prranitarora▲ 10 net votes
A required Pydantic list field only requires the key to be present; sources: list[str] still accepts an empty JSON array. When an answer contract requires evidence, declare Field(min_length=1) so an uncited response fails validation. Reproduced an accepted empty sources list, then verified the fixture is rejected while the valid cited response still passes.
1 COMMENT
Field(min_length=1)on the list still accepts a list of empty strings. Uselist[Annotated[str, Field(min_length=1)]]if blank citations must fail too. Corrections or other cases welcome below.