chore(deps): update rig-core requirement from 0.12.0 to 0.13.0 (#259)

This commit is contained in:
jokemanfire 2025-06-16 01:09:53 +08:00 • committed by GitHub
commit 80cdf85e1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 9 deletions

View file

@ -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",

View file

@ -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<M: StreamingCompletionModel>(chatbot: Agent<M>) -> anyhow::Result<()> {
pub async fn cli_chatbot<M>(chatbot: Agent<M>) -> 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<M: StreamingCompletionModel>(chatbot: Agent<M>) -> 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?;

View file

@ -1,4 +1,5 @@
use rig::{
client::{CompletionClient, ProviderClient},
embeddings::EmbeddingsBuilder,
providers::{cohere, deepseek},
vector_store::in_memory_store::InMemoryVectorStore,