Skip to content

ContentToolCallContent

Base classes

Name Children Inherits
AnnotatedObject
aclientp.schema.base
Base class for generated models.

â‹” Inheritance diagram

graph TD
  95970859758896["tool_call.ContentToolCallContent"]
  95970862258240["base.AnnotatedObject"]
  95970862254416["base.Schema"]
  95970851503232["main.BaseModel"]
  125067848591872["builtins.object"]
  95970862258240 --> 95970859758896
  95970862254416 --> 95970862258240
  95970851503232 --> 95970862254416
  125067848591872 --> 95970851503232

🛈 DocStrings

Bases: AnnotatedObject

Standard content block (text, images, resources).

Source code in src/aclientp/schema/tool_call.py
class ContentToolCallContent(AnnotatedObject):
    """Standard content block (text, images, resources)."""

    type: Literal["content"] = Field(default="content", init=False)
    """Standard content block (text, images, resources)."""

    content: ContentBlock
    """The actual content block."""

    @classmethod
    def text(
        cls,
        text: str,
        *,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing text.

        Args:
            text: The text content.
            audience: The audience for the text.
            last_modified: The last modified date of the text.
            priority: The priority of the text.
        """
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        return cls(content=TextContentBlock(text=text, annotations=annotations))

    @classmethod
    def image(
        cls,
        data: str | bytes,
        mime_type: str,
        uri: str | None = None,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing an embedded image resource.

        Args:
            data: The image data.
            mime_type: The MIME type of the image.
            uri: The URI of the image.
            audience: The audience for the image.
            last_modified: The last modified date of the image.
            priority: The priority of the image.
        """
        if isinstance(data, bytes):
            data = base64.b64encode(data).decode()
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        image = ImageContentBlock(data=data, mime_type=mime_type, uri=uri, annotations=annotations)
        return cls(content=image)

    @classmethod
    def audio(
        cls,
        data: str | bytes,
        mime_type: str,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing audio content.

        Args:
            data: The audio data.
            mime_type: The MIME type of the audio data.
            audience: The audience for the audio chunk.
            last_modified: The last modified date of the audio chunk.
            priority: The priority of the audio chunk.
        """
        if isinstance(data, bytes):
            data = base64.b64encode(data).decode()
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        content = AudioContentBlock(data=data, mime_type=mime_type, annotations=annotations)
        return cls(content=content)

    @classmethod
    def resource(
        cls,
        name: str,
        uri: str,
        description: str | None = None,
        mime_type: str | None = None,
        size: int | None = None,
        title: str | None = None,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing a resource content block.

        Args:
            name: The name of the resource.
            uri: The URI of the resource.
            description: The description of the resource.
            mime_type: The MIME type of the resource.
            size: The size of the resource.
            title: The title of the resource.
            audience: The audience of the resource.
            last_modified: The last modified date of the resource.
            priority: The priority of the resource.
        """
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        block = ResourceContentBlock(
            name=name,
            uri=uri,
            description=description,
            mime_type=mime_type,
            size=size,
            title=title,
            annotations=annotations,
        )
        return cls(content=block)

    @classmethod
    def embedded_text_resource(
        cls,
        text: str,
        uri: str,
        mime_type: str | None = None,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing an embedded text resource.

        Args:
            text: The text to embed.
            uri: The URI of the resource.
            mime_type: The MIME type of the resource.
            audience: The audience to apply to the resource.
            last_modified: The last modified date of the resource.
            priority: The priority of the resource.
        """
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        contents = TextResourceContents(text=text, mime_type=mime_type, uri=uri)
        content = EmbeddedResourceContentBlock(annotations=annotations, resource=contents)
        return cls(content=content)

    @classmethod
    def embedded_blob_resource(
        cls,
        data: bytes | str,
        uri: str,
        mime_type: str | None = None,
        audience: Audience | None = None,
        last_modified: datetime | str | None = None,
        priority: float | None = None,
    ) -> Self:
        """Create a ToolCallContent containing an embedded blob resource.

        Args:
            data: The data to embed.
            uri: The URI of the resource.
            mime_type: The MIME type of the resource.
            audience: The audience to apply to the resource.
            last_modified: The last modified date of the resource.
            priority: The priority of the resource.
        """
        if isinstance(data, bytes):
            data = base64.b64encode(data).decode()
        annotations = Annotations.optionally_create(
            audience=audience,
            last_modified=last_modified,
            priority=priority,
        )
        resource = BlobResourceContents(blob=data, mime_type=mime_type, uri=uri)
        content = EmbeddedResourceContentBlock(annotations=annotations, resource=resource)
        return cls(content=content)

content instance-attribute

content: ContentBlock

The actual content block.

type class-attribute instance-attribute

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

Standard content block (text, images, resources).

audio classmethod

audio(
    data: str | bytes,
    mime_type: str,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing audio content.

Parameters:

Name Type Description Default
data str | bytes

The audio data.

required
mime_type str

The MIME type of the audio data.

required
audience Audience | None

The audience for the audio chunk.

None
last_modified datetime | str | None

The last modified date of the audio chunk.

None
priority float | None

The priority of the audio chunk.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def audio(
    cls,
    data: str | bytes,
    mime_type: str,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing audio content.

    Args:
        data: The audio data.
        mime_type: The MIME type of the audio data.
        audience: The audience for the audio chunk.
        last_modified: The last modified date of the audio chunk.
        priority: The priority of the audio chunk.
    """
    if isinstance(data, bytes):
        data = base64.b64encode(data).decode()
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    content = AudioContentBlock(data=data, mime_type=mime_type, annotations=annotations)
    return cls(content=content)

embedded_blob_resource classmethod

embedded_blob_resource(
    data: bytes | str,
    uri: str,
    mime_type: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing an embedded blob resource.

Parameters:

Name Type Description Default
data bytes | str

The data to embed.

required
uri str

The URI of the resource.

required
mime_type str | None

The MIME type of the resource.

None
audience Audience | None

The audience to apply to the resource.

None
last_modified datetime | str | None

The last modified date of the resource.

None
priority float | None

The priority of the resource.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def embedded_blob_resource(
    cls,
    data: bytes | str,
    uri: str,
    mime_type: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing an embedded blob resource.

    Args:
        data: The data to embed.
        uri: The URI of the resource.
        mime_type: The MIME type of the resource.
        audience: The audience to apply to the resource.
        last_modified: The last modified date of the resource.
        priority: The priority of the resource.
    """
    if isinstance(data, bytes):
        data = base64.b64encode(data).decode()
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    resource = BlobResourceContents(blob=data, mime_type=mime_type, uri=uri)
    content = EmbeddedResourceContentBlock(annotations=annotations, resource=resource)
    return cls(content=content)

embedded_text_resource classmethod

embedded_text_resource(
    text: str,
    uri: str,
    mime_type: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing an embedded text resource.

Parameters:

Name Type Description Default
text str

The text to embed.

required
uri str

The URI of the resource.

required
mime_type str | None

The MIME type of the resource.

None
audience Audience | None

The audience to apply to the resource.

None
last_modified datetime | str | None

The last modified date of the resource.

None
priority float | None

The priority of the resource.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def embedded_text_resource(
    cls,
    text: str,
    uri: str,
    mime_type: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing an embedded text resource.

    Args:
        text: The text to embed.
        uri: The URI of the resource.
        mime_type: The MIME type of the resource.
        audience: The audience to apply to the resource.
        last_modified: The last modified date of the resource.
        priority: The priority of the resource.
    """
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    contents = TextResourceContents(text=text, mime_type=mime_type, uri=uri)
    content = EmbeddedResourceContentBlock(annotations=annotations, resource=contents)
    return cls(content=content)

image classmethod

image(
    data: str | bytes,
    mime_type: str,
    uri: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing an embedded image resource.

Parameters:

Name Type Description Default
data str | bytes

The image data.

required
mime_type str

The MIME type of the image.

required
uri str | None

The URI of the image.

None
audience Audience | None

The audience for the image.

None
last_modified datetime | str | None

The last modified date of the image.

None
priority float | None

The priority of the image.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def image(
    cls,
    data: str | bytes,
    mime_type: str,
    uri: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing an embedded image resource.

    Args:
        data: The image data.
        mime_type: The MIME type of the image.
        uri: The URI of the image.
        audience: The audience for the image.
        last_modified: The last modified date of the image.
        priority: The priority of the image.
    """
    if isinstance(data, bytes):
        data = base64.b64encode(data).decode()
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    image = ImageContentBlock(data=data, mime_type=mime_type, uri=uri, annotations=annotations)
    return cls(content=image)

resource classmethod

resource(
    name: str,
    uri: str,
    description: str | None = None,
    mime_type: str | None = None,
    size: int | None = None,
    title: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing a resource content block.

Parameters:

Name Type Description Default
name str

The name of the resource.

required
uri str

The URI of the resource.

required
description str | None

The description of the resource.

None
mime_type str | None

The MIME type of the resource.

None
size int | None

The size of the resource.

None
title str | None

The title of the resource.

None
audience Audience | None

The audience of the resource.

None
last_modified datetime | str | None

The last modified date of the resource.

None
priority float | None

The priority of the resource.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def resource(
    cls,
    name: str,
    uri: str,
    description: str | None = None,
    mime_type: str | None = None,
    size: int | None = None,
    title: str | None = None,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing a resource content block.

    Args:
        name: The name of the resource.
        uri: The URI of the resource.
        description: The description of the resource.
        mime_type: The MIME type of the resource.
        size: The size of the resource.
        title: The title of the resource.
        audience: The audience of the resource.
        last_modified: The last modified date of the resource.
        priority: The priority of the resource.
    """
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    block = ResourceContentBlock(
        name=name,
        uri=uri,
        description=description,
        mime_type=mime_type,
        size=size,
        title=title,
        annotations=annotations,
    )
    return cls(content=block)

text classmethod

text(
    text: str,
    *,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self

Create a ToolCallContent containing text.

Parameters:

Name Type Description Default
text str

The text content.

required
audience Audience | None

The audience for the text.

None
last_modified datetime | str | None

The last modified date of the text.

None
priority float | None

The priority of the text.

None
Source code in src/aclientp/schema/tool_call.py
@classmethod
def text(
    cls,
    text: str,
    *,
    audience: Audience | None = None,
    last_modified: datetime | str | None = None,
    priority: float | None = None,
) -> Self:
    """Create a ToolCallContent containing text.

    Args:
        text: The text content.
        audience: The audience for the text.
        last_modified: The last modified date of the text.
        priority: The priority of the text.
    """
    annotations = Annotations.optionally_create(
        audience=audience,
        last_modified=last_modified,
        priority=priority,
    )
    return cls(content=TextContentBlock(text=text, annotations=annotations))

:fa-brands-github: Show source on GitHub