| 262 | std::string id = call_id.empty() ? generate_tool_call_id() : call_id; |
| 263 | return ToolCall(id, tool_name, arguments); |
| 264 | } |
| 265 | |
| 266 | std::string generate_tool_call_id() { |
| 267 | // Generate a unique ID for tool calls |
| 268 | static std::random_device rd; |
| 269 | static std::mt19937 gen(rd()); |
| 270 | static std::uniform_int_distribution<> dis(0, 15); |
| 271 | |
| 272 | std::string id = "call_"; |
| 273 | for (int i = 0; i < 24; ++i) { |
| 274 | int val = dis(gen); |
| 275 | if (val < 10) { |
| 276 | id += static_cast<char>('0' + val); |
| 277 | } else { |
| 278 | id += static_cast<char>('a' + val - 10); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return id; |
| 283 | } |
| 284 | |