Skip to content

Messages

AIMessage

Bases: BaseModel

A message in the LLM conversation.

Attributes:

Name Type Description
role Literal[USER, MODEL, SYSTEM]

The role of the message sender.

chunks list[AIChunks]

The content chunks.

Source code in src/llmir/messages.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class AIMessage(BaseModel):
    """
    A message in the LLM conversation.

    Attributes:
        role: The role of the message sender.
        chunks: The content chunks.
    """

    role: Literal[AIRoles.USER, AIRoles.MODEL, AIRoles.SYSTEM]
    chunks: list[AIChunks] = Field(default_factory=list[AIChunks])

    @classmethod
    def text(cls,
        text: str,
        role: Literal[AIRoles.USER, AIRoles.MODEL, AIRoles.SYSTEM],
    ) -> AIMessage:
        return AIMessage(
            role=role,
            chunks=[
                AIChunkText(text=text)
            ]
        )

AIMessageToolResponse

Bases: BaseModel

A special tool response message in the LLM conversation.

Attributes:

Name Type Description
role Literal[TOOL]

The role of the message sender.

chunks list[AIChunks]

The content chunks.

id str

The id of the tool.

name str

The name of the tool.

Source code in src/llmir/messages.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class AIMessageToolResponse(BaseModel):
    """
    A special tool response message in the LLM conversation.

    Attributes:
        role: The role of the message sender.
        chunks: The content chunks.
        id: The id of the tool.
        name: The name of the tool.
    """

    role: Literal[AIRoles.TOOL] = AIRoles.TOOL
    chunks: list[AIChunks] = Field(default_factory=list[AIChunks])
    id: str
    name: str