alexhancock/mcp-crate-cleanup (#4885)

This commit is contained in:
Alex Hancock
2025-09-29 17:00:17 -04:00
committed by GitHub
parent 2bd18a757b
commit cb0eca9966
78 changed files with 1039 additions and 1090 deletions
+10 -7
View File
@@ -38,9 +38,8 @@ use crate::conversation::Conversation;
use crate::model::ModelConfig;
use crate::providers::formats::openai::create_request;
use anyhow::Result;
use mcp_core::tool::ToolCall;
use reqwest::Client;
use rmcp::model::{RawContent, Tool};
use rmcp::model::{object, CallToolRequestParam, RawContent, Tool};
use serde_json::{json, Value};
use std::ops::Deref;
use std::time::Duration;
@@ -60,7 +59,7 @@ pub trait ToolInterpreter {
&self,
content: &str,
tools: &[Tool],
) -> Result<Vec<ToolCall>, ProviderError>;
) -> Result<Vec<CallToolRequestParam>, ProviderError>;
}
/// Ollama-specific implementation of the ToolInterpreter trait
@@ -198,7 +197,9 @@ impl OllamaInterpreter {
Ok(response_json)
}
fn process_interpreter_response(response: &Value) -> Result<Vec<ToolCall>, ProviderError> {
fn process_interpreter_response(
response: &Value,
) -> Result<Vec<CallToolRequestParam>, ProviderError> {
let mut tool_calls = Vec::new();
tracing::info!(
"Tool interpreter response is {}",
@@ -219,12 +220,14 @@ impl OllamaInterpreter {
&& item.get("name").is_some()
&& item.get("arguments").is_some()
{
// Create ToolCall directly from the JSON data
let name = item["name"].as_str().unwrap_or_default().to_string();
let arguments = item["arguments"].clone();
// Add the tool call to our result vector
tool_calls.push(ToolCall::new(name, arguments));
tool_calls.push(CallToolRequestParam {
name: name.into(),
arguments: Some(object(arguments)),
});
}
}
}
@@ -242,7 +245,7 @@ impl ToolInterpreter for OllamaInterpreter {
&self,
last_assistant_msg: &str,
tools: &[Tool],
) -> Result<Vec<ToolCall>, ProviderError> {
) -> Result<Vec<CallToolRequestParam>, ProviderError> {
if tools.is_empty() {
return Ok(vec![]);
}