add anthropic/ provider prefix for claude models, preserve date suffixes, passthrough provider-prefixed models
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { normalizeModelID } from "../../shared/model-normalization"
|
||||
|
||||
const DATE_SUFFIX_PATTERN = /-\d{8}$/
|
||||
const ANTHROPIC_PREFIX = "anthropic/"
|
||||
|
||||
export function mapClaudeModelToOpenCode(model: string | undefined): string | undefined {
|
||||
if (!model) return undefined
|
||||
@@ -8,6 +8,15 @@ export function mapClaudeModelToOpenCode(model: string | undefined): string | un
|
||||
const trimmed = model.trim()
|
||||
if (trimmed.length === 0) return undefined
|
||||
|
||||
const withoutDate = trimmed.replace(DATE_SUFFIX_PATTERN, "")
|
||||
return normalizeModelID(withoutDate)
|
||||
if (trimmed.includes("/")) {
|
||||
return trimmed
|
||||
}
|
||||
|
||||
const normalized = normalizeModelID(trimmed)
|
||||
|
||||
if (normalized.startsWith("claude-")) {
|
||||
return `${ANTHROPIC_PREFIX}${normalized}`
|
||||
}
|
||||
|
||||
return normalized
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user