From 80cdf85e1a6d1c010ebc04c7f801354b52a450be Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Mon, 16 Jun 2025 01:09:53 +0800 Subject: [PATCH] chore(deps): update rig-core requirement from 0.12.0 to 0.13.0 (#259) --- examples/rig-integration/Cargo.toml | 2 +- examples/rig-integration/src/chat.rs | 22 ++++++++++++++-------- examples/rig-integration/src/main.rs | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/rig-integration/Cargo.toml b/examples/rig-integration/Cargo.toml index a7e46b1..42cb463 100644 --- a/examples/rig-integration/Cargo.toml +++ b/examples/rig-integration/Cargo.toml @@ -12,7 +12,7 @@ categories = { workspace = true } readme = { workspace = true } [dependencies] -rig-core = "0.12.0" +rig-core = "0.13.0" tokio = { version = "1", features = ["full"] } rmcp = { path = "../../crates/rmcp", features = [ "client", diff --git a/examples/rig-integration/src/chat.rs b/examples/rig-integration/src/chat.rs index 7997d76..bc09368 100644 --- a/examples/rig-integration/src/chat.rs +++ b/examples/rig-integration/src/chat.rs @@ -1,12 +1,16 @@ use futures::StreamExt; use rig::{ agent::Agent, + completion::{AssistantContent, CompletionModel}, message::Message, - streaming::{StreamingChat, StreamingChoice, StreamingCompletionModel}, + streaming::StreamingChat, }; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter}; -pub async fn cli_chatbot(chatbot: Agent) -> anyhow::Result<()> { +pub async fn cli_chatbot(chatbot: Agent) -> anyhow::Result<()> +where + M: CompletionModel, +{ let mut chat_log = vec![]; let mut output = BufWriter::new(tokio::io::stdout()); @@ -32,15 +36,17 @@ pub async fn cli_chatbot(chatbot: Agent) -> anyh let mut message_buf = String::new(); while let Some(message) = response.next().await { match message { - Ok(StreamingChoice::Message(text)) => { - message_buf.push_str(&text); - output_agent(text, &mut output).await?; + Ok(AssistantContent::Text(text)) => { + message_buf.push_str(&text.text); + output_agent(text.text, &mut output).await?; } - Ok(StreamingChoice::ToolCall(name, _, param)) => { + Ok(AssistantContent::ToolCall(tool_call)) => { + let name = tool_call.function.name; + let arguments = tool_call.function.arguments; chat_log.push(Message::assistant(format!( - "Calling tool: {name} with args: {param}" + "Calling tool: {name} with args: {arguments}" ))); - let result = chatbot.tools.call(&name, param.to_string()).await; + let result = chatbot.tools.call(&name, arguments.to_string()).await; match result { Ok(tool_call_result) => { stream_output_agent_finished(&mut output).await?; diff --git a/examples/rig-integration/src/main.rs b/examples/rig-integration/src/main.rs index ddf220f..4ac12b0 100644 --- a/examples/rig-integration/src/main.rs +++ b/examples/rig-integration/src/main.rs @@ -1,4 +1,5 @@ use rig::{ + client::{CompletionClient, ProviderClient}, embeddings::EmbeddingsBuilder, providers::{cohere, deepseek}, vector_store::in_memory_store::InMemoryVectorStore,