use super::{ChatEvent, ChatProvider, ToolDef};
use crate::ChatMessage;
use anyhow::{Result, anyhow};
use async_trait::async_trait;
use tokio::sync::mpsc::Sender;
#[derive(Debug)]
pub struct BedrockProvider {
model: String,
}
impl BedrockProvider {
pub async fn new(model: impl Into<String>, _region: Option<&str>) -> Result<Self> {
let _ = model.into();
Err(anyhow!(
"bedrock feature not compiled in — rebuild with \
--features bedrock (or enable the 'bedrock' feature in Cargo.toml)"
))
}
}
#[async_trait]
impl ChatProvider for BedrockProvider {
fn name(&self) -> &str {
"bedrock-stub"
}
fn model(&self) -> &str {
&self.model
}
async fn chat_stream(
&self,
_messages: Vec<ChatMessage>,
_tools: Vec<ToolDef>,
_tx: Sender<ChatEvent>,
) -> Result<()> {
Err(anyhow!(
"bedrock feature not compiled in — rebuild with \
--features bedrock (or enable the 'bedrock' feature in Cargo.toml)"
))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn bedrock_stub_returns_error_without_feature() {
let result = BedrockProvider::new("some-model-id", None).await;
let err = result.expect_err("must error without feature");
assert!(
err.to_string().contains("bedrock feature not compiled in"),
"wrong error: {err}"
);
}
}