types¶
The Model Types module defines core data types for interacting with models.
This module contains type definitions for messages, content blocks, tool calls, responses, and more, providing a unified data structure representation for model input and output.
Tool ¶
Bases: BaseModel
A description of a tool that can be used by the LLM. Generally, a list of tools is provided to the LLM for selection.
Source code in bridgic/core/model/types/_tool_use.py
name class-attribute instance-attribute ¶
The name of the tool to be called.
description class-attribute instance-attribute ¶
A description of what the tool does, used by the LLM to choose when and how to call the tool.
parameters class-attribute instance-attribute ¶
parameters: Dict[str, Any] = Field(
...,
description="JSON schema object that describes the parameters of the tool.",
)
A JSON schema dictionary that describes the parameters of the tool.
ToolCall ¶
Bases: BaseModel
A description of a tool call that is generated by the LLM. The LLM can return one or multiple tool calls at once.
Source code in bridgic/core/model/types/_tool_use.py
id class-attribute instance-attribute ¶
The ID of the tool call.
name class-attribute instance-attribute ¶
The name of the tool to be called.
arguments class-attribute instance-attribute ¶
arguments: Dict[str, Any] = Field(
...,
default_factory=dict,
description="Arguments that are used to call the tool.",
)
The arguments to call the tool with, as generated by the LLM in JSON format.
ToolCallDict ¶
Bases: TypedDict
A dictionary that describes a tool call that is generated by the LLM. The LLM can return one or multiple tool calls at once. This ToolCallDict is another format of ToolCall that may be easier for developers to use.
Source code in bridgic/core/model/types/_tool_use.py
TextBlock ¶
Bases: BaseModel
Encapsulates plain text data that is passed to or received from language models.
Attributes:
| Name | Type | Description |
|---|---|---|
block_type | Literal['text'] | The type identifier for this content block. |
text | str | The actual text content. |
Source code in bridgic/core/model/types/_content_block.py
ToolCallBlock ¶
Bases: BaseModel
Encapsulates tool invocation data that is received from language models.
Attributes:
| Name | Type | Description |
|---|---|---|
block_type | Literal['tool_call'] | The type identifier for this content block. |
id | str | Unique identifier for the tool call instance. |
name | str | Name of the tool to be called. |
arguments | Dict[str, Any] | Parameters to be passed to the tool function. |
Source code in bridgic/core/model/types/_content_block.py
ToolResultBlock ¶
Bases: BaseModel
Encapsulates the results returned from tool executions.
Attributes:
| Name | Type | Description |
|---|---|---|
block_type | Literal['tool_result'] | The type identifier for this content block. |
id | str | Unique identifier matching the corresponding tool call. |
content | str | The result content returned from the tool execution. |
Source code in bridgic/core/model/types/_content_block.py
Role ¶
Bases: str, Enum
Message role enumeration for LLM conversations.
Defines the different roles that can be assigned to messages in a conversation with language models, following standard chat completion formats.
Attributes:
| Name | Type | Description |
|---|---|---|
SYSTEM | str | System role for providing instructions or context to the model. |
USER | str | User role for human input and queries. |
AI | str | Assistant role for model responses and outputs. |
TOOL | str | Tool role for tool execution results and responses. |
Source code in bridgic/core/model/types/_message.py
Message ¶
Bases: BaseModel
LLM message container for conversation exchanges.
Represents a single message in a conversation with language models, containing role information, content blocks, and optional metadata. Supports various content types including text, tool calls, and tool results.
Attributes:
| Name | Type | Description |
|---|---|---|
role | Role | The role of the message sender (system, user, assistant, or tool). |
blocks | List[ContentBlock] | List of content blocks containing the actual message data. |
extras | Dict[str, Any] | Additional metadata and custom fields for the message. |
Source code in bridgic/core/model/types/_message.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
from_tool_call ¶
classmethod from_tool_call(
tool_calls: Union[
ToolCallDict,
List[ToolCallDict],
ToolCall,
List[ToolCall],
],
text: Optional[str] = None,
extras: Optional[Dict[str, Any]] = {},
) -> Message
Create a message with tool call blocks and optional text content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_calls | Union[ToolCallDict, List[ToolCallDict], ToolCall, List[ToolCall]] | Tool call data in various formats: - Single tool call dict: {"id": "call_123", "name": "get_weather", "arguments": {...}} - List of tool call dicts: [{"id": "call_123", ...}, {"id": "call_124", ...}] - Single ToolCall instance - List of ToolCall instances | required |
text | Optional[str] | Optional text content to include in the message | None |
extras | Optional[Dict[str, Any]] | Additional metadata for the message | {} |
Returns:
| Type | Description |
|---|---|
Message | A message containing the tool call blocks and optional text |
Examples:
Source code in bridgic/core/model/types/_message.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
from_tool_result ¶
classmethod from_tool_result(
tool_id: str,
content: str,
extras: Optional[Dict[str, Any]] = {},
) -> Message
Create a message with a tool result block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id | str | The ID of the tool call that this result corresponds to | required |
content | str | The result content from the tool execution | required |
extras | Optional[Dict[str, Any]] | Additional metadata for the message | {} |
Returns:
| Type | Description |
|---|---|
Message | A message containing the tool result block |
Examples:
Source code in bridgic/core/model/types/_message.py
MessageChunk ¶
Bases: BaseModel
Streaming message chunk for real-time LLM responses.
Represents a partial message chunk received during streaming responses from language models, allowing for real-time processing of incremental content.
Attributes:
| Name | Type | Description |
|---|---|---|
delta | Optional[str] | The incremental text content of this chunk. |
raw | Optional[Any] | Raw response data from the LLM provider. |
Source code in bridgic/core/model/types/_message.py
Response ¶
Bases: BaseModel
LLM response container for model outputs.
Represents the complete response from a language model, containing both the message content and the raw response data from the underlying model provider.
Attributes:
| Name | Type | Description |
|---|---|---|
message | Optional[Message] | The structured message containing the model's response content. |
raw | Optional[Any] | Raw response data from the LLM provider for debugging or custom processing. |