17#include <nlohmann/json.hpp>
21namespace facade_json {
40 const std::vector<entropic::Message>& messages) {
41 nlohmann::json
arr = nlohmann::json::array();
42 for (
const auto& m : messages) {
43 arr.push_back({{
"role", m.role},
44 {
"content", entropic::mcp::sanitize_utf8(m.content)}});
56inline nlohmann::json
parse(
const char* str) {
57 if (!str) {
return nlohmann::json(); }
58 return nlohmann::json::parse(str,
nullptr,
false);
67inline nlohmann::json
obj() {
return nlohmann::json::object(); }
75inline nlohmann::json
arr() {
return nlohmann::json::array(); }
88 j[
"state"] =
static_cast<int>(ai.
state);
89 j[
"scale"] = ai.
scale;
91 j[
"path"] = ai.
path.string();
105 const std::vector<entropic::AdapterInfo>& adapters) {
106 nlohmann::json a = nlohmann::json::array();
107 for (
const auto& ai : adapters) {
108 a.push_back({{
"name", ai.name},
109 {
"state",
static_cast<int>(ai.state)},
111 {
"tier_name", ai.tier_name}});
Configuration structs with defaults.
std::string serialize_messages(const std::vector< entropic::Message > &messages)
Serialize messages to JSON array string.
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 parse(const char *str)
Parse JSON string to nlohmann::json object.
nlohmann::json obj()
Create a JSON object from key-value pairs.
nlohmann::json arr()
Create an empty JSON array.
Message struct for conversation history.
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)
UTF-8 validation + replacement at every system boundary where bytes change ownership.