13namespace entropic::prompts {
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;
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;
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,
128 const std::vector<std::string>&
history,
131 std::string result =
"Classify the message. Reply with the number only.\n\n";
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.
json lines
Lines taken so far.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
@ optional
optional: every escape asks the host's path approver