mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-25 13:19:35 +00:00
24 lines
812 B
TypeScript
24 lines
812 B
TypeScript
// Model parameter B helpers normalize provider-specific reasoning budget values.
|
|
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
|
|
|
|
/** Infers the largest `<number>b` parameter-size token from a model id or display name. */
|
|
export function inferParamBFromIdOrName(text: string): number | null {
|
|
const raw = normalizeLowercaseStringOrEmpty(text);
|
|
const matches = raw.matchAll(/(?:^|[^a-z0-9])[a-z]?(\d+(?:\.\d+)?)b(?:[^a-z0-9]|$)/g);
|
|
let best: number | null = null;
|
|
for (const match of matches) {
|
|
const numRaw = match[1];
|
|
if (!numRaw) {
|
|
continue;
|
|
}
|
|
const value = Number(numRaw);
|
|
if (!Number.isFinite(value) || value <= 0) {
|
|
continue;
|
|
}
|
|
if (best === null || value > best) {
|
|
best = value;
|
|
}
|
|
}
|
|
return best;
|
|
}
|