Types
Bases: genkit.core.typing.GenerateResponse
A wrapper around GenerateResponse providing utility methods.
Extends the base GenerateResponse
with cached properties (text
, output
, messages
, tool_requests
) and methods for validation (assert_valid
, assert_valid_schema
). It also handles optional message/chunk parsing.
Source code in packages/genkit/src/genkit/blocks/model.py
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 228 229 230 231 232 233 234 235 236 |
|
interrupts
cached
property
Returns all interrupted tool request parts of the response as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of interrupted tool requests. |
messages
cached
property
Returns all messages of the response, including request messages as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.Message] | list[Message]: list of messages. |
output
cached
property
Parses out JSON data from the text parts of the response.
Returns:
Name | Type | Description |
---|---|---|
Any | typing.Any | The parsed JSON data from the response. |
text
cached
property
Returns all text parts of the response joined into a single string.
Returns:
Name | Type | Description |
---|---|---|
str | str | The combined text content from the response. |
tool_requests
cached
property
Returns all tool request parts of the response as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of tool requests present in this response. |
__init__(response, request, message_parser=None)
Initializes a GenerateResponseWrapper instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response | genkit.core.typing.GenerateResponse | The original GenerateResponse object. | required |
request | genkit.core.typing.GenerateRequest | The GenerateRequest object associated with the response. | required |
message_parser | genkit.blocks.model.MessageParser | None | An optional function to parse the output from the message. | None |
Source code in packages/genkit/src/genkit/blocks/model.py
assert_valid()
Validates the basic structure of the response.
Note: This method is currently a placeholder (TODO).
Raises:
Type | Description |
---|---|
AssertionError | If the response structure is considered invalid. |
Source code in packages/genkit/src/genkit/blocks/model.py
assert_valid_schema()
Validates that the response message conforms to any specified output schema.
Note: This method is currently a placeholder (TODO).
Raises:
Type | Description |
---|---|
AssertionError | If the response message does not conform to the schema. |
Source code in packages/genkit/src/genkit/blocks/model.py
Bases: pydantic.BaseModel
Model for generaterequest data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for generateresponse data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: genkit.core.typing.Message
A wrapper around the base Message type providing utility methods.
This class extends the standard Message
by adding convenient cached properties like text
(for concatenated text content) and tool_requests
. It stores the original message in the _original_message
attribute.
Source code in packages/genkit/src/genkit/blocks/model.py
interrupts
cached
property
Returns all interrupted tool request parts of the message as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of interrupted tool requests. |
text
cached
property
Returns all text parts of the current chunk joined into a single string.
Returns:
Name | Type | Description |
---|---|---|
str | str | The combined text content from the current chunk. |
tool_requests
cached
property
Returns all tool request parts of the response as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of tool requests present in this response. |
__init__(message)
Initializes the MessageWrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | genkit.core.typing.Message | The original Message object to wrap. | required |
Source code in packages/genkit/src/genkit/blocks/model.py
Bases: genkit.core.typing.Message
A wrapper around the base Message type providing utility methods.
This class extends the standard Message
by adding convenient cached properties like text
(for concatenated text content) and tool_requests
. It stores the original message in the _original_message
attribute.
Source code in packages/genkit/src/genkit/blocks/model.py
interrupts
cached
property
Returns all interrupted tool request parts of the message as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of interrupted tool requests. |
text
cached
property
Returns all text parts of the current chunk joined into a single string.
Returns:
Name | Type | Description |
---|---|---|
str | str | The combined text content from the current chunk. |
tool_requests
cached
property
Returns all tool request parts of the response as a list.
Returns:
Type | Description |
---|---|
list[genkit.core.typing.ToolRequestPart] | list[ToolRequestPart]: list of tool requests present in this response. |
__init__(message)
Initializes the MessageWrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | genkit.core.typing.Message | The original Message object to wrap. | required |
Source code in packages/genkit/src/genkit/blocks/model.py
Bases: pydantic.BaseModel
Model for message data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.RootModel[genkit.core.typing.TextPart | genkit.core.typing.MediaPart | genkit.core.typing.ToolRequestPart | genkit.core.typing.ToolResponsePart | genkit.core.typing.DataPart | genkit.core.typing.CustomPart]
Root model for part.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for textpart data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for mediapart data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for media data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for toolrequestpart data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for toolrequest data.
Source code in packages/genkit/src/genkit/core/typing.py
Bases: pydantic.BaseModel
Model for toolresponsepart data.