Example tool function: Get weather information
| 23 | |
| 24 | // Example tool function: Get weather information |
| 25 | ai::JsonValue get_weather(const ai::JsonValue& args, |
| 26 | const ai::ToolExecutionContext& context) { |
| 27 | std::string location = args["location"].get<std::string>(); |
| 28 | |
| 29 | // Simulate weather API call |
| 30 | std::srand(std::time(nullptr)); |
| 31 | int temperature = 60 + (std::rand() % 40); // Random temp between 60-100°F |
| 32 | |
| 33 | ai::JsonValue result = {{"location", location}, |
| 34 | {"temperature", temperature}, |
| 35 | {"unit", "Fahrenheit"}, |
| 36 | {"condition", "Partly cloudy"}}; |
| 37 | |
| 38 | std::cout << "🌤️ Weather tool called for: " << location << std::endl; |
| 39 | return result; |
| 40 | } |
| 41 | |
| 42 | // Example tool function: Get city attractions |
| 43 | ai::JsonValue get_city_attractions(const ai::JsonValue& args, |
nothing calls this directly
no outgoing calls
no test coverage detected