mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 04:01:56 +00:00
fix: codex thinking handling
This commit is contained in:
parent
22870ae0c2
commit
02b72b49d5
23 changed files with 205 additions and 754 deletions
|
|
@ -102,6 +102,18 @@ export interface ParsedModelResult {
|
|||
warning: string | undefined;
|
||||
}
|
||||
|
||||
const THINKING_SUFFIXES = ["-none", "-minimal", "-low", "-medium", "-high", "-xhigh"];
|
||||
|
||||
function stripThinkingSuffix(pattern: string): string {
|
||||
const normalized = pattern.toLowerCase();
|
||||
for (const suffix of THINKING_SUFFIXES) {
|
||||
if (normalized.endsWith(suffix)) {
|
||||
return pattern.slice(0, pattern.length - suffix.length);
|
||||
}
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a pattern to extract model and thinking level.
|
||||
* Handles models with colons in their IDs (e.g., OpenRouter's :exacto suffix).
|
||||
|
|
@ -122,6 +134,14 @@ export function parseModelPattern(pattern: string, availableModels: Model<Api>[]
|
|||
return { model: exactMatch, thinkingLevel: "off", warning: undefined };
|
||||
}
|
||||
|
||||
const normalizedPattern = stripThinkingSuffix(pattern);
|
||||
if (normalizedPattern !== pattern) {
|
||||
const normalizedMatch = tryMatchModel(normalizedPattern, availableModels);
|
||||
if (normalizedMatch) {
|
||||
return { model: normalizedMatch, thinkingLevel: "off", warning: undefined };
|
||||
}
|
||||
}
|
||||
|
||||
// No match - try splitting on last colon if present
|
||||
const lastColonIndex = pattern.lastIndexOf(":");
|
||||
if (lastColonIndex === -1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue