Skip to content

UserDocumentPrompt

🛈 DocStrings

A user prompt containing a base64-encoded PDF document.

Source code in src/clawd_code_sdk/models/prompts.py
@dataclass
class UserDocumentPrompt:
    """A user prompt containing a base64-encoded PDF document."""

    document_data: str
    """Base64-encoded PDF data."""
    media_type: DocumentMediaType = "application/pdf"
    """MIME type of the document."""
    title: str | None = None
    """Optional document title."""
    context: str | None = None
    """Optional context about the document."""

    def to_content_block(self) -> BetaRequestDocumentBlockParam:
        """Return the Anthropic API content block dict."""
        block = BetaRequestDocumentBlockParam(
            type="document",
            source=BetaBase64PDFSourceParam(
                type="base64",
                media_type=self.media_type,
                data=self.document_data,
            ),
            title=self.title,
            context=self.context,
        )
        return cast(
            "BetaRequestDocumentBlockParam", {k: v for k, v in block.items() if v is not None}
        )

context class-attribute instance-attribute

context: str | None = None

Optional context about the document.

document_data instance-attribute

document_data: str

Base64-encoded PDF data.

media_type class-attribute instance-attribute

media_type: DocumentMediaType = 'application/pdf'

MIME type of the document.

title class-attribute instance-attribute

title: str | None = None

Optional document title.

to_content_block

to_content_block() -> BetaRequestDocumentBlockParam

Return the Anthropic API content block dict.

Source code in src/clawd_code_sdk/models/prompts.py
def to_content_block(self) -> BetaRequestDocumentBlockParam:
    """Return the Anthropic API content block dict."""
    block = BetaRequestDocumentBlockParam(
        type="document",
        source=BetaBase64PDFSourceParam(
            type="base64",
            media_type=self.media_type,
            data=self.document_data,
        ),
        title=self.title,
        context=self.context,
    )
    return cast(
        "BetaRequestDocumentBlockParam", {k: v for k, v in block.items() if v is not None}
    )

:fa-brands-github: Show source on GitHub