Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
tool_call_serialize.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
17#pragma once
18
19#include <string>
20#include <vector>
21
23#include <nlohmann/json.hpp>
24
25namespace entropic {
26
47inline std::string serialize_tool_calls(
48 const std::vector<ToolCall>& calls) {
49 nlohmann::json arr = nlohmann::json::array();
50 for (const auto& tc : calls) {
51 nlohmann::json args;
52 for (const auto& [k, v] : tc.arguments) {
53 auto parsed_val = nlohmann::json::parse(v, nullptr, false);
54 args[k] = parsed_val.is_discarded()
55 ? nlohmann::json(v) : parsed_val;
56 }
57 arr.push_back({{"name", tc.name}, {"arguments", args}});
58 }
59 return arr.dump(-1, ' ', false,
60 nlohmann::json::error_handler_t::replace);
61}
62
63} // namespace entropic
Activate model on GPU (WARM → ACTIVE).
std::string serialize_tool_calls(const std::vector< ToolCall > &calls)
Serialize parsed tool calls to the C-ABI JSON array form.
Tool call and tool result types.