Entropic 2.9.5
Local-first agentic inference engine
Loading...
Searching...
No Matches
xml_parameter_parser.h File Reference

Shared <parameter=NAME>value</parameter> extractor for XML-format chat adapters (Qwen 3.5 / Qwen 3.6 / Nemotron 3). More...

#include <spdlog/spdlog.h>
#include <memory>
#include <string>
#include <unordered_map>
Include dependency graph for xml_parameter_parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

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

Functions

std::unordered_map< std::string, std::string > entropic::inference::adapters::parse_xml_parameters (const std::string &func_body, const std::shared_ptr< spdlog::logger > &logger)
 Extract <parameter=NAME>value</parameter> pairs from a function body.
 

Detailed Description

Shared <parameter=NAME>value</parameter> extractor for XML-format chat adapters (Qwen 3.5 / Qwen 3.6 / Nemotron 3).

Pre-v2.4.1 each adapter carried a byte-identical inline regex parser. They also shared a latent bug (gh#79): when a model closes a parameter with </NAME> echoing the opening name instead of the literal </parameter>, the non-greedy regex scanned past the wrong close tag to the next </parameter>, bleeding the following parameter's content into the first parameter's value.

This helper centralizes the parse:

  • Tolerates </parameter> OR </NAME> close tags (whichever comes first after the opening, where NAME matches the opening's name verbatim).
  • Truncates the body at a nested <function= tag (malformed multi-call output handling, preserved from the per-adapter implementations).
  • Trims whitespace on key and value; skips empty after trim.
Version
2.4.1 (gh#79)

Definition in file xml_parameter_parser.h.

Function Documentation

◆ parse_xml_parameters()

std::unordered_map< std::string, std::string > entropic::inference::adapters::parse_xml_parameters ( const std::string &  func_body,
const std::shared_ptr< spdlog::logger > &  logger 
)

Extract <parameter=NAME>value</parameter> pairs from a function body.

gh#79 fix: tolerates </NAME> close tags in addition to the literal </parameter>. See the helper definitions above and the header for full contract.

@utility

Version
2.4.1

Returns a map keyed by parameter name. Empty keys / values (after trim) are skipped with a warning. The </NAME> close-tag tolerance is the gh#79 fix.

Parameters
func_bodyFunction body text (between <function=name> and the matching </function>).
loggerAdapter-owned logger for warn messages. May be null — the parser is silent in that case.
Returns
Map of trimmed parameter key to trimmed parameter value. @utility
Version
2.4.1

Definition at line 116 of file xml_parameter_parser.cpp.