Skip to content

Chunks

AIChunkText

Bases: RichReprMixin, BaseModel

A text chunk in the LLM conversation.

Attributes:

Name Type Description
type Literal['text']

The type of the chunk, only for discriminated unions.

text str

The text content.

Source code in src/llmir/chunks.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
class AIChunkText(RichReprMixin, BaseModel):
    """
    A text chunk in the LLM conversation.

    Attributes:
        type: The type of the chunk, only for discriminated unions.
        text: The text content.
    """

    type: Literal["text"] = "text"
    text: str

AIChunkFile

Bases: RichReprMixin, BaseModel

A file chunk in the LLM conversation.

The file is represented as bytes. It does not contain any pointer to the file system.

Attributes:

Name Type Description
type Literal['file']

The type of the chunk, only for discriminated unions.

name str

The name of the file.

mimetype str

The mimetype of the file.

bytes bytes

The bytes of the file.

Source code in src/llmir/chunks.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class AIChunkFile(RichReprMixin, BaseModel):
    """
    A file chunk in the LLM conversation.

    The file is represented as bytes.
    It does not contain any pointer to the file system.

    Attributes:
        type: The type of the chunk, only for discriminated unions.
        name: The name of the file.
        mimetype: The mimetype of the file.
        bytes: The bytes of the file.
    """

    type: Literal["file"] = "file"
    name: str
    mimetype: str
    bytes: bytes

AIChunkImageURL

Bases: RichReprMixin, BaseModel

An image chunk in the LLM conversation.

The image is represented as an URL that points to the image data.

Attributes:

Name Type Description
type Literal['image']

The type of the chunk, only for discriminated unions.

url str

The URL of the image.

Source code in src/llmir/chunks.py
36
37
38
39
40
41
42
43
44
45
46
47
48
class AIChunkImageURL(RichReprMixin, BaseModel):
    """
    An image chunk in the LLM conversation.

    The image is represented as an URL that points to the image data.

    Attributes:
        type: The type of the chunk, only for discriminated unions.
        url: The URL of the image.
    """

    type: Literal["image"] = "image"
    url: str

AIChunkToolCall

Bases: RichReprMixin, BaseModel

A tool call chunk in the LLM conversation.

Attributes:

Name Type Description
type Literal['tool_call']

The type of the chunk, only for discriminated unions.

id str

The id of the tool.

name str

The name of the tool.

arguments Mapping[str, Any]

The arguments of the tool call. The arguments are a dictionary of key-value pairs. The values can be of any type, but should be JSON serializable. The keys are the names of the arguments.

Source code in src/llmir/chunks.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class AIChunkToolCall(RichReprMixin, BaseModel):
    """
    A tool call chunk in the LLM conversation.

    Attributes:
        type: The type of the chunk, only for discriminated unions.
        id: The id of the tool.
        name: The name of the tool.
        arguments: The arguments of the tool call. The arguments are a dictionary of key-value pairs. The values can be of any type, but should be JSON serializable. The keys are the names of the arguments.
    """


    type: Literal["tool_call"] = "tool_call"
    id: str
    name: str
    arguments: Mapping[str, Any]