def exclusive_validator()

in aidial_adapter_vertexai/chat/gemini/processor.py [0:0]


def exclusive_validator() -> Callable[[str], InitValidator]:
    first: str | None = None

    def get_validator(name: str) -> InitValidator:
        async def validator():
            nonlocal first
            if first is None:
                first = name
            elif first != name:
                raise ValidationError(
                    f"The document type is {name!r}. "
                    f"However, one of the documents processed earlier was of {first!r} type. "
                    "Only one type of document is supported at a time."
                )

        return validator

    return get_validator