@@ -390,8 +390,9 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::conversation::message::Message;
|
||||
use anyhow::Result;
|
||||
use rmcp::model::{CallToolRequestParam, Content};
|
||||
use rmcp::object;
|
||||
use mcp_core::tool::ToolCall;
|
||||
use rmcp::model::Content;
|
||||
use serde_json::json;
|
||||
|
||||
// Helper function to create a user text message with a specified token count
|
||||
fn user_text(index: usize, tokens: usize) -> (Message, usize) {
|
||||
@@ -406,11 +407,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Helper function to create a tool request message with a specified token count
|
||||
fn assistant_tool_request(
|
||||
id: &str,
|
||||
tool_call: CallToolRequestParam,
|
||||
tokens: usize,
|
||||
) -> (Message, usize) {
|
||||
fn assistant_tool_request(id: &str, tool_call: ToolCall, tokens: usize) -> (Message, usize) {
|
||||
(
|
||||
Message::assistant().with_tool_request(id, Ok(tool_call)),
|
||||
tokens,
|
||||
@@ -461,10 +458,7 @@ mod tests {
|
||||
user_text(1, 10).0,
|
||||
assistant_tool_request(
|
||||
"tool1",
|
||||
CallToolRequestParam {
|
||||
name: "read_file".into(),
|
||||
arguments: Some(object!({"path": "large_file.txt"})),
|
||||
},
|
||||
ToolCall::new("read_file", json!({"path": "large_file.txt"})),
|
||||
20,
|
||||
)
|
||||
.0,
|
||||
@@ -526,14 +520,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_complex_conversation_with_tools() -> Result<()> {
|
||||
// Simulating a real conversation with multiple tool interactions
|
||||
let tool_call1 = CallToolRequestParam {
|
||||
name: "file_read".into(),
|
||||
arguments: Some(object!({"path": "/tmp/test.txt"})),
|
||||
};
|
||||
let tool_call2 = CallToolRequestParam {
|
||||
name: "database_query".into(),
|
||||
arguments: Some(object!({"query": "SELECT * FROM users"})),
|
||||
};
|
||||
let tool_call1 = ToolCall::new("file_read", json!({"path": "/tmp/test.txt"}));
|
||||
let tool_call2 = ToolCall::new("database_query", json!({"query": "SELECT * FROM users"}));
|
||||
|
||||
let messages = vec![
|
||||
user_text(1, 15).0, // Initial user query
|
||||
@@ -634,18 +622,9 @@ mod tests {
|
||||
fn test_multi_tool_chain() -> Result<()> {
|
||||
// Simulate a chain of dependent tool calls
|
||||
let tool_calls = vec![
|
||||
CallToolRequestParam {
|
||||
name: "git_status".into(),
|
||||
arguments: Some(object!({})),
|
||||
},
|
||||
CallToolRequestParam {
|
||||
name: "git_diff".into(),
|
||||
arguments: Some(object!({"file": "main.rs"})),
|
||||
},
|
||||
CallToolRequestParam {
|
||||
name: "git_commit".into(),
|
||||
arguments: Some(object!({"message": "Update"})),
|
||||
},
|
||||
ToolCall::new("git_status", json!({})),
|
||||
ToolCall::new("git_diff", json!({"file": "main.rs"})),
|
||||
ToolCall::new("git_commit", json!({"message": "Update"})),
|
||||
];
|
||||
|
||||
let mut messages = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user