Skip to content

BaseChunk

Sub classes

Name Children Inherits
UserMessageChunk
aclientp.schema.session_updates
A chunk of the user's message being streamed.
    AgentMessageChunk
    aclientp.schema.session_updates
    A chunk of the agent's response being streamed.
      AgentThoughtChunk
      aclientp.schema.session_updates
      A chunk of the agent's internal reasoning being streamed.

        Base classes

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

        â‹” Inheritance diagram

        graph TD
          95970862246960["session_updates.BaseChunk"]
          95970862258240["base.AnnotatedObject"]
          95970862254416["base.Schema"]
          95970851503232["main.BaseModel"]
          125067848591872["builtins.object"]
          95970862258240 --> 95970862246960
          95970862254416 --> 95970862258240
          95970851503232 --> 95970862254416
          125067848591872 --> 95970851503232

        🛈 DocStrings

        Bases: AnnotatedObject

        Base class for all session update chunks.

        Source code in src/aclientp/schema/session_updates.py
        class BaseChunk(AnnotatedObject):
            """Base class for all session update chunks."""
        
            content: ContentBlock
            """A single item of content"""
        
            message_id: str | None = None
            """**UNSTABLE**: A unique identifier for the message this chunk belongs to.
        
            All chunks belonging to the same message share the same ``message_id``.
            A change in ``message_id`` indicates a new message has started.
            Both clients and agents MUST use UUID format for message IDs.
            """
        
            @classmethod
            def text(
                cls,
                text: str,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk containing text.
        
                Args:
                    text: The text content.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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),
                    message_id=message_id,
                )
        
            @classmethod
            def image(
                cls,
                data: str | bytes,
                mime_type: str,
                uri: str | None = None,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk containing an embedded image resource.
        
                Args:
                    data: The image data.
                    mime_type: The MIME type of the image.
                    uri: The URI of the image.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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, message_id=message_id)
        
            @classmethod
            def audio(
                cls,
                data: str | bytes,
                mime_type: str,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk containing audio content.
        
                Args:
                    data: The audio data.
                    mime_type: The MIME type of the audio data.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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, message_id=message_id)
        
            @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,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk 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.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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, message_id=message_id)
        
            @classmethod
            def embedded_text_resource(
                cls,
                text: str,
                uri: str,
                mime_type: str | None = None,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk 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.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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, message_id=message_id)
        
            @classmethod
            def embedded_blob_resource(
                cls,
                data: bytes | str,
                uri: str,
                mime_type: str | None = None,
                *,
                message_id: str | None = None,
                audience: Audience | None = None,
                last_modified: datetime | str | None = None,
                priority: float | None = None,
            ) -> Self:
                """Create a chunk 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.
                    message_id: Unique identifier for the message this chunk belongs to.
                    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, message_id=message_id)
        

        content instance-attribute

        content: ContentBlock
        

        A single item of content

        message_id class-attribute instance-attribute

        message_id: str | None = None
        

        UNSTABLE: A unique identifier for the message this chunk belongs to.

        All chunks belonging to the same message share the same message_id. A change in message_id indicates a new message has started. Both clients and agents MUST use UUID format for message IDs.

        audio classmethod

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

        Create a chunk 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
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        None
        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/session_updates.py
        @classmethod
        def audio(
            cls,
            data: str | bytes,
            mime_type: str,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk containing audio content.
        
            Args:
                data: The audio data.
                mime_type: The MIME type of the audio data.
                message_id: Unique identifier for the message this chunk belongs to.
                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, message_id=message_id)
        

        embedded_blob_resource classmethod

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

        Create a chunk 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
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        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/session_updates.py
        @classmethod
        def embedded_blob_resource(
            cls,
            data: bytes | str,
            uri: str,
            mime_type: str | None = None,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk 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.
                message_id: Unique identifier for the message this chunk belongs to.
                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, message_id=message_id)
        

        embedded_text_resource classmethod

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

        Create a chunk 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
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        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/session_updates.py
        @classmethod
        def embedded_text_resource(
            cls,
            text: str,
            uri: str,
            mime_type: str | None = None,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk 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.
                message_id: Unique identifier for the message this chunk belongs to.
                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, message_id=message_id)
        

        image classmethod

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

        Create a chunk 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
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        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/session_updates.py
        @classmethod
        def image(
            cls,
            data: str | bytes,
            mime_type: str,
            uri: str | None = None,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk containing an embedded image resource.
        
            Args:
                data: The image data.
                mime_type: The MIME type of the image.
                uri: The URI of the image.
                message_id: Unique identifier for the message this chunk belongs to.
                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, message_id=message_id)
        

        resource classmethod

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

        Create a chunk 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
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        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/session_updates.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,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk 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.
                message_id: Unique identifier for the message this chunk belongs to.
                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, message_id=message_id)
        

        text classmethod

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

        Create a chunk containing text.

        Parameters:

        Name Type Description Default
        text str

        The text content.

        required
        message_id str | None

        Unique identifier for the message this chunk belongs to.

        None
        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/session_updates.py
        @classmethod
        def text(
            cls,
            text: str,
            *,
            message_id: str | None = None,
            audience: Audience | None = None,
            last_modified: datetime | str | None = None,
            priority: float | None = None,
        ) -> Self:
            """Create a chunk containing text.
        
            Args:
                text: The text content.
                message_id: Unique identifier for the message this chunk belongs to.
                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),
                message_id=message_id,
            )
        

        :fa-brands-github: Show source on GitHub