impl Display for ToolUsage
This commit is contained in:
@@ -9,6 +9,7 @@ use rmcp::ServiceError;
|
|||||||
use rmcp::model::{CallToolRequestParams, CallToolResult};
|
use rmcp::model::{CallToolRequestParams, CallToolResult};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::fmt::Formatter;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Default, Deserialize, PartialEq)]
|
#[derive(Debug, Copy, Clone, Default, Deserialize, PartialEq)]
|
||||||
@@ -111,6 +112,20 @@ pub struct ToolUsage {
|
|||||||
pub result: RestrictedToolCallResult,
|
pub result: RestrictedToolCallResult,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for ToolUsage {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}(", self.call.function.name)?;
|
||||||
|
|
||||||
|
for (name, value) in self.call.function.arguments.as_object().expect("function.arguments is always an object").iter() {
|
||||||
|
write!(f, "{name}={value}, ")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(f, ") = {:?}", self.result)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AgentChat {
|
impl AgentChat {
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
ollama_client: Ollama,
|
ollama_client: Ollama,
|
||||||
|
|||||||
Reference in New Issue
Block a user