https://www.boundaryml.com logo
🟡 PDF Type Validation Error in Python using Pydan...
# questions
a
Hi community, I am currently trying to implement pdf type multimodality an application (I am working on python), I have a standard class encapsulate the user prompt, file or other type send, and I add the pdf type for the options To focus on the problem I will resume this like
Copy code
class TestPdfWrapper {
  content pdf
}
My main problem, is that if I try to pass the content like the following statements ——
Copy code
pdf_data = Pdf.from_base64(base64=amazing_user_pdf_file_on_base_64)

TestPdfWrapper(
    content= pdf_data
)
— I get a multiple validation errors by pydantic
Copy code
File —— line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for TestPdfWrapper
content.model-fields
  Input should be a valid dictionary or instance of Model [type=model_type, input_value=BamlPdfPy(base64=JVBERi0x...ia_type=application/pdf), input_type=BamlPdfPy]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
content.model-fields
  Input should be a valid dictionary or instance of Model [type=model_type, input_value=BamlPdfPy(base64=JVBERi0x...ia_type=application/pdf), input_type=BamlPdfPy]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
———— I already check the baml_cli type for the wrapper and seems to be right: —
Copy code
class TestPdfWrapper(BaseModel):
    content: baml_py.Pdf
— I also tested, by creating a baml function that directly ask for a pdf and not a type with a pdf inside: —-
function TestPdfType(description: pdf) -> string{…}
—- And it actually worked, but… for future purposes I will need to be able to handle the pdf type on the class Am I doing something wrong? I there any other way to handle this type?
v
what version of python and pydantic are you using by chance?
and thanks for reporting this, I think i know what might be the issue here, i think pydantic may not like the
baml_py.Pdf
type for some reason. We had to do some work for the
baml_py.Image
types and i had thought we did that on the
Pdf
types as well
but i think we might have accidentally missed that!
I'll double check in the AM and confirm shortly!
we should be able to get a resolution out by this tuesday's release regardless!
a
Hi, I am currently using python 3.13.5 and pydantic 2.11.7 . Thanks for the support : )
e
@andreyhabla Currently working on fixing this, it turns out we only had Image types implemented.
a
Amazing!! Thx : )
a
this should be out in 0.205.0
2 Views