pub struct BedrockProvider;Expand description
Provider for AWS Bedrock-hosted models (bedrock/* slugs), backed by the
Converse API.
Why: Reserves the routing target and (#1021 phase 1) normalises
tool-choice/usage for the Converse wire shape, which differs from
OpenRouter’s OpenAI-compatible schema on both axes.
What: Zero-sized marker type implementing Provider.
Test: bedrock::tests::*.
Implementations§
Trait Implementations§
Source§impl Clone for BedrockProvider
impl Clone for BedrockProvider
Source§impl Debug for BedrockProvider
impl Debug for BedrockProvider
Source§impl Default for BedrockProvider
impl Default for BedrockProvider
Source§impl Provider for BedrockProvider
impl Provider for BedrockProvider
Source§fn map_tool_choice(&self, choice: ToolChoice) -> Value
fn map_tool_choice(&self, choice: ToolChoice) -> Value
Translate a neutral ToolChoice into Converse’s own toolChoice JSON
shape.
Why: Converse’s toolChoice is {"auto":{}} / {"any":{}} /
{"tool":{"name":...}} — structurally different from OpenAI’s bare
strings and {"type":"function","function":{"name":...}} object.
crate::llm::bedrock::convert::build_tool_config’s
interpret_tool_choice accepts BOTH this shape and the OpenAI shape
(since agent_loop::build_request currently sends the OpenAI
"auto" string unconditionally — #1021 doesn’t rewire that call
site), so wiring this mapping in later is a drop-in change with no
transport update required.
What: None -> "none" (a sentinel string; Converse has no “don’t
call any tool” choice, so the transport omits toolConfig entirely
when it sees this). Auto -> {"auto":{}}. Required -> {"any":{}}
(Converse’s “must call some tool” choice). Function(name) ->
{"tool":{"name":name}}.
Test: bedrock::tests::map_tool_choice_*.
Source§fn extract_usage(&self, response: &ChatResponse) -> TokenUsage
fn extract_usage(&self, response: &ChatResponse) -> TokenUsage
Extract canonical token usage from a (Bedrock-originated) chat response.
Why: By the time a Bedrock Converse response reaches Provider, the
transport (crate::llm::bedrock::convert::converse_output_to_chat_response)
has already mapped Converse’s TokenUsage (inputTokens/
outputTokens/cacheReadInputTokens/cacheWriteInputTokens) into
ChatResponse.usage: UsageBlock — the same canonical shape every
other provider’s response is normalised into. No Bedrock-specific
parsing is needed at this layer.
What: Delegates to ChatResponse::token_usage (identical to
OpenRouterProvider::extract_usage).
Test: bedrock::tests::extract_usage_maps_fields.
Source§fn supports_native_tools(&self) -> bool
fn supports_native_tools(&self) -> bool
Source§fn supports_prompt_caching(&self) -> bool
fn supports_prompt_caching(&self) -> bool
cache_control
prompt-cache breakpoints (#2156). Read moreSource§fn wants_detailed_usage(&self) -> bool
fn wants_detailed_usage(&self) -> bool
Auto Trait Implementations§
impl Freeze for BedrockProvider
impl RefUnwindSafe for BedrockProvider
impl Send for BedrockProvider
impl Sync for BedrockProvider
impl Unpin for BedrockProvider
impl UnsafeUnpin for BedrockProvider
impl UnwindSafe for BedrockProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more