chore(deps): update rig-core requirement from 0.12.0 to 0.13.0 (#259)
This commit is contained in:
parent
abf7c7af08
commit
80cdf85e1a
3 changed files with 16 additions and 9 deletions
|
|
@ -12,7 +12,7 @@ categories = { workspace = true }
|
||||||
readme = { workspace = true }
|
readme = { workspace = true }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rig-core = "0.12.0"
|
rig-core = "0.13.0"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
rmcp = { path = "../../crates/rmcp", features = [
|
rmcp = { path = "../../crates/rmcp", features = [
|
||||||
"client",
|
"client",
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use rig::{
|
use rig::{
|
||||||
agent::Agent,
|
agent::Agent,
|
||||||
|
completion::{AssistantContent, CompletionModel},
|
||||||
message::Message,
|
message::Message,
|
||||||
streaming::{StreamingChat, StreamingChoice, StreamingCompletionModel},
|
streaming::StreamingChat,
|
||||||
};
|
};
|
||||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter};
|
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 chat_log = vec![];
|
||||||
|
|
||||||
let mut output = BufWriter::new(tokio::io::stdout());
|
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();
|
let mut message_buf = String::new();
|
||||||
while let Some(message) = response.next().await {
|
while let Some(message) = response.next().await {
|
||||||
match message {
|
match message {
|
||||||
Ok(StreamingChoice::Message(text)) => {
|
Ok(AssistantContent::Text(text)) => {
|
||||||
message_buf.push_str(&text);
|
message_buf.push_str(&text.text);
|
||||||
output_agent(text, &mut output).await?;
|
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!(
|
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 {
|
match result {
|
||||||
Ok(tool_call_result) => {
|
Ok(tool_call_result) => {
|
||||||
stream_output_agent_finished(&mut output).await?;
|
stream_output_agent_finished(&mut output).await?;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use rig::{
|
use rig::{
|
||||||
|
client::{CompletionClient, ProviderClient},
|
||||||
embeddings::EmbeddingsBuilder,
|
embeddings::EmbeddingsBuilder,
|
||||||
providers::{cohere, deepseek},
|
providers::{cohere, deepseek},
|
||||||
vector_store::in_memory_store::InMemoryVectorStore,
|
vector_store::in_memory_store::InMemoryVectorStore,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue