| 476 | } |
| 477 | |
| 478 | bool test_tool_call_with_three_tools() { |
| 479 | const char* messages = R"([ |
| 480 | {"role": "system", "content": "You are a helpful assistant that can use tools."}, |
| 481 | {"role": "user", "content": "Send a message to John saying hello."} |
| 482 | ])"; |
| 483 | |
| 484 | const char* tools = R"([{ |
| 485 | "type": "function", |
| 486 | "function": { |
| 487 | "name": "get_weather", |
| 488 | "description": "Get weather for a location", |
| 489 | "parameters": { |
| 490 | "type": "object", |
| 491 | "properties": { |
| 492 | "location": {"type": "string", "description": "City, State, Country"} |
| 493 | }, |
| 494 | "required": ["location"] |
| 495 | } |
| 496 | } |
| 497 | }, { |
| 498 | "type": "function", |
| 499 | "function": { |
| 500 | "name": "set_alarm", |
| 501 | "description": "Set an alarm for a given time", |
| 502 | "parameters": { |
| 503 | "type": "object", |
| 504 | "properties": { |
| 505 | "hour": {"type": "integer", "description": "Hour to set the alarm for"}, |
| 506 | "minute": {"type": "integer", "description": "Minute to set the alarm for"} |
| 507 | }, |
| 508 | "required": ["hour", "minute"] |
| 509 | } |
| 510 | } |
| 511 | }, { |
| 512 | "type": "function", |
| 513 | "function": { |
| 514 | "name": "send_message", |
| 515 | "description": "Send a message to a contact", |
| 516 | "parameters": { |
| 517 | "type": "object", |
| 518 | "properties": { |
| 519 | "recipient": {"type": "string", "description": "Name of the person to send the message to"}, |
| 520 | "message": {"type": "string", "description": "The message content to send"} |
| 521 | }, |
| 522 | "required": ["recipient", "message"] |
| 523 | } |
| 524 | } |
| 525 | }])"; |
| 526 | |
| 527 | const char* options_with_force_tools = R"({ |
| 528 | "max_tokens": 256, |
| 529 | "stop_sequences": ["<|im_end|>", "<end_of_turn>"], |
| 530 | "force_tools": true |
| 531 | })"; |
| 532 | |
| 533 | return EngineTestUtils::run_test("TRIPLE TOOLS TEST", g_model_path, messages, options_with_force_tools, |
| 534 | [](int result, const StreamingData&, const std::string& response, const Metrics& m) { |
| 535 | bool has_function = response.find("\"function_calls\":[") != std::string::npos; |
no test coverage detected