pub struct BedrockProvider { /* private fields */ }Expand description
Amazon Bedrock provider implementation.
Clone-able and cheap to copy (wraps an [Arc]-backed reqwest::Client).
§Examples
use codetether_agent::provider::bedrock::{AwsCredentials, BedrockProvider};
let creds = AwsCredentials::from_environment().unwrap();
let p = BedrockProvider::with_credentials(creds, "us-west-2".into()).unwrap();
assert_eq!(p.region(), "us-west-2");Implementations§
Source§impl BedrockProvider
impl BedrockProvider
Sourcepub async fn send_converse_request(
&self,
url: &str,
body: &[u8],
) -> Result<Response>
pub async fn send_converse_request( &self, url: &str, body: &[u8], ) -> Result<Response>
Send a pre-formed POST request to any Bedrock runtime URL, signed with whichever auth mode is configured. Used by the thinker backend for direct URL access.
§Arguments
url— The full HTTPS URL to POST to.body— The serialized JSON request body.
§Errors
Returns anyhow::Error if the network call fails.
§Examples
use codetether_agent::provider::bedrock::{AwsCredentials, BedrockProvider};
let creds = AwsCredentials::from_environment().unwrap();
let p = BedrockProvider::with_credentials(creds, "us-west-2".into()).unwrap();
let url = "https://bedrock-runtime.us-west-2.amazonaws.com/model/amazon.nova-micro-v1:0/converse";
let resp = p.send_converse_request(url, b"{}" ).await.unwrap();
assert!(resp.status().is_client_error() || resp.status().is_success());Source§impl BedrockProvider
impl BedrockProvider
Sourcepub fn new(api_key: String) -> Result<Self>
pub fn new(api_key: String) -> Result<Self>
Create a bearer-token provider in the default region.
§Errors
Currently infallible, but returns Result for API symmetry with
BedrockProvider::with_credentials and future validation needs.
§Examples
use codetether_agent::provider::bedrock::BedrockProvider;
let p = BedrockProvider::new("token-abc".into()).unwrap();
assert_eq!(p.region(), "us-east-1");Sourcepub fn with_region(api_key: String, region: String) -> Result<Self>
pub fn with_region(api_key: String, region: String) -> Result<Self>
Create a bearer-token provider with an explicit region.
§Examples
use codetether_agent::provider::bedrock::BedrockProvider;
let p = BedrockProvider::with_region("token".into(), "eu-west-1".into()).unwrap();
assert_eq!(p.region(), "eu-west-1");Sourcepub fn with_credentials(
credentials: AwsCredentials,
region: String,
) -> Result<Self>
pub fn with_credentials( credentials: AwsCredentials, region: String, ) -> Result<Self>
Create a SigV4 provider from AWS IAM credentials.
§Examples
use codetether_agent::provider::bedrock::{AwsCredentials, BedrockProvider};
let creds = AwsCredentials::from_environment().unwrap();
let p = BedrockProvider::with_credentials(creds, "us-west-2".into()).unwrap();
assert_eq!(p.region(), "us-west-2");Sourcepub fn resolve_model_id(model: &str) -> &str
pub fn resolve_model_id(model: &str) -> &str
Resolve a short model alias to a full Bedrock model ID.
See aliases::resolve_model_id for details.
Sourcepub fn build_converse_body(
&self,
request: &CompletionRequest,
model_id: &str,
) -> Value
pub fn build_converse_body( &self, request: &CompletionRequest, model_id: &str, ) -> Value
Build a Converse request body. See body::build_converse_body.
Trait Implementations§
Source§impl Clone for BedrockProvider
impl Clone for BedrockProvider
Source§fn clone(&self) -> BedrockProvider
fn clone(&self) -> BedrockProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BedrockProvider
impl Debug for BedrockProvider
Source§impl Provider for BedrockProvider
impl Provider for BedrockProvider
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn complete_stream<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, StreamChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_stream<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, StreamChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn embed<'life0, 'async_trait>(
&'life0 self,
_request: EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn embed<'life0, 'async_trait>(
&'life0 self,
_request: EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request