mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 23:04:41 +00:00
mom: add context usage to thread summary, update docs
- Usage summary now shows context tokens vs model context window - Updated CHANGELOG.md with all recent changes - Updated README.md with new file structure (log.jsonl/context.jsonl)
This commit is contained in:
parent
99fe4802ef
commit
71b776e290
4 changed files with 87 additions and 30 deletions
|
|
@ -195,13 +195,26 @@ export function logUsageSummary(
|
|||
cacheWrite: number;
|
||||
cost: { input: number; output: number; cacheRead: number; cacheWrite: number; total: number };
|
||||
},
|
||||
contextTokens?: number,
|
||||
contextWindow?: number,
|
||||
): string {
|
||||
const formatTokens = (count: number): string => {
|
||||
if (count < 1000) return count.toString();
|
||||
if (count < 10000) return (count / 1000).toFixed(1) + "k";
|
||||
if (count < 1000000) return Math.round(count / 1000) + "k";
|
||||
return (count / 1000000).toFixed(1) + "M";
|
||||
};
|
||||
|
||||
const lines: string[] = [];
|
||||
lines.push("*Usage Summary*");
|
||||
lines.push(`Tokens: ${usage.input.toLocaleString()} in, ${usage.output.toLocaleString()} out`);
|
||||
if (usage.cacheRead > 0 || usage.cacheWrite > 0) {
|
||||
lines.push(`Cache: ${usage.cacheRead.toLocaleString()} read, ${usage.cacheWrite.toLocaleString()} write`);
|
||||
}
|
||||
if (contextTokens && contextWindow) {
|
||||
const contextPercent = ((contextTokens / contextWindow) * 100).toFixed(1);
|
||||
lines.push(`Context: ${formatTokens(contextTokens)} / ${formatTokens(contextWindow)} (${contextPercent}%)`);
|
||||
}
|
||||
lines.push(
|
||||
`Cost: $${usage.cost.input.toFixed(4)} in, $${usage.cost.output.toFixed(4)} out` +
|
||||
(usage.cacheRead > 0 || usage.cacheWrite > 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue