13namespace entropic::prompts {
26static std::string
to_upper(
const std::string& s)
28 std::string result = s;
29 std::transform(result.begin(), result.end(), result.begin(),
30 [](
unsigned char c) { return std::toupper(c); });
42 const std::vector<TierDescriptor>& tiers)
46 const std::vector<std::string>* examples;
49 std::vector<Queue> queues;
50 for (
size_t i = 0; i < tiers.size(); ++i) {
51 if (!tiers[i].examples.empty()) {
53 {
static_cast<int>(i + 1), &tiers[i].examples});
57 std::vector<std::string> lines;
61 for (
const auto& q : queues) {
62 if (round_idx < q.examples->size()) {
63 lines.push_back(
"\"" + (*q.examples)[round_idx]
65 + std::to_string(q.digit));
86 const std::vector<std::string>& items,
const std::string& sep)
89 for (
size_t i = 0; i < items.size(); ++i) {
90 if (i > 0) result += sep;
104 const std::vector<TierDescriptor>& tiers)
107 for (
size_t i = 0; i < tiers.size(); ++i) {
108 result += std::to_string(i + 1) +
" = "
110 +
join(tiers[i].focus,
", ") +
"\n";
126 const std::vector<TierDescriptor>& tiers,
127 const std::string& message,
128 const std::vector<std::string>& history,
129 const std::vector<std::string>& recent_tiers)
131 std::string result =
"Classify the message. Reply with the number only.\n\n";
134 if (!recent_tiers.empty()) {
135 result +=
"Recent tiers: " +
join(recent_tiers,
" -> ") +
"\n\n";
138 if (!history.empty()) {
139 size_t start = history.size() > 5 ? history.size() - 5 : 0;
140 std::vector<std::string> recent(history.begin() +
static_cast<long>(start), history.end());
141 result +=
"Recent messages: " +
join(recent,
" | ") +
"\n\n";
145 result += line +
"\n";
148 result +=
"\"" + message +
"\" -> ";
149 logger->info(
"Classification prompt: {} tiers, {} history, "
151 tiers.size(), history.size(), result.size());
static std::string to_upper(const std::string &s)
Convert string to uppercase.
static std::string join(const std::vector< std::string > &items, const std::string &sep)
Join strings with a separator.
static std::string format_tier_definitions(const std::vector< TierDescriptor > &tiers)
Build tier definition lines for classification prompt.
Auto-generated classification prompt for the router model.
ENTROPIC_EXPORT std::vector< std::string > interleave_examples(const std::vector< TierDescriptor > &tiers)
Round-robin interleave few-shot examples across tiers.
ENTROPIC_EXPORT std::string build_classification_prompt(const std::vector< TierDescriptor > &tiers, const std::string &message, const std::vector< std::string > &history={}, const std::vector< std::string > &recent_tiers={})
Auto-generate classification prompt from tier focus + examples.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.