35#include <unordered_set>
80 const std::string& raw);
101 const std::string& tools_json);
120 ChatAdapter(std::string tier_name, std::string identity_prompt);
133 const std::string& base_prompt,
134 const std::vector<std::string>& tool_jsons)
const;
145 const std::string& content)
const = 0;
158 const std::string& result)
const;
169 const std::vector<std::string>& tool_jsons)
const;
181 const std::string& content,
182 const std::vector<ToolCall>& tool_calls)
const;
199 const std::string& content)
const;
206 const std::string& content)
const;
225 const std::string& json_str)
const;
234 const std::string& json_str)
const;
254 const std::string& base_system,
255 bool has_vision)
const;
267 const std::vector<ContentPart>& parts)
const;
Concrete base class for chat format adapters (80% logic).
std::string format_system_prompt(const std::string &base_prompt, const std::vector< std::string > &tool_jsons) const
Assemble system prompt: identity + context + tools.
std::unordered_set< std::string > tool_prefixes_
Known tool prefixes.
std::optional< ToolCall > try_recover_json(const std::string &json_str) const
Attempt JSON recovery on malformed tool call string.
virtual std::string format_content_parts(const std::vector< ContentPart > &parts) const
Convert multimodal content parts to adapter-specific format.
virtual std::string format_system_with_vision(const std::string &base_system, bool has_vision) const
Format system prompt with optional vision context.
virtual std::string chat_format() const =0
Chat format identifier (e.g.
std::optional< ToolCall > parse_single_tool_call(const std::string &json_str) const
Parse a single JSON tool call string.
std::vector< ToolCall > parse_tagged_tool_calls(const std::string &content) const
Parse <tool_call>JSON</tool_call> tagged blocks.
std::vector< ToolCall > parse_bare_json_tool_calls(const std::string &content) const
Parse bare JSON lines containing "name" key.
virtual std::string format_tools(const std::vector< std::string > &tool_jsons) const
Format tool definitions for injection into system prompt.
virtual ParseResult parse_tool_calls(const std::string &content) const =0
Parse tool calls from model output.
bool is_response_complete(const std::string &content, const std::vector< ToolCall > &tool_calls) const
Check if response represents task completion.
std::string strip_think_blocks(const std::string &content) const
Strip all <think>...</think> blocks from content.
std::string identity_prompt_
Assembled identity prompt.
virtual Message format_tool_result(const ToolCall &tool_call, const std::string &result) const
Format a tool result as a user message.
std::string tier_name_
Identity tier name.
std::string extract_thinking(const std::string &content) const
Extract <think>...</think> content.
Message struct for conversation history.
Activate model on GPU (WARM → ACTIVE).
void 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.
std::vector< ToolCall > recover_action_envelope_calls(const std::string &raw)
gh#88: recover tool calls a gemma model parroted as bare-JSON.
void 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;...
A message in a conversation.
Parsed tool call result: cleaned content + extracted calls.
std::string cleaned_content
Content with tool calls removed.
std::vector< ToolCall > tool_calls
Extracted tool calls.