feat(antigravity): add model specs and update mapping logic

This commit is contained in:
Draculabo committed 2026-03-06 21:48:24 +08:00
1 parent 30e38dcb8b
commit 0a60c0eafa
11 files changed
+552 -82

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import modelSpecsJson from './model-specs';
type ModelSpec = {
max_output_tokens?: number;
thinking_budget?: number;
is_thinking?: boolean;
};
type SpecsConfig = {
models: Record<string, ModelSpec>;
aliases: Record<string, string>;
};
const DEFAULT_MAX_OUTPUT_TOKENS = 65535;
const DEFAULT_THINKING_BUDGET = 24576;
const SPECS = modelSpecsJson as SpecsConfig;
export function resolveModelAlias(modelId: string): string {
const normalized = modelId.trim();
return SPECS.aliases[normalized] ?? normalized;
}
export function getMaxOutputTokens(modelId: string): number {
const resolved = resolveModelAlias(modelId);
const fromSpec = SPECS.models[resolved]?.max_output_tokens;
if (typeof fromSpec === 'number' && Number.isFinite(fromSpec) && fromSpec > 0) {
return Math.floor(fromSpec);
}
return DEFAULT_MAX_OUTPUT_TOKENS;
}
export function getThinkingBudget(modelId: string): number {
const resolved = resolveModelAlias(modelId);
const fromSpec = SPECS.models[resolved]?.thinking_budget;
if (typeof fromSpec === 'number' && Number.isFinite(fromSpec) && fromSpec >= 0) {
return Math.floor(fromSpec);
}
return DEFAULT_THINKING_BUDGET;
}