| 446 | return value != "0" && value != "false" && value != "no" && |
| 447 | value != "off"; |
| 448 | } |
| 449 | |
| 450 | static const json * find_tool_function(const json & tools, |
| 451 | const std::string & name) { |
| 452 | if (!tools.is_array() || name.empty()) return nullptr; |
| 453 | for (const auto & tool : tools) { |
| 454 | if (!tool.contains("function") || !tool["function"].is_object()) { |
| 455 | continue; |
| 456 | } |
| 457 | const json & fn = tool["function"]; |
| 458 | if (fn.value("name", "") == name) return &fn; |
| 459 | } |
| 460 | return nullptr; |
| 461 | } |
| 462 | |
| 463 | static std::string first_tool_parameter_name(const json & function_def) { |
| 464 | const auto & params = function_def.value("parameters", json::object()); |
| 465 | if (params.contains("required") && params["required"].is_array()) { |
| 466 | for (const auto & name : params["required"]) { |
no test coverage detected