| 75 | } |
| 76 | |
| 77 | void test_anthropic_tools() { |
| 78 | std::cout << "\n=== Testing Anthropic Tool Integration ===\n"; |
| 79 | |
| 80 | auto client = ai::anthropic::create_client(); |
| 81 | |
| 82 | // Create a simple tool |
| 83 | ai::ToolSet tools = { |
| 84 | {"test_tool", ai::create_simple_tool( |
| 85 | "test_tool", "A simple test tool that echoes input", |
| 86 | {{"input", "string"}}, simple_test_tool)}}; |
| 87 | |
| 88 | ai::GenerateOptions options; |
| 89 | options.model = ai::anthropic::models::kClaudeSonnet46; |
| 90 | options.prompt = "Please use the test_tool with input 'hello anthropic'"; |
| 91 | options.tools = tools; |
| 92 | options.tool_choice = |
| 93 | ai::ToolChoice::specific("test_tool"); // Force tool usage |
| 94 | options.max_tokens = 100; |
| 95 | |
| 96 | std::cout << "Making request to Anthropic with forced tool usage...\n"; |
| 97 | |
| 98 | auto result = client.generate_text(options); |
| 99 | |
| 100 | if (result) { |
| 101 | std::cout << "✅ Request successful!\n"; |
| 102 | std::cout << "Response: " << result.text << "\n"; |
| 103 | std::cout << "Tool calls: " << result.tool_calls.size() << "\n"; |
| 104 | std::cout << "Tool results: " << result.tool_results.size() << "\n"; |
| 105 | |
| 106 | if (!result.tool_calls.empty()) { |
| 107 | const auto& call = result.tool_calls[0]; |
| 108 | std::cout << "First tool call: " << call.tool_name << "\n"; |
| 109 | std::cout << "Arguments: " << call.arguments.dump() << "\n"; |
| 110 | } |
| 111 | |
| 112 | if (!result.tool_results.empty()) { |
| 113 | const auto& tool_result = result.tool_results[0]; |
| 114 | std::cout << "First tool result: " << tool_result.result.dump() << "\n"; |
| 115 | } |
| 116 | } else { |
| 117 | std::cout << "❌ Request failed: " << result.error_message() << "\n"; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | void test_multi_step() { |
| 122 | std::cout << "\n=== Testing Multi-Step Tool Calling ===\n"; |
no test coverage detected