Skip to content

UserPlainTextDocumentPrompt

🛈 DocStrings

A user prompt containing a plain text document.

Source code in src/clawd_code_sdk/models/prompts.py
@dataclass
class UserPlainTextDocumentPrompt:
    """A user prompt containing a plain text document."""

    data: str
    """The plain text content."""
    media_type: PlainTextMediaType = "text/plain"
    """MIME type (always text/plain)."""
    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=BetaPlainTextSourceParam(
                type="text",
                media_type=self.media_type,
                data=self.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.

data instance-attribute

data: str

The plain text content.

media_type class-attribute instance-attribute

media_type: PlainTextMediaType = 'text/plain'

MIME type (always text/plain).

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=BetaPlainTextSourceParam(
            type="text",
            media_type=self.media_type,
            data=self.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