Entropic 2.9.5
Local-first agentic inference engine
Loading...
Searching...
No Matches
adapter_base.cpp File Reference

ChatAdapter base class implementation. More...

#include <entropic/inference/adapters/adapter_base.h>
#include <entropic/types/logging.h>
#include <nlohmann/json.hpp>
#include <algorithm>
#include <atomic>
#include <cstdint>
#include <regex>
#include <sstream>
#include <unordered_set>
Include dependency graph for adapter_base.cpp:

Go to the source code of this file.

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Functions

static std::optional< ToolCallentropic::action_envelope_to_call (const nlohmann::json &j)
 Map one parsed JSON object to a recovered ToolCall.
 
std::vector< ToolCallentropic::recover_action_envelope_calls (const std::string &raw)
 gh#88: recover tool calls a gemma model parroted as bare-JSON.
 
void entropic::apply_action_envelope_recovery (std::vector< ToolCall > &calls, const std::string &raw)
 gh#88: substitute recovered bare-JSON calls when a reliable (PEG_GEMMA4 / gemma) parse produced none; logs the recovery.
 
static std::unordered_set< std::string > entropic::tool_string_props (const nlohmann::json &tools, const std::string &name)
 String-typed property names for a tool in the staged MCP defs.
 
static void entropic::coerce_call_string_args (ToolCall &tc, const nlohmann::json &tools)
 Coerce one call's numeric args to strings per the tool schema.
 
void entropic::coerce_string_typed_args (std::vector< ToolCall > &calls, const std::string &tools_json)
 gh#90: coerce numeric scalars back to strings for string-typed tool parameters.
 
static std::optional< ToolCallentropic::parse_recovered_tool_call (const std::string &fixed)
 Parse a brace/quote-fixed JSON string into a ToolCall.
 
static std::optional< ToolCallentropic::regex_recovered_tool_call (const std::string &json_str)
 Last-ditch recovery: pull a tool name out via regex.
 
logger entropic::info ("JSON recovery attempt: {} chars", json_str.size())
 

Variables

 entropic::fixed = std::regex_replace(fixed, std::regex(R"(,\s*\])"), "]")
 
 entropic::try
 

Detailed Description

ChatAdapter base class implementation.

Provides shared tool-call parsing, think-block handling, JSON recovery, system prompt assembly, and response completeness detection.

Version
1.8.2

Definition in file adapter_base.cpp.