add caldav mcp server
refactoring
This commit is contained in:
+16
-11
@@ -221,19 +221,24 @@ impl AgentChat {
|
||||
log::debug!("calling tool {}", tool_call.function.name);
|
||||
let result = self.call_tool(tool_call, &mut permission_request_callback).await?;
|
||||
|
||||
let contents = match result {
|
||||
Some(result) => result.content
|
||||
.iter()
|
||||
.filter_map(|content| content.as_text())
|
||||
.map(|text_content| text_content.text.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
None => vec![String::from("Tool Permission Denied by the user")],
|
||||
};
|
||||
// serialize structured content if it exists
|
||||
if let Some(structured_content) = result.clone().and_then(|result|result.structured_content) {
|
||||
self.message_history.push(ChatMessage::tool(structured_content.to_string()));
|
||||
} else {
|
||||
let contents = match result {
|
||||
Some(result) => result.content
|
||||
.iter()
|
||||
.filter_map(|content| content.as_text())
|
||||
.map(|text_content| text_content.text.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
None => vec![String::from("Tool Permission Denied by the user")],
|
||||
};
|
||||
|
||||
log::debug!("contents: {:#?}", contents);
|
||||
log::debug!("contents: {:#?}", contents);
|
||||
|
||||
self.message_history
|
||||
.push(ChatMessage::tool(contents.join("\n")));
|
||||
self.message_history
|
||||
.push(ChatMessage::tool(contents.join("\n")));
|
||||
}
|
||||
}
|
||||
|
||||
response = self
|
||||
|
||||
Reference in New Issue
Block a user