| 2011 | } |
| 2012 | |
| 2013 | static void func_args_not_string(json & messages) { |
| 2014 | GGML_ASSERT(messages.is_array()); |
| 2015 | for (auto & message : messages) { |
| 2016 | if (message.contains("tool_calls")) { |
| 2017 | for (auto & tool_call : message["tool_calls"]) { |
| 2018 | if (tool_call.contains("function") && tool_call["function"].contains("arguments")) { |
| 2019 | auto & args = tool_call["function"]["arguments"]; |
| 2020 | if (args.is_string()) { |
| 2021 | try { |
| 2022 | args = json::parse(args.get<std::string>()); |
| 2023 | } catch (const std::exception & e) { |
| 2024 | throw std::runtime_error("Failed to parse tool call arguments as JSON: " + std::string(e.what())); |
| 2025 | } |
| 2026 | } |
| 2027 | } |
| 2028 | } |
| 2029 | } |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | } |
| 2034 |
no test coverage detected