Parameters
Parameter | Type | Default | Description |
---|---|---|---|
model_name | BedrockModelName | None | The name of the Bedrock model to use. List of model names available here |
provider | Literal['bedrock'] | Provider[BaseClient] | 'bedrock' | The provider to use for authentication and API access. Can be either the string ‘bedrock’ or an instance of Provider[BaseClient] . If not provided, a new provider will be created using the other parameters |
profile | ModelProfileSpec | None | None | The model profile to use. Defaults to a profile picked by the provider based on the model name |
settings | ModelSettings | None | None | Model-specific settings that will be used as defaults for this model |
Functions
__init__
Initialize a Bedrock model.
Parameters:
model_name
(BedrockModelName): The name of the Bedrock model to use. List of model names available hereprovider
(Literal[‘bedrock’] | Provider[BaseClient]): The provider to use for authentication and API access. Can be either the string ‘bedrock’ or an instance ofProvider[BaseClient]
. If not provided, a new provider will be created using the other parametersprofile
(ModelProfileSpec | None): The model profile to use. Defaults to a profile picked by the provider based on the model namesettings
(ModelSettings | None): Model-specific settings that will be used as defaults for this model
base_url
Get the base URL for the provider API.
Returns:
str
: The base URL for the provider API
model_name
Get the model name.
Returns:
str
: The model name
system
Get the model provider.
Returns:
str
: The model provider
request
Make a request to the model.
Parameters:
messages
(list[ModelMessage]): The messages to send to the modelmodel_settings
(ModelSettings | None): Model-specific settingsmodel_request_parameters
(ModelRequestParameters): Request parameters
ModelResponse
: The model response
request_stream
Make a request to the model and return a streaming response.
Parameters:
messages
(list[ModelMessage]): The messages to send to the modelmodel_settings
(ModelSettings | None): Model-specific settingsmodel_request_parameters
(ModelRequestParameters): Request parameters
AsyncIterator[StreamedResponse]
: An async iterator of streamed responses
_get_tools
Get the tools for the model request.
Parameters:
model_request_parameters
(ModelRequestParameters): Request parameters
list[ToolTypeDef]
: The tools for the request
_map_tool_definition
Map a tool definition to Bedrock format.
Parameters:
f
(ToolDefinition): The tool definition to map
ToolTypeDef
: The mapped tool definition
_process_response
Process a non-streamed response, and prepare a message to return.
Parameters:
response
(ConverseResponseTypeDef): The response from Bedrock
ModelResponse
: The processed model response
_messages_create
Create a messages request to the Bedrock API.
Parameters:
messages
(list[ModelMessage]): The messages to send to the modelstream
(bool): Whether to stream the responsemodel_settings
(BedrockModelSettings | None): Bedrock-specific model settingsmodel_request_parameters
(ModelRequestParameters): Request parameters
ConverseResponseTypeDef | ConverseStreamResponseTypeDef
: The response from Bedrock
_map_inference_config
Map model settings to Bedrock inference configuration.
Parameters:
model_settings
(ModelSettings | None): Model settings
InferenceConfigurationTypeDef
: The mapped inference configuration
_map_tool_config
Map tool configuration for Bedrock.
Parameters:
model_request_parameters
(ModelRequestParameters): Request parameters
ToolConfigurationTypeDef | None
: The mapped tool configuration
_map_messages
Map messages to Bedrock format.
Parameters:
messages
(list[ModelMessage]): The messages to map
tuple[list[SystemContentBlockTypeDef], list[MessageUnionTypeDef]]
: The mapped messages
_map_user_prompt
Map a user prompt to Bedrock format.
Parameters:
part
(UserPromptPart): The user prompt part to mapdocument_count
(Iterator[int]): Iterator for document counting
list[MessageUnionTypeDef]
: The mapped user prompt
_map_tool_call
Map a tool call to Bedrock format.
Parameters:
t
(ToolCallPart): The tool call part to map
ContentBlockOutputTypeDef
: The mapped tool call