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
Requirements
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
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);
}