Skip to content

UserDocumentURLPrompt

🛈 DocStrings

A user prompt containing a PDF document referenced by URL.

Source code in src/clawd_code_sdk/models/prompts.py
@dataclass
class UserDocumentURLPrompt:
    """A user prompt containing a PDF document referenced by URL."""

    url: str
    """Public URL of the PDF 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=BetaURLPDFSourceParam(type="url", url=self.url),
            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.

title class-attribute instance-attribute

title: str | None = None

Optional document title.

url instance-attribute

url: str

Public URL of the PDF document.

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=BetaURLPDFSourceParam(type="url", url=self.url),
        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