43#include <nlohmann/json.hpp>
48namespace facade_json {
65 j[
"path"] = entropic::mcp::sanitize_utf8(p.
image_path);
66 j[
"url"] = entropic::mcp::sanitize_utf8(p.
image_url);
71 j[
"text"] = entropic::mcp::sanitize_utf8(p.
text);
84 nlohmann::json meta = nlohmann::json::object();
85 for (
const auto& [k, v] : m.
metadata) {
86 meta[k] = entropic::mcp::sanitize_utf8(v);
99 nlohmann::json parts = nlohmann::json::array();
121 nlohmann::json
obj = nlohmann::json::object();
123 obj[
"content"] = entropic::mcp::sanitize_utf8(m.
content);
140 const std::vector<entropic::Message>& messages) {
141 nlohmann::json
arr = nlohmann::json::array();
142 for (
const auto& m : messages) {
155inline nlohmann::json
parse(
const char* str) {
156 if (!str) {
return nlohmann::json(); }
157 return nlohmann::json::parse(str,
nullptr,
false);
166inline nlohmann::json
obj() {
return nlohmann::json::object(); }
174inline nlohmann::json
arr() {
return nlohmann::json::array(); }
187 j[
"state"] =
static_cast<int>(ai.
state);
188 j[
"scale"] = ai.
scale;
190 j[
"path"] = ai.
path.string();
204 const std::vector<entropic::AdapterInfo>& adapters) {
205 nlohmann::json a = nlohmann::json::array();
206 for (
const auto& ai : adapters) {
207 a.push_back({{
"name", ai.name},
208 {
"state",
static_cast<int>(ai.state)},
210 {
"tier_name", ai.tier_name}});
Configuration structs with defaults.
Multimodal content types for messages.
std::string serialize_messages(const std::vector< entropic::Message > &messages)
Serialize messages to JSON array string — see serialize_message.
std::string serialize_adapter_list(const std::vector< entropic::AdapterInfo > &adapters)
Serialize a list of AdapterInfo to JSON array string.
std::string serialize_adapter_info(const entropic::AdapterInfo &ai)
Serialize an AdapterInfo to JSON string.
nlohmann::json serialize_parts(const entropic::Message &m)
Serialize a message's multimodal parts (gh#165).
nlohmann::json parse(const char *str)
Parse JSON string to nlohmann::json object.
nlohmann::json obj()
Create a JSON object from key-value pairs.
nlohmann::json serialize_content_part(const entropic::ContentPart &p)
Serialize one content part, losslessly (gh#165, v2.13.0).
nlohmann::json serialize_metadata(const entropic::Message &m)
Serialize a message's metadata map, sanitized (gh#165).
nlohmann::json serialize_message(const entropic::Message &m)
Serialize ONE message, losslessly — see the file header (gh#165).
nlohmann::json arr()
Create an empty JSON array.
Message struct for conversation history.
@ IMAGE
Image content (local path or data URI)
Metadata for a loaded LoRA adapter.
std::string tier_name
Tier this adapter is assigned to (empty = unassigned)
size_t ram_bytes
RAM consumption when WARM/HOT (0 if COLD)
std::string base_model_path
Path of the base model this adapter targets.
std::filesystem::path path
Resolved path to .gguf adapter file.
AdapterState state
Current lifecycle state.
std::string name
Unique adapter identifier.
float scale
LoRA scaling factor (alpha/rank)
A single content part within a multimodal message.
int height
Image height after preprocessing (0 = not yet processed)
int width
Image width after preprocessing (0 = not yet processed)
std::string image_path
Local file path (type == IMAGE)
std::string text
Text content (type == TEXT)
ContentPartType type
Part type discriminant.
std::string image_url
URL or data URI (type == IMAGE)
A message in a conversation.
std::vector< ContentPart > content_parts
Multimodal parts (empty for text-only)
std::unordered_map< std::string, std::string > metadata
Arbitrary metadata.
std::string content
Message text content (always populated)
std::string role
Message role.
UTF-8 validation + replacement at every system boundary where bytes change ownership.