mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 05:31:47 +00:00
- Bug B1-B7: media UI m.kind||m.type, serviceKinds, gemini mediaPriority, schema kind, models/info lookup by kind - Dead code D1-D6: safeParseJSON, drop PROVIDER_ENDPOINTS, orphan fetcher, GITHUB_CONFIG derive, getProviderConfig internal, legacy kiro file - Translator concerns: toOpenAIUsage, toOpenAIFinish (gemini/kiro/ollama + fix kiro tool finish), thinking effort maps - Reorg helpers/ → concerns/ (logic) + formats/ (per-format) + schema/ (pure enums: roles/blocks/finishReasons/defaults) - Wire ~280 hardcoded role/block/finish/default literals to schema enums across 20+ files - collapseTextParts + extractTextContent dedup - Normalize translator fn names to openaiToXRequest / xToOpenAIResponse - Golden tests lock behavior; 0 regression (byte-for-byte providers/alias, 26=26 known fails) Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// Concern: reasoning_effort ↔ provider-native thinking config.
|
|
// Each provider expresses "how much to think" differently — centralize the maps here.
|
|
// Streaming reasoning delta shape lives in reasoning.js; this file is request-side config only.
|
|
|
|
// OpenAI reasoning_effort → Claude thinking.budget_tokens
|
|
const EFFORT_TO_BUDGET = { none: 0, low: 4096, medium: 8192, high: 16384, xhigh: 32768 };
|
|
|
|
// Returns budget_tokens for a reasoning_effort, or undefined if unknown effort.
|
|
// 0 means "no thinking" (caller skips enabling); undefined means "effort not recognized".
|
|
export function effortToBudget(effort) {
|
|
if (!effort) return undefined;
|
|
return EFFORT_TO_BUDGET[String(effort).toLowerCase()];
|
|
}
|
|
|
|
// OpenAI reasoning_effort → Gemini thinkingLevel (gemini-3 enum: minimal|low|medium|high).
|
|
// Gemini 3 cannot fully disable thinking; "none"/"off" map to "minimal" (closest to off).
|
|
export function effortToThinkingLevel(effort) {
|
|
const e = String(effort).toLowerCase().trim();
|
|
return e === "none" || e === "off" ? "minimal" : e;
|
|
}
|
|
|
|
// Gemini thinkingBudget (numeric) → OpenAI reasoning_effort (antigravity reverse map).
|
|
// Returns null when budget <= 0 (no reasoning).
|
|
export function budgetToEffort(budget) {
|
|
if (!budget || budget <= 0) return null;
|
|
if (budget <= 2048) return "low";
|
|
if (budget <= 16384) return "medium";
|
|
return "high";
|
|
}
|