diff --git a/Cargo.lock b/Cargo.lock index 838c4bf1..d4e15394 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4129,24 +4129,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "rig-bedrock" -version = "0.3.9" -dependencies = [ - "async-stream", - "aws-config", - "aws-sdk-bedrockruntime", - "aws-smithy-types", - "base64 0.22.1", - "rig-core", - "schemars 0.8.22", - "serde", - "serde_json", - "tokio", - "tracing", - "uuid", -] - [[package]] name = "rig-core" version = "0.27.0" @@ -4852,6 +4834,11 @@ dependencies = [ "ahash", "aho-corasick", "assert_cmd", + "async-stream", + "aws-config", + "aws-sdk-bedrockruntime", + "aws-smithy-types", + "base64 0.22.1", "blake3", "bstr", "chrono", @@ -4880,10 +4867,10 @@ dependencies = [ "regex", "regex-automata", "reqwest", - "rig-bedrock", "rig-core", "rustsec", "rustyline", + "schemars 0.8.22", "serde", "serde_json", "serde_yaml", @@ -4900,6 +4887,7 @@ dependencies = [ "thiserror 2.0.12", "tokio", "toml 0.9.6", + "tracing", "uuid", "walkdir", "yaml-rust2", @@ -5196,7 +5184,6 @@ dependencies = [ "bytes", "libc", "mio 1.0.4", - "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.6.0", diff --git a/Cargo.toml b/Cargo.toml index c7846a3b..11954fec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,8 +73,16 @@ rand = "0.8" futures-util = "0.3" # Agent dependencies (using Rig - LLM application framework) -rig-core = { version = "0.27", features = ["derive"] } -rig-bedrock = { version = "0.3", path = "vendor/rig-bedrock" } # Vendored with fix for extended thinking + tool calls +rig-core = { version = "0.27", features = ["derive", "image"] } + +# AWS Bedrock dependencies (inlined bedrock module with extended thinking fixes) +async-stream = "0.3" +aws-config = { version = "1", features = ["behavior-version-latest"] } +aws-sdk-bedrockruntime = "1" +aws-smithy-types = "1" +base64 = "0.22" +schemars = "0.8" +tracing = "0.1" # Diff rendering for file confirmation UI similar = "2.6" @@ -107,8 +115,3 @@ path = "examples/check_vulnerabilities.rs" name = "security_analysis" path = "examples/security_analysis.rs" -# Patch rig-bedrock to fix extended thinking support with tool use -# The upstream version drops Reasoning blocks when a tool call is present. -# See: vendor/rig-bedrock/src/types/assistant_content.rs for the fix. -[patch.crates-io] -rig-bedrock = { version = "0.3", path = "vendor/rig-bedrock" } diff --git a/src/agent/mod.rs b/src/agent/mod.rs index 2eceb709..0267079b 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -495,7 +495,7 @@ pub async fn run_interactive( } ProviderType::Bedrock => { // Bedrock provider via rig-bedrock - same pattern as OpenAI/Anthropic - let client = rig_bedrock::client::Client::from_env(); + let client = crate::bedrock::client::Client::from_env(); // Extended thinking for Claude models via Bedrock // This enables Claude to show its reasoning process before responding. @@ -1477,7 +1477,7 @@ pub async fn run_query( } ProviderType::Bedrock => { // Bedrock provider via rig-bedrock - same pattern as Anthropic - let client = rig_bedrock::client::Client::from_env(); + let client = crate::bedrock::client::Client::from_env(); let model_name = model .as_deref() .unwrap_or("global.anthropic.claude-sonnet-4-5-20250929-v1:0"); diff --git a/vendor/rig-bedrock/src/client.rs b/src/bedrock/client.rs similarity index 97% rename from vendor/rig-bedrock/src/client.rs rename to src/bedrock/client.rs index 0ca24399..e28577b2 100644 --- a/vendor/rig-bedrock/src/client.rs +++ b/src/bedrock/client.rs @@ -1,5 +1,5 @@ -use crate::image::ImageGenerationModel; -use crate::{completion::CompletionModel, embedding::EmbeddingModel}; +use super::image::ImageGenerationModel; +use super::{completion::CompletionModel, embedding::EmbeddingModel}; use aws_config::{BehaviorVersion, Region}; use rig::client::Nothing; use rig::prelude::*; diff --git a/vendor/rig-bedrock/src/completion.rs b/src/bedrock/completion.rs similarity index 99% rename from vendor/rig-bedrock/src/completion.rs rename to src/bedrock/completion.rs index 2892d11c..e58ba03c 100644 --- a/vendor/rig-bedrock/src/completion.rs +++ b/src/bedrock/completion.rs @@ -1,6 +1,6 @@ //! All supported models -use crate::{ +use super::{ client::Client, types::{ assistant_content::AwsConverseOutput, completion_request::AwsCompletionRequest, @@ -173,7 +173,7 @@ impl CompletionModel { impl completion::CompletionModel for CompletionModel { type Response = AwsConverseOutput; - type StreamingResponse = crate::streaming::BedrockStreamingResponse; + type StreamingResponse = super::streaming::BedrockStreamingResponse; type Client = Client; diff --git a/vendor/rig-bedrock/src/embedding.rs b/src/bedrock/embedding.rs similarity index 98% rename from vendor/rig-bedrock/src/embedding.rs rename to src/bedrock/embedding.rs index 9ed148bf..898217dd 100644 --- a/vendor/rig-bedrock/src/embedding.rs +++ b/src/bedrock/embedding.rs @@ -2,7 +2,7 @@ use aws_smithy_types::Blob; use rig::embeddings::{self, Embedding, EmbeddingError}; use serde::{Deserialize, Serialize}; -use crate::{client::Client, types::errors::AwsSdkInvokeModelError}; +use super::{client::Client, types::errors::AwsSdkInvokeModelError}; #[derive(Serialize)] #[serde(rename_all = "camelCase")] diff --git a/vendor/rig-bedrock/src/image.rs b/src/bedrock/image.rs similarity index 94% rename from vendor/rig-bedrock/src/image.rs rename to src/bedrock/image.rs index ed5cee1a..d3397cb2 100644 --- a/vendor/rig-bedrock/src/image.rs +++ b/src/bedrock/image.rs @@ -1,6 +1,6 @@ -use crate::client::Client; -use crate::types::errors::AwsSdkInvokeModelError; -use crate::types::text_to_image::{TextToImageGeneration, TextToImageResponse}; +use super::client::Client; +use super::types::errors::AwsSdkInvokeModelError; +use super::types::text_to_image::{TextToImageGeneration, TextToImageResponse}; use aws_smithy_types::Blob; use rig::image_generation::{ self, ImageGenerationError, ImageGenerationRequest, ImageGenerationResponse, diff --git a/vendor/rig-bedrock/src/lib.rs b/src/bedrock/mod.rs similarity index 100% rename from vendor/rig-bedrock/src/lib.rs rename to src/bedrock/mod.rs diff --git a/vendor/rig-bedrock/src/streaming.rs b/src/bedrock/streaming.rs similarity index 99% rename from vendor/rig-bedrock/src/streaming.rs rename to src/bedrock/streaming.rs index a2c54e1a..29d15add 100644 --- a/vendor/rig-bedrock/src/streaming.rs +++ b/src/bedrock/streaming.rs @@ -1,5 +1,5 @@ -use crate::types::completion_request::AwsCompletionRequest; -use crate::{completion::CompletionModel, types::errors::AwsSdkConverseStreamError}; +use super::types::completion_request::AwsCompletionRequest; +use super::{completion::CompletionModel, types::errors::AwsSdkConverseStreamError}; use async_stream::stream; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::completion::GetTokenUsage; diff --git a/vendor/rig-bedrock/src/types/assistant_content.rs b/src/bedrock/types/assistant_content.rs similarity index 86% rename from vendor/rig-bedrock/src/types/assistant_content.rs rename to src/bedrock/types/assistant_content.rs index c6650ce8..fc79a561 100644 --- a/vendor/rig-bedrock/src/types/assistant_content.rs +++ b/src/bedrock/types/assistant_content.rs @@ -6,7 +6,7 @@ use rig::{ }; use serde::{Deserialize, Serialize}; -use crate::types::message::RigMessage; +use super::message::RigMessage; use super::{converse_output::InternalConverseOutput, json::AwsDocument}; use rig::completion; @@ -78,6 +78,29 @@ impl TryFrom for RigAssistantContent { type Error = CompletionError; fn try_from(value: aws_bedrock::ContentBlock) -> Result { + // Debug: Log incoming AWS content block + let block_type = match &value { + aws_bedrock::ContentBlock::Text(t) => format!("Text(len={})", t.len()), + aws_bedrock::ContentBlock::ToolUse(t) => { + format!("ToolUse(id={}, name={})", t.tool_use_id, t.name) + } + aws_bedrock::ContentBlock::ReasoningContent(r) => match r { + aws_bedrock::ReasoningContentBlock::ReasoningText(rt) => format!( + "ReasoningContent::ReasoningText(len={}, has_sig={})", + rt.text.len(), + rt.signature.is_some() + ), + aws_bedrock::ReasoningContentBlock::RedactedContent(blob) => format!( + "ReasoningContent::RedactedContent(blob_len={})", + blob.as_ref().len() + ), + _ => "ReasoningContent::Unknown".to_string(), + }, + aws_bedrock::ContentBlock::ToolResult(_) => "ToolResult".to_string(), + _ => "Other".to_string(), + }; + tracing::debug!("Converting AWS ContentBlock to Rig: {}", block_type); + match value { aws_bedrock::ContentBlock::Text(text) => { Ok(RigAssistantContent(AssistantContent::Text(Text { text }))) @@ -91,18 +114,42 @@ impl TryFrom for RigAssistantContent { )), aws_bedrock::ContentBlock::ReasoningContent(reasoning_block) => match reasoning_block { aws_bedrock::ReasoningContentBlock::ReasoningText(reasoning_text) => { + tracing::debug!( + "Converting ReasoningText: text_len={}, signature={:?}", + reasoning_text.text.len(), + reasoning_text + .signature + .as_ref() + .map(|s| format!("{}...", &s[..s.len().min(20)])) + ); Ok(RigAssistantContent(AssistantContent::Reasoning( rig::message::Reasoning::new(&reasoning_text.text) .with_signature(reasoning_text.signature), ))) } - _ => Err(CompletionError::ProviderError( - "AWS Bedrock returned unsupported ReasoningContentBlock variant".into(), - )), + aws_bedrock::ReasoningContentBlock::RedactedContent(blob) => { + tracing::warn!( + "AWS Bedrock returned RedactedContent (blob_len={}). This variant is not yet supported!", + blob.as_ref().len() + ); + Err(CompletionError::ProviderError(format!( + "AWS Bedrock returned RedactedContent (blob_len={}). This variant needs to be handled for multi-turn conversations with extended thinking.", + blob.as_ref().len() + ))) + } + _ => { + tracing::error!("AWS Bedrock returned unknown ReasoningContentBlock variant"); + Err(CompletionError::ProviderError( + "AWS Bedrock returned unsupported ReasoningContentBlock variant".into(), + )) + } }, - _ => Err(CompletionError::ProviderError( - "AWS Bedrock returned unsupported ContentBlock".into(), - )), + _ => { + tracing::warn!("AWS Bedrock returned unsupported ContentBlock type"); + Err(CompletionError::ProviderError( + "AWS Bedrock returned unsupported ContentBlock".into(), + )) + } } } } @@ -190,12 +237,9 @@ impl TryFrom for aws_bedrock::ContentBlock { #[cfg(test)] mod tests { - use crate::types::{ - assistant_content::RigAssistantContent, converse_output::InternalConverseOutput, - errors::TypeConversionError, - }; - + use super::super::{converse_output::InternalConverseOutput, errors::TypeConversionError}; use super::AwsConverseOutput; + use super::RigAssistantContent; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{OneOrMany, completion, message::AssistantContent}; diff --git a/vendor/rig-bedrock/src/types/completion_request.rs b/src/bedrock/types/completion_request.rs similarity index 99% rename from vendor/rig-bedrock/src/types/completion_request.rs rename to src/bedrock/types/completion_request.rs index 211a8bd1..7ddf7f8f 100644 --- a/vendor/rig-bedrock/src/types/completion_request.rs +++ b/src/bedrock/types/completion_request.rs @@ -1,5 +1,5 @@ -use crate::types::json::AwsDocument; -use crate::types::message::RigMessage; +use super::json::AwsDocument; +use super::message::RigMessage; use aws_sdk_bedrockruntime::types as aws_bedrock; use aws_sdk_bedrockruntime::types::{ InferenceConfiguration, SystemContentBlock, Tool, ToolConfiguration, ToolInputSchema, diff --git a/vendor/rig-bedrock/src/types/converse_output.rs b/src/bedrock/types/converse_output.rs similarity index 100% rename from vendor/rig-bedrock/src/types/converse_output.rs rename to src/bedrock/types/converse_output.rs diff --git a/vendor/rig-bedrock/src/types/document.rs b/src/bedrock/types/document.rs similarity index 98% rename from vendor/rig-bedrock/src/types/document.rs rename to src/bedrock/types/document.rs index 8b85384c..c8eaa293 100644 --- a/vendor/rig-bedrock/src/types/document.rs +++ b/src/bedrock/types/document.rs @@ -4,7 +4,7 @@ use rig::{ message::{Document, DocumentSourceKind}, }; -pub(crate) use crate::types::media_types::RigDocumentMediaType; +pub(crate) use super::media_types::RigDocumentMediaType; use base64::{Engine, prelude::BASE64_STANDARD}; use uuid::Uuid; @@ -95,7 +95,7 @@ mod tests { message::{Document, DocumentMediaType, DocumentSourceKind}, }; - use crate::types::document::RigDocument; + use super::RigDocument; #[test] fn test_document_to_aws_document() { diff --git a/vendor/rig-bedrock/src/types/errors.rs b/src/bedrock/types/errors.rs similarity index 100% rename from vendor/rig-bedrock/src/types/errors.rs rename to src/bedrock/types/errors.rs diff --git a/vendor/rig-bedrock/src/types/image.rs b/src/bedrock/types/image.rs similarity index 99% rename from vendor/rig-bedrock/src/types/image.rs rename to src/bedrock/types/image.rs index c2b8cf4b..682c50c2 100644 --- a/vendor/rig-bedrock/src/types/image.rs +++ b/src/bedrock/types/image.rs @@ -92,7 +92,7 @@ mod tests { message::{DocumentSourceKind, Image, ImageMediaType}, }; - use crate::types::image::RigImage; + use super::RigImage; #[test] fn test_image_to_aws_image() { diff --git a/vendor/rig-bedrock/src/types/json.rs b/src/bedrock/types/json.rs similarity index 99% rename from vendor/rig-bedrock/src/types/json.rs rename to src/bedrock/types/json.rs index ce8856da..710c954b 100644 --- a/vendor/rig-bedrock/src/types/json.rs +++ b/src/bedrock/types/json.rs @@ -85,7 +85,7 @@ mod tests { use aws_smithy_types::{Document, Number}; use serde_json::Value; - use crate::types::json::AwsDocument; + use super::AwsDocument; #[test] fn test_json_to_aws_document() { diff --git a/vendor/rig-bedrock/src/types/media_types.rs b/src/bedrock/types/media_types.rs similarity index 100% rename from vendor/rig-bedrock/src/types/media_types.rs rename to src/bedrock/types/media_types.rs diff --git a/vendor/rig-bedrock/src/types/message.rs b/src/bedrock/types/message.rs similarity index 67% rename from vendor/rig-bedrock/src/types/message.rs rename to src/bedrock/types/message.rs index f6530d20..953c3c6d 100644 --- a/vendor/rig-bedrock/src/types/message.rs +++ b/src/bedrock/types/message.rs @@ -30,12 +30,51 @@ impl TryFrom for aws_bedrock::Message { .map_err(|e| CompletionError::RequestError(Box::new(e)))? } Message::Assistant { content, .. } => { + // Debug: Log what we're converting from Rig to AWS format + tracing::debug!( + "Converting Assistant message with {} content blocks to AWS format", + content.len() + ); + for (i, c) in content.iter().enumerate() { + let type_name = match c { + AssistantContent::Reasoning(r) => format!( + "Reasoning(len={}, has_sig={})", + r.reasoning.len(), + r.signature.is_some() + ), + AssistantContent::ToolCall(t) => { + format!("ToolCall(id={}, name={})", t.id, t.function.name) + } + AssistantContent::Text(t) => format!("Text(len={})", t.text.len()), + AssistantContent::Image(_) => "Image".to_string(), + }; + tracing::debug!(" Input content[{}]: {}", i, type_name); + } + // Convert all content blocks let mut content_blocks: Vec = content .into_iter() .map(|content| RigAssistantContent(content).try_into()) .collect::, _>>()?; + // Debug: Log converted blocks before sorting + tracing::debug!( + "Converted {} content blocks, before sorting:", + content_blocks.len() + ); + for (i, block) in content_blocks.iter().enumerate() { + let type_name = match block { + aws_bedrock::ContentBlock::ReasoningContent(_) => "ReasoningContent", + aws_bedrock::ContentBlock::ToolUse(t) => { + tracing::debug!(" ToolUse: id={}, name={}", t.tool_use_id, t.name); + "ToolUse" + } + aws_bedrock::ContentBlock::Text(_) => "Text", + _ => "Other", + }; + tracing::debug!(" Block[{}]: {}", i, type_name); + } + // CRITICAL: Sort to put Reasoning blocks FIRST // AWS Bedrock requires assistant messages to start with thinking blocks // when extended thinking is enabled. Without this, multi-turn conversations @@ -48,6 +87,18 @@ impl TryFrom for aws_bedrock::Message { _ => 3, }); + // Debug: Log after sorting + tracing::debug!("After sorting, content block order:"); + for (i, block) in content_blocks.iter().enumerate() { + let type_name = match block { + aws_bedrock::ContentBlock::ReasoningContent(_) => "ReasoningContent", + aws_bedrock::ContentBlock::ToolUse(_) => "ToolUse", + aws_bedrock::ContentBlock::Text(_) => "Text", + _ => "Other", + }; + tracing::debug!(" Block[{}]: {}", i, type_name); + } + aws_bedrock::Message::builder() .role(aws_bedrock::ConversationRole::Assistant) .set_content(Some(content_blocks)) @@ -113,7 +164,7 @@ impl TryFrom for RigMessage { #[cfg(test)] mod tests { - use crate::types::message::RigMessage; + use super::RigMessage; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ OneOrMany, diff --git a/vendor/rig-bedrock/src/types/mod.rs b/src/bedrock/types/mod.rs similarity index 100% rename from vendor/rig-bedrock/src/types/mod.rs rename to src/bedrock/types/mod.rs diff --git a/vendor/rig-bedrock/src/types/text_to_image.rs b/src/bedrock/types/text_to_image.rs similarity index 100% rename from vendor/rig-bedrock/src/types/text_to_image.rs rename to src/bedrock/types/text_to_image.rs diff --git a/vendor/rig-bedrock/src/types/tool.rs b/src/bedrock/types/tool.rs similarity index 98% rename from vendor/rig-bedrock/src/types/tool.rs rename to src/bedrock/types/tool.rs index 43e68d8e..908a5331 100644 --- a/vendor/rig-bedrock/src/types/tool.rs +++ b/src/bedrock/types/tool.rs @@ -60,7 +60,7 @@ mod tests { message::{DocumentSourceKind, Image, ImageMediaType, Text, ToolResultContent}, }; - use crate::types::tool::RigToolResultContent; + use super::RigToolResultContent; #[test] fn rig_tool_text_to_aws_tool() { diff --git a/vendor/rig-bedrock/src/types/user_content.rs b/src/bedrock/types/user_content.rs similarity index 99% rename from vendor/rig-bedrock/src/types/user_content.rs rename to src/bedrock/types/user_content.rs index a6b2d86f..308d93f4 100644 --- a/vendor/rig-bedrock/src/types/user_content.rs +++ b/src/bedrock/types/user_content.rs @@ -97,7 +97,7 @@ impl TryFrom for Vec { #[cfg(test)] mod tests { - use crate::types::user_content::RigUserContent; + use super::RigUserContent; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ OneOrMany, diff --git a/src/lib.rs b/src/lib.rs index 9c61bd5d..176404f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod agent; pub mod analyzer; +pub mod bedrock; // Inlined rig-bedrock with extended thinking fixes pub mod cli; pub mod common; pub mod config; diff --git a/vendor/rig-bedrock/CHANGELOG.md b/vendor/rig-bedrock/CHANGELOG.md deleted file mode 100644 index cf62ef70..00000000 --- a/vendor/rig-bedrock/CHANGELOG.md +++ /dev/null @@ -1,188 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [0.3.9](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.8...rig-bedrock-v0.3.9) - 2025-12-15 - -### Other - -- ToolCall Signature and additional parameters ([#1154](https://github.com/0xPlaygrounds/rig/pull/1154)) -- *(rig-1090)* crate re-org ([#1145](https://github.com/0xPlaygrounds/rig/pull/1145)) - -## [0.3.8](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.7...rig-bedrock-v0.3.8) - 2025-12-04 - -### Other - -- updated the following local packages: rig-core - -## [0.3.7](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.6...rig-bedrock-v0.3.7) - 2025-12-01 - -### Added - -- Gemini Assistant Image Responses ([#1048](https://github.com/0xPlaygrounds/rig/pull/1048)) -- *(rig-985)* Consolidate provider clients ([#1050](https://github.com/0xPlaygrounds/rig/pull/1050)) - -### Fixed - -- *(rig-1050)* Inconsistent model/agent initialisation methods ([#1069](https://github.com/0xPlaygrounds/rig/pull/1069)) - -### Other - -- Deprecate `DynClientBuilder` ([#1105](https://github.com/0xPlaygrounds/rig/pull/1105)) - -## [0.3.6](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.5...rig-bedrock-v0.3.6) - 2025-11-10 - -### Added - -- *(providers)* Emit tool call deltas ([#1020](https://github.com/0xPlaygrounds/rig/pull/1020)) - -## [0.3.5](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.4...rig-bedrock-v0.3.5) - 2025-10-28 - -### Other - -- updated the following local packages: rig-core - -## [0.3.4](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.3...rig-bedrock-v0.3.4) - 2025-10-27 - -### Added - -- *(bedrock)* Support streaming thinking ([#946](https://github.com/0xPlaygrounds/rig/pull/946)) -- *(bedrock)* Implement usage ([#934](https://github.com/0xPlaygrounds/rig/pull/934)) - -### Other - -- Fix bedrock tool calls with zero arguments ([#989](https://github.com/0xPlaygrounds/rig/pull/989)) -- Dependent packages no longer force unnecessary features on rig-core ([#964](https://github.com/0xPlaygrounds/rig/pull/964)) - -## [0.3.3](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.2...rig-bedrock-v0.3.3) - 2025-10-14 - -### Added - -- *(rig-973)* DocumentSourceKind::String ([#882](https://github.com/0xPlaygrounds/rig/pull/882)) - -### Other - -- provider SDK has issue with DocumentBlock ([#892](https://github.com/0xPlaygrounds/rig/pull/892)) - -## [0.3.2](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.1...rig-bedrock-v0.3.2) - 2025-09-29 - -### Added - -- *(rig-795)* support file URLs for audio, video, documents ([#823](https://github.com/0xPlaygrounds/rig/pull/823)) - -### Other - -- *(rig-963)* fix feature regression in AWS bedrock ([#863](https://github.com/0xPlaygrounds/rig/pull/863)) - -## [0.3.1](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.3.0...rig-bedrock-v0.3.1) - 2025-09-15 - -### Added - -- *(rig-931)* support file input for images on Gemini ([#790](https://github.com/0xPlaygrounds/rig/pull/790)) - -## [0.3.0](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.9...rig-bedrock-v0.3.0) - 2025-09-02 - -### Added - -- VerifyClient trait ([#724](https://github.com/0xPlaygrounds/rig/pull/724)) - -### Other - -- added AWS Bedrock client creation using from_env ([#710](https://github.com/0xPlaygrounds/rig/pull/710)) - -## [0.2.9](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.8...rig-bedrock-v0.2.9) - 2025-08-20 - -### Other - -- updated the following local packages: rig-core - -## [0.2.8](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.7...rig-bedrock-v0.2.8) - 2025-08-19 - -### Other - -- updated the following local packages: rig-core - -## [0.2.7](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.6...rig-bedrock-v0.2.7) - 2025-08-19 - -### Added - -- *(rig-865)* multi turn streaming ([#712](https://github.com/0xPlaygrounds/rig/pull/712)) -- video input for gemini ([#690](https://github.com/0xPlaygrounds/rig/pull/690)) - -## [0.2.6](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.5...rig-bedrock-v0.2.6) - 2025-08-05 - -### Other - -- updated the following local packages: rig-core - -## [0.2.5](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.4...rig-bedrock-v0.2.5) - 2025-08-05 - -### Other - -- updated the following local packages: rig-core - -## [0.2.4](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.3...rig-bedrock-v0.2.4) - 2025-07-30 - -### Added - -- *(rig-812)* yield final response with total usage metrics from streaming completion response in stream impl ([#584](https://github.com/0xPlaygrounds/rig/pull/584)) -- *(rig-784)* thinking/reasoning ([#557](https://github.com/0xPlaygrounds/rig/pull/557)) - -## [0.2.3](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.2...rig-bedrock-v0.2.3) - 2025-07-16 - -### Other - -- updated the following local packages: rig-core - -## [0.2.2](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.1...rig-bedrock-v0.2.2) - 2025-07-14 - -### Added - -- *(rig-801)* DynClientBuilder::from_values ([#556](https://github.com/0xPlaygrounds/rig/pull/556)) -- add `.extended_details` to `PromptRequest` ([#555](https://github.com/0xPlaygrounds/rig/pull/555)) - -## [0.2.1](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.2.0...rig-bedrock-v0.2.1) - 2025-07-07 - -### Added - -- *(rig-780)* integrate openAI responses API ([#508](https://github.com/0xPlaygrounds/rig/pull/508)) - -### Other - -- Migrate all crates to Rust 2024 ([#539](https://github.com/0xPlaygrounds/rig/pull/539)) -- Declare shared dependencies in workspace ([#538](https://github.com/0xPlaygrounds/rig/pull/538)) -- Make clippy happy on all targets ([#542](https://github.com/0xPlaygrounds/rig/pull/542)) - -## [0.2.0](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.1.3...rig-bedrock-v0.2.0) - 2025-06-09 - -### Added - -- Improve Streaming API ([#388](https://github.com/0xPlaygrounds/rig/pull/388)) - -### Other - -- Introduce Client Traits and Testing ([#440](https://github.com/0xPlaygrounds/rig/pull/440)) - -## [0.1.3](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.1.2...rig-bedrock-v0.1.3) - 2025-04-30 - -### Fixed - -- fixed bug with base64 encoding on AWS Bedrock ([#432](https://github.com/0xPlaygrounds/rig/pull/432)) - -## [0.1.2](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.1.1...rig-bedrock-v0.1.2) - 2025-04-29 - -### Added - -- multi-turn / reasoning loops + parallel tool calling ([#370](https://github.com/0xPlaygrounds/rig/pull/370)) -- support custom clients for bedrock ([#403](https://github.com/0xPlaygrounds/rig/pull/403)) - -## [0.1.1](https://github.com/0xPlaygrounds/rig/compare/rig-bedrock-v0.1.0...rig-bedrock-v0.1.1) - 2025-04-12 - -### Other - -- updated the following local packages: rig-derive diff --git a/vendor/rig-bedrock/Cargo.toml b/vendor/rig-bedrock/Cargo.toml deleted file mode 100644 index a5e7f9d1..00000000 --- a/vendor/rig-bedrock/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "rig-bedrock" -version = "0.3.9" -edition = "2024" -license = "MIT" -readme = "README.md" -description = "AWS Bedrock model provider for Rig integration (vendored with extended thinking fix)" - -[dependencies] -async-stream = "0.3" -aws-config = { version = "1", features = ["behavior-version-latest"] } -aws-sdk-bedrockruntime = "1" -aws-smithy-types = "1" -base64 = "0.22" -rig-core = { version = "0.27", default-features = false, features = ["image"] } -schemars = "0.8" -serde = { version = "1", features = ["derive"] } -serde_json = "1" -tokio = { version = "1", features = ["full"] } -tracing = "0.1" -uuid = { version = "1", features = ["v4"] } - -[dev-dependencies] -anyhow = "1" -reqwest = { version = "0.12", features = ["json", "stream"] } -tracing-subscriber = "0.3" diff --git a/vendor/rig-bedrock/README.md b/vendor/rig-bedrock/README.md deleted file mode 100644 index 9da9048b..00000000 --- a/vendor/rig-bedrock/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## Rig-Bedrock -This companion crate integrates AWS Bedrock as model provider with Rig. - -## Usage - -Add the companion crate to your `Cargo.toml`, along with the rig-core crate: - -```toml -[dependencies] -rig-bedrock = "0.1.0" -rig-core = "0.9.1" -``` - -You can also run `cargo add rig-bedrock rig-core` to add the most recent versions of the dependencies to your project. - -See the [`/examples`](./examples) folder for usage examples. - -Make sure to have AWS credentials env vars loaded before starting client such as: -```shell -export AWS_DEFAULT_REGION=us-east-1 -export AWS_SECRET_ACCESS_KEY=....... -export AWS_ACCESS_KEY_ID=...... -``` diff --git a/vendor/rig-bedrock/examples/agent_with_bedrock.rs b/vendor/rig-bedrock/examples/agent_with_bedrock.rs deleted file mode 100644 index a3b56dc1..00000000 --- a/vendor/rig-bedrock/examples/agent_with_bedrock.rs +++ /dev/null @@ -1,119 +0,0 @@ -use rig::client::{CompletionClient, ProviderClient}; -use rig::{agent::AgentBuilder, completion::Prompt, loaders::FileLoader}; -use rig_bedrock::{client::Client, completion::AMAZON_NOVA_LITE}; -use tracing::info; - -mod common; - -/// Runs 4 agents based on AWS Bedrock (derived from the agent_with_grok example) -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_target(false) - .init(); - - info!("Running basic agent"); - basic().await?; - - info!("\nRunning agent with tools"); - tools().await?; - - info!("\nRunning agent with loaders"); - loaders().await?; - - info!("\nRunning agent with context"); - context().await?; - - info!("\n\nAll agents ran successfully"); - Ok(()) -} - -fn client() -> Client { - Client::from_env() -} - -async fn partial_agent() -> AgentBuilder { - let client = client(); - client.agent(AMAZON_NOVA_LITE) -} - -/// Create an AWS Bedrock agent with a system prompt -async fn basic() -> Result<(), anyhow::Error> { - let agent = partial_agent() - .await - .preamble("Answer with json format only") - .build(); - - let response = agent.prompt("Describe solar system").await?; - info!("{}", response); - - Ok(()) -} - -/// Create an AWS Bedrock with tools -async fn tools() -> Result<(), anyhow::Error> { - let calculator_agent = partial_agent() - .await - .preamble("You must only do math by using a tool.") - .max_tokens(1024) - .tool(common::Adder) - .build(); - - info!( - "Calculator Agent: add 400 and 20\nResult: {}", - calculator_agent.prompt("add 400 and 20").await? - ); - - Ok(()) -} - -async fn context() -> Result<(), anyhow::Error> { - let model = client().completion_model(AMAZON_NOVA_LITE); - - // Create an agent with multiple context documents - let agent = AgentBuilder::new(model) - .preamble("Answer the question") - .context("Definition of a *flurbo*: A flurbo is a green alien that lives on cold planets") - .context("Definition of a *glarb-glarb*: A glarb-glarb is a ancient tool used by the ancestors of the inhabitants of planet Jiro to farm the land.") - .context("Definition of a *linglingdong*: A term used by inhabitants of the far side of the moon to describe humans.") - .build(); - - // Prompt the agent and print the response - let response = agent.prompt("What does \"glarb-glarb\" mean?").await?; - - info!("What does \"glarb-glarb\" mean?\n{}", response); - - Ok(()) -} - -/// Based upon the `loaders` example -/// -/// This example loads in all the rust examples from the rig-core crate and uses them as\\ -/// context for the agent -async fn loaders() -> Result<(), anyhow::Error> { - let model = client().completion_model(AMAZON_NOVA_LITE); - - // Load in all the rust examples - let examples = FileLoader::with_glob("rig-core/examples/*.rs")? - .read_with_path() - .ignore_errors() - .into_iter(); - - // Create an agent with multiple context documents - let agent = examples - .fold(AgentBuilder::new(model), |builder, (path, content)| { - builder.context(format!("Rust Example {path:?}:\n{content}").as_str()) - }) - .preamble("Answer the question") - .build(); - - // Prompt the agent and print the response - let response = agent - .prompt("Which rust example is best suited for the operation 1 + 2") - .await?; - - info!("{}", response); - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/common/mod.rs b/vendor/rig-bedrock/examples/common/mod.rs deleted file mode 100644 index 6cc9468b..00000000 --- a/vendor/rig-bedrock/examples/common/mod.rs +++ /dev/null @@ -1,60 +0,0 @@ -use std::{ - error::Error, - fmt::{Display, Formatter}, -}; - -use rig::{completion::ToolDefinition, tool::Tool}; -use serde::{Deserialize, Serialize}; -use serde_json::json; - -#[derive(Deserialize)] -pub struct OperationArgs { - x: i32, - y: i32, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MathError {} - -impl Display for MathError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "Math error") - } -} - -impl Error for MathError {} - -#[derive(Deserialize, Serialize)] -pub struct Adder; -impl Tool for Adder { - const NAME: &'static str = "add"; - - type Error = MathError; - type Args = OperationArgs; - type Output = i32; - - async fn definition(&self, _prompt: String) -> ToolDefinition { - ToolDefinition { - name: "add".to_string(), - description: "Add x and y together".to_string(), - parameters: json!({ - "type": "object", - "properties": { - "x": { - "type": "number", - "description": "The first number to add" - }, - "y": { - "type": "number", - "description": "The second number to add" - } - } - }), - } - } - - async fn call(&self, args: Self::Args) -> Result { - let result = args.x + args.y; - Ok(result) - } -} diff --git a/vendor/rig-bedrock/examples/document_with_bedrock.rs b/vendor/rig-bedrock/examples/document_with_bedrock.rs deleted file mode 100644 index be492002..00000000 --- a/vendor/rig-bedrock/examples/document_with_bedrock.rs +++ /dev/null @@ -1,49 +0,0 @@ -use rig::{ - completion::{Prompt, message::Document}, - message::{DocumentMediaType, DocumentSourceKind}, -}; - -use base64::{Engine, prelude::BASE64_STANDARD}; -use rig::client::{CompletionClient, ProviderClient}; -use rig_bedrock::client::Client; -use rig_bedrock::completion::AMAZON_NOVA_LITE; -use tracing::info; - -const DOCUMENT_URL: &str = "https://bitcoin.org/bitcoin.pdf"; - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .without_time() - .with_level(false) - .with_target(false) - .init(); - - let client = Client::from_env(); - let agent = client - .agent(AMAZON_NOVA_LITE) - .preamble("Describe this document") - .temperature(0.5) - .build(); - - let reqwest_client = reqwest::Client::new(); - let response = reqwest_client.get(DOCUMENT_URL).send().await?; - - info!("Status: {}", response.status().as_str()); - info!("Content Type: {:?}", response.headers().get("Content-Type")); - - let document_bytes = response.bytes().await?; - let bytes_base64 = BASE64_STANDARD.encode(document_bytes); - - let document = Document { - data: DocumentSourceKind::Base64(bytes_base64), - media_type: Some(DocumentMediaType::PDF), - additional_params: None, - }; - - let response = agent.prompt(document).await?; - info!("{}", response); - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/embedding_with_bedrock.rs b/vendor/rig-bedrock/examples/embedding_with_bedrock.rs deleted file mode 100644 index 606d2424..00000000 --- a/vendor/rig-bedrock/examples/embedding_with_bedrock.rs +++ /dev/null @@ -1,35 +0,0 @@ -use rig::Embed; -use rig::client::{EmbeddingsClient, ProviderClient}; -use rig_bedrock::client::Client; -use rig_bedrock::embedding::AMAZON_TITAN_EMBED_TEXT_V2_0; -use tracing::info; - -#[derive(rig_derive::Embed, Debug)] -struct Greetings { - #[embed] - message: String, -} - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_target(false) - .init(); - - let client = Client::from_env(); - let embeddings = client - .embeddings_with_ndims(AMAZON_TITAN_EMBED_TEXT_V2_0, 256) - .document(Greetings { - message: "aa".to_string(), - })? - .document(Greetings { - message: "bb".to_string(), - })? - .build() - .await?; - - info!("{:?}", embeddings); - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/extractor_with_bedrock.rs b/vendor/rig-bedrock/examples/extractor_with_bedrock.rs deleted file mode 100644 index db163a4a..00000000 --- a/vendor/rig-bedrock/examples/extractor_with_bedrock.rs +++ /dev/null @@ -1,33 +0,0 @@ -use rig::client::{CompletionClient, ProviderClient}; -use rig_bedrock::client::Client; -use rig_bedrock::completion::AMAZON_NOVA_LITE; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use tracing::info; - -#[derive(Debug, Deserialize, JsonSchema, Serialize)] -struct Person { - pub first_name: Option, - pub last_name: Option, - pub job: Option, -} - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_target(false) - .init(); - - let client = Client::from_env(); - let data_extractor = client.extractor::(AMAZON_NOVA_LITE).build(); - let person = data_extractor - .extract("Hello my name is John Doe! I am a software engineer.") - .await?; - - info!( - "AWS Bedrock: {}", - serde_json::to_string_pretty(&person).unwrap() - ); - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/image_generator.rs b/vendor/rig-bedrock/examples/image_generator.rs deleted file mode 100644 index a933eacd..00000000 --- a/vendor/rig-bedrock/examples/image_generator.rs +++ /dev/null @@ -1,27 +0,0 @@ -use rig::client::ProviderClient; -use rig::client::image_generation::ImageGenerationClient; -use rig::image_generation::ImageGenerationModel; -use rig_bedrock::client::Client; -use rig_bedrock::image::AMAZON_NOVA_CANVAS; -use std::fs::File; -use std::io::Write; -use std::path::Path; - -const DEFAULT_PATH: &str = "./output.png"; - -#[tokio::main] -async fn main() { - let client = Client::from_env(); - let image_generation_model = client.image_generation_model(AMAZON_NOVA_CANVAS); - let response = image_generation_model - .image_generation_request() - .prompt("A castle sitting upon a large mountain, overlooking the water.") - .width(512) - .height(512) - .send() - .await; - - // save image - let mut file = File::create_new(Path::new(&DEFAULT_PATH)).expect("Failed to create file"); - let _ = file.write(&response.unwrap().image); -} diff --git a/vendor/rig-bedrock/examples/image_with_bedrock.rs b/vendor/rig-bedrock/examples/image_with_bedrock.rs deleted file mode 100644 index 3fa6724e..00000000 --- a/vendor/rig-bedrock/examples/image_with_bedrock.rs +++ /dev/null @@ -1,46 +0,0 @@ -use reqwest::Client; - -use rig::{ - completion::{Prompt, message::Image}, - message::{DocumentSourceKind, ImageMediaType}, -}; - -use base64::{Engine, prelude::BASE64_STANDARD}; -use rig::client::{CompletionClient, ProviderClient}; -use rig_bedrock::completion::AMAZON_NOVA_LITE; -use tracing::info; - -const IMAGE_URL: &str = "https://playgrounds.network/assets/PG-Logo.png"; - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_target(false) - .init(); - - let client = rig_bedrock::client::Client::from_env(); - let agent = client - .agent(AMAZON_NOVA_LITE) - .preamble("You are an image describer.") - .temperature(0.5) - .build(); - - // Grab image and convert to base64 - let reqwest_client = Client::new(); - let image_bytes = reqwest_client.get(IMAGE_URL).send().await?.bytes().await?; - let image_base64 = BASE64_STANDARD.encode(image_bytes); - - // Compose `Image` for prompt - let image = Image { - data: DocumentSourceKind::base64(&image_base64), - media_type: Some(ImageMediaType::PNG), - ..Default::default() - }; - - // Prompt the agent and print the response - let response = agent.prompt(image).await?; - info!("{}", response); - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/rag_with_bedrock.rs b/vendor/rig-bedrock/examples/rag_with_bedrock.rs deleted file mode 100644 index 026f1be7..00000000 --- a/vendor/rig-bedrock/examples/rag_with_bedrock.rs +++ /dev/null @@ -1,86 +0,0 @@ -use std::vec; - -use rig::client::{CompletionClient, EmbeddingsClient, ProviderClient}; -use rig::{ - Embed, completion::Prompt, embeddings::EmbeddingsBuilder, - vector_store::in_memory_store::InMemoryVectorStore, -}; -use rig_bedrock::client::Client; -use rig_bedrock::completion::AMAZON_NOVA_LITE; -use rig_bedrock::embedding::AMAZON_TITAN_EMBED_TEXT_V2_0; -use serde::Serialize; -use tracing::info; - -// Data to be RAG-ed. -// A vector search needs to be performed on the `definitions` field, so we derive the `Embed` trait for `WordDefinition` -// and tag that field with `#[embed]`. -#[derive(rig_derive::Embed, Serialize, Clone, Debug, Eq, PartialEq, Default)] -struct WordDefinition { - id: String, - word: String, - #[embed] - definitions: Vec, -} - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_target(false) - .init(); - - let client = Client::from_env(); - let embedding_model = client.embedding_model_with_ndims(AMAZON_TITAN_EMBED_TEXT_V2_0, 256); - - // Generate embeddings for the definitions of all the documents using the specified embedding model. - let embeddings = EmbeddingsBuilder::new(embedding_model.clone()) - .documents(vec![ - WordDefinition { - id: "doc0".to_string(), - word: "flurbo".to_string(), - definitions: vec![ - "1. *flurbo* (name): A flurbo is a green alien that lives on cold planets.".to_string(), - "2. *flurbo* (name): A fictional digital currency that originated in the animated series Rick and Morty.".to_string() - ] - }, - WordDefinition { - id: "doc1".to_string(), - word: "glarb-glarb".to_string(), - definitions: vec![ - "1. *glarb-glarb* (noun): A glarb-glarb is a ancient tool used by the ancestors of the inhabitants of planet Jiro to farm the land.".to_string(), - "2. *glarb-glarb* (noun): A fictional creature found in the distant, swampy marshlands of the planet Glibbo in the Andromeda galaxy.".to_string() - ] - }, - WordDefinition { - id: "doc2".to_string(), - word: "linglingdong".to_string(), - definitions: vec![ - "1. *linglingdong* (noun): A term used by inhabitants of the far side of the moon to describe humans.".to_string(), - "2. *linglingdong* (noun): A rare, mystical instrument crafted by the ancient monks of the Nebulon Mountain Ranges on the planet Quarm.".to_string() - ] - }, - ])? - .build() - .await?; - - // Create vector store with the embeddings - let vector_store = InMemoryVectorStore::from_documents(embeddings); - - // Create vector store index - let index = vector_store.index(embedding_model); - - let rag_agent = client.agent(AMAZON_NOVA_LITE) - .preamble(" - You are a dictionary assistant here to assist the user in understanding the meaning of words. - You will find additional non-standard word definitions that could be useful below. - ") - .dynamic_context(1, index) - .build(); - - // Prompt the agent and print the response - let response = rag_agent.prompt("What does \"glarb-glarb\" mean?").await?; - - info!("{}", response); - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/streaming_with_bedrock.rs b/vendor/rig-bedrock/examples/streaming_with_bedrock.rs deleted file mode 100644 index a028beb7..00000000 --- a/vendor/rig-bedrock/examples/streaming_with_bedrock.rs +++ /dev/null @@ -1,23 +0,0 @@ -use rig::agent::stream_to_stdout; -use rig::client::{CompletionClient, ProviderClient}; -use rig::streaming::StreamingPrompt; -use rig_bedrock::{client::Client, completion::AMAZON_NOVA_LITE}; - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - // Create streaming agent with a single context prompt - let agent = Client::from_env() - .agent(AMAZON_NOVA_LITE) - .preamble("Be precise and concise.") - .temperature(0.5) - .build(); - - // Stream the response and print chunks as they arrive - let mut stream = agent - .stream_prompt("When and where and what type is the next solar eclipse?") - .await; - - let _ = stream_to_stdout(&mut stream).await?; - - Ok(()) -} diff --git a/vendor/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs b/vendor/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs deleted file mode 100644 index 32ce2632..00000000 --- a/vendor/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs +++ /dev/null @@ -1,27 +0,0 @@ -use rig::agent::stream_to_stdout; -use rig::client::{CompletionClient, ProviderClient}; -use rig::streaming::StreamingPrompt; -use rig_bedrock::{client::Client, completion::AMAZON_NOVA_LITE}; -mod common; - -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { - tracing_subscriber::fmt().init(); - // Create agent with a single context prompt and two tools - let agent = Client::from_env() - .agent(AMAZON_NOVA_LITE) - .preamble( - "You are a calculator here to help the user perform arithmetic - operations. Use the tools provided to answer the user's question. - make your answer long, so we can test the streaming functionality, - like 20 words", - ) - .max_tokens(1024) - .tool(common::Adder) - .build(); - - println!("Calculate 2 + 5"); - let mut stream = agent.stream_prompt("Calculate 2 + 5").await; - let _ = stream_to_stdout(&mut stream).await?; - Ok(()) -}