Skip to content

PDFBase64Content

Base classes

Name Children Inherits
BasePDFContent
llmling_agent.models.content
Base for PDF document content.

⋔ Inheritance diagram

graph TD
  94237904279728["content.PDFBase64Content"]
  94237904270768["content.BasePDFContent"]
  94237904272160["content.BaseContent"]
  94237875526560["schema.Schema"]
  94237863989056["main.BaseModel"]
  139906220169696["builtins.object"]
  94237904270768 --> 94237904279728
  94237904272160 --> 94237904270768
  94237875526560 --> 94237904272160
  94237863989056 --> 94237875526560
  139906220169696 --> 94237863989056

🛈 DocStrings

Bases: BasePDFContent

PDF from base64 data.

Source code in src/llmling_agent/models/content.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
class PDFBase64Content(BasePDFContent):
    """PDF from base64 data."""

    type: Literal["pdf_base64"] = Field("pdf_base64", init=False)
    """Base64-data based PDF."""

    data: str
    """Base64-encoded PDF data."""

    @classmethod
    def from_bytes(
        cls,
        data: bytes,
        *,
        detail: DetailLevel | None = None,
        description: str | None = None,
    ) -> Self:
        """Create PDF content from raw bytes."""
        content = base64.b64encode(data).decode()
        return cls(data=content, detail=detail, description=description)

    def to_pydantic_ai(self) -> BinaryContent:
        binary_data = base64.b64decode(self.data)
        return BinaryContent(binary_data, media_type="application/pdf")

data instance-attribute

data: str

Base64-encoded PDF data.

type class-attribute instance-attribute

type: Literal['pdf_base64'] = Field('pdf_base64', init=False)

Base64-data based PDF.

from_bytes classmethod

from_bytes(
    data: bytes, *, detail: DetailLevel | None = None, description: str | None = None
) -> Self

Create PDF content from raw bytes.

Source code in src/llmling_agent/models/content.py
204
205
206
207
208
209
210
211
212
213
214
@classmethod
def from_bytes(
    cls,
    data: bytes,
    *,
    detail: DetailLevel | None = None,
    description: str | None = None,
) -> Self:
    """Create PDF content from raw bytes."""
    content = base64.b64encode(data).decode()
    return cls(data=content, detail=detail, description=description)

Show source on GitHub