base.types¶
Base types and abstract interfaces for typing LLM calls.
AssistantMessage
¶
Bases: TypedDict
A message with the assistant
role.
Attributes:
Name | Type | Description |
---|---|---|
role |
Required[Literal['assistant']]
|
The role of the message's author, in this case |
content |
Required[str]
|
The contents of the message. |
Source code in mirascope/base/types.py
BaseCallParams
¶
Bases: BaseModel
, Generic[BaseToolT]
The parameters with which to make a call.
Source code in mirascope/base/types.py
kwargs(tool_type=None, exclude=None)
¶
Returns all parameters for the call as a keyword arguments dictionary.
Source code in mirascope/base/types.py
BaseCallResponse
¶
Bases: BaseModel
, Generic[ResponseT, BaseToolT]
, ABC
A base abstract interface for LLM call responses.
Attributes:
Name | Type | Description |
---|---|---|
response |
ResponseT
|
The original response from whichever model response this wraps. |
Source code in mirascope/base/types.py
content: str
abstractmethod
property
¶
Should return the string content of the response.
If there are multiple choices in a response, this method should select the 0th choice and return it's string content.
If there is no string content (e.g. when using tools), this method must return the empty string.
tool: Optional[BaseToolT]
abstractmethod
property
¶
Returns the 0th tool for the 0th choice message.
tools: Optional[list[BaseToolT]]
abstractmethod
property
¶
Returns the tools for the 0th choice message.
BaseCallResponseChunk
¶
Bases: BaseModel
, Generic[ChunkT, BaseToolT]
, ABC
A base abstract interface for LLM streaming response chunks.
Attributes:
Name | Type | Description |
---|---|---|
response |
The original response chunk from whichever model response this wraps. |
Source code in mirascope/base/types.py
content: str
abstractmethod
property
¶
Should return the string content of the response chunk.
If there are multiple choices in a chunk, this method should select the 0th choice and return it's string content.
If there is no string content (e.g. when using tools), this method must return the empty string.
ModelMessage
¶
Bases: TypedDict
A message with the model
role.
Attributes:
Name | Type | Description |
---|---|---|
role |
Required[Literal['model']]
|
The role of the message's author, in this case |
content |
Required[str]
|
The contents of the message. |
Source code in mirascope/base/types.py
SystemMessage
¶
Bases: TypedDict
A message with the system
role.
Attributes:
Name | Type | Description |
---|---|---|
role |
Required[Literal['system']]
|
The role of the message's author, in this case |
content |
Required[str]
|
The contents of the message. |
Source code in mirascope/base/types.py
ToolMessage
¶
Bases: TypedDict
A message with the tool
role.
Attributes:
Name | Type | Description |
---|---|---|
role |
Required[Literal['tool']]
|
The role of the message's author, in this case |
content |
Required[str]
|
The contents of the message. |
Source code in mirascope/base/types.py
UserMessage
¶
Bases: TypedDict
A message with the user
role.
Attributes:
Name | Type | Description |
---|---|---|
role |
Required[Literal['user']]
|
The role of the message's author, in this case |
content |
Required[str]
|
The contents of the message. |