Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
adapter_registry.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
19#include "adapter_registry.h"
20#include "generic_adapter.h"
21#include "nemotron3_adapter.h"
22#include "qwen35_adapter.h"
23#include "qwen36_adapter.h"
24
26
27#include <algorithm>
28#include <array>
29#include <functional>
30#include <string>
31#include <string_view>
32
33namespace entropic {
34
35namespace {
36auto logger = entropic::log::get("inference.adapter.registry");
37
39using AdapterFactory = std::function<std::unique_ptr<ChatAdapter>(
40 const std::string&, const std::string&)>;
41
47struct AdapterEntry {
48 std::string_view key;
49 AdapterFactory factory;
50};
51
63const std::array<AdapterEntry, 3>& adapter_table() {
64 static const std::array<AdapterEntry, 3> table{{
65 {"qwen35", [](auto& t, auto& p) {
66 return std::make_unique<Qwen35Adapter>(t, p); }},
67 {"qwen36", [](auto& t, auto& p) {
68 return std::make_unique<Qwen36Adapter>(t, p); }},
69 {"nemotron3", [](auto& t, auto& p) {
70 return std::make_unique<Nemotron3Adapter>(t, p); }},
71 }};
72 return table;
73}
74
82std::string to_lower(const std::string& name) {
83 std::string lower = name;
84 std::transform(lower.begin(), lower.end(), lower.begin(),
85 [](unsigned char c) { return std::tolower(c); });
86 return lower;
87}
88
89} // anonymous namespace
90
106std::unique_ptr<ChatAdapter> create_adapter(
107 const std::string& name,
108 const std::string& tier_name,
109 const std::string& identity_prompt)
110{
111 const std::string lower = to_lower(name);
112 for (const auto& entry : adapter_table()) {
113 if (lower == entry.key) {
114 logger->info("Adapter created: type={}, tier={}",
115 entry.key, tier_name);
116 return entry.factory(tier_name, identity_prompt);
117 }
118 }
119 logger->info("Adapter created: generic (config='{}'), tier={} "
120 "(tool parsing via common_chat)", name, tier_name);
121 return std::make_unique<GenericAdapter>(tier_name, identity_prompt);
122}
123
124} // namespace entropic
Adapter factory — create adapters by name.
GenericAdapter — default ChatML adapter with JSON tool calls.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Definition logging.cpp:211
Activate model on GPU (WARM → ACTIVE).
std::unique_ptr< ChatAdapter > 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).
Nemotron 3 chat adapter (v2.1.9, gh#47).
Qwen 3.5 chat adapter.
Qwen 3.6 chat adapter (v2.1.9, gh#45).