adapter_registry.cpp

src/inference/adapters/adapter_registry.cpp

@file adapter_registry.cpp @brief Adapter factory implementation.

Owners: @tvanfossen

adapter_table

const std::array< AdapterEntry, 4 > & entropic::anonymous_namespace{adapter_registry.cpp}::adapter_table()

Build the static adapter dispatch table (gh#87 Phase D).

src/inference/adapters/adapter_registry.cpp:73

Source · 13 lines
const std::array<AdapterEntry, 4>& adapter_table() {
    static const std::array<AdapterEntry, 4> table{{
        {"gemma4",    [](auto& t, auto& p) {
            return std::make_unique<Gemma4Adapter>(t, p); }},
        {"qwen35",    [](auto& t, auto& p) {
            return std::make_unique<Qwen35Adapter>(t, p); }},
        {"qwen36",    [](auto& t, auto& p) {
            return std::make_unique<Qwen36Adapter>(t, p); }},
        {"nemotron3", [](auto& t, auto& p) {
            return std::make_unique<Nemotron3Adapter>(t, p); }},
    }};
    return table;
}
Activity · 2 steps
lines 74–83static const std::array<AdapterEntry, 4> table{{ {"gemma4", [](auto& t, auto& p) { return std::make_unique<Gemma4Adapter>(t, p); }}, {"qwen35", [](auto& t, auto& p) { return std::make_unique<Qwen35Adapter>(t, p); }}, {"qwen36", [](auto& t, auto& p) { return std::make_unique<Qwen36Adapter>(t, p); }}, {"nemotron3", [](auto& t, auto& p) { return std::make_unique<Nemotron3Adapter>(t, p); }}, }};lines 84–84return table;

Requirements

REQ-INFER-012

create_adapter

std::unique_ptr< ChatAdapter > entropic::create_adapter(const std::string &name, const std::string &tier_name, const std::string &identity_prompt)

Create adapter by name (gh#87 Phase D hybrid).

src/inference/adapters/adapter_registry.cpp:123

Show on the map →

Called by SCENARIO, create_tier_backends

Calls adapter_table

Source · 17 lines
std::unique_ptr<ChatAdapter> create_adapter(
    const std::string& name,
    const std::string& tier_name,
    const std::string& identity_prompt)
{
    const std::string lower = to_lower(name);
    for (const auto& entry : adapter_table()) {
        if (lower == entry.key) {
            logger->info("Adapter created: type={}, tier={}",
                         entry.key, tier_name);
            return entry.factory(tier_name, identity_prompt);
        }
    }
    logger->info("Adapter created: generic (config='{}'), tier={} "
                 "(tool parsing via common_chat)", name, tier_name);
    return std::make_unique<GenericAdapter>(tier_name, identity_prompt);
}
Activity · 7 steps
lines 128–128const std::string lower = to_lower(name);lines 129–129◇ for (const auto& entry : adapter_table())lines 130–130◇ if (lower == entry.key)lines 131–132logger->info("Adapter created: type={}, tier={}", entry.key, tier_name);lines 133–133return entry.factory(tier_name, identity_prompt);lines 136–137logger->info("Adapter created: generic (config='{}'), tier={} " "(tool parsing via common_chat)", name, tier_name);lines 138–138return std::make_unique<GenericAdapter>(tier_name, identity_prompt);

Requirements

REQ-INFER-012