-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcost.cpp
More file actions
20 lines (17 loc) · 705 Bytes
/
Copy pathcost.cpp
File metadata and controls
20 lines (17 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define LLM_COST_IMPLEMENTATION
#include "llm_cost.hpp"
#include <cstdio>
int main() {
std::string prompt; // a 12,000-character prompt
while (prompt.size() < 12000)
prompt += "Summarise the attached incident report. ";
for (const auto& row : llm::compare_costs(prompt))
std::printf("%-18s %5zu tokens %s\n", row.model_name.c_str(),
row.tokens, llm::format_cost(row.input_cost_usd).c_str());
auto tc = llm::count(prompt, llm::models::CLAUDE_OPUS);
try {
llm::assert_budget(tc, 0.01); // refuse anything over one cent
} catch (const std::exception& e) {
std::printf("\nblocked: %s\n", e.what());
}
}