Example tool function: Get city attractions
| 41 | |
| 42 | // Example tool function: Get city attractions |
| 43 | ai::JsonValue get_city_attractions(const ai::JsonValue& args, |
| 44 | const ai::ToolExecutionContext& context) { |
| 45 | std::string city = args["city"].get<std::string>(); |
| 46 | |
| 47 | ai::JsonValue attractions; |
| 48 | if (city == "San Francisco") { |
| 49 | attractions = {"Golden Gate Bridge", "Alcatraz Island", "Fisherman's Wharf", |
| 50 | "Lombard Street"}; |
| 51 | } else if (city == "New York") { |
| 52 | attractions = {"Statue of Liberty", "Central Park", "Times Square", |
| 53 | "Brooklyn Bridge"}; |
| 54 | } else if (city == "Paris") { |
| 55 | attractions = {"Eiffel Tower", "Louvre Museum", "Notre-Dame Cathedral", |
| 56 | "Arc de Triomphe"}; |
| 57 | } else { |
| 58 | attractions = {"Downtown area", "Local parks", "Historical sites"}; |
| 59 | } |
| 60 | |
| 61 | ai::JsonValue result = {{"city", city}, {"attractions", attractions}}; |
| 62 | |
| 63 | std::cout << "🏛️ Attractions tool called for: " << city << std::endl; |
| 64 | return result; |
| 65 | } |
| 66 | |
| 67 | int main() { |
| 68 | std::cout << "AI SDK C++ - Basic Tool Calling Example\n"; |
nothing calls this directly
no outgoing calls
no test coverage detected