17 lines
384 B
TypeScript
17 lines
384 B
TypeScript
export function normalizeEmbeddingModelWithPrefixes(params: {
|
|
model: string;
|
|
defaultModel: string;
|
|
prefixes: string[];
|
|
}): string {
|
|
const trimmed = params.model.trim();
|
|
if (!trimmed) {
|
|
return params.defaultModel;
|
|
}
|
|
for (const prefix of params.prefixes) {
|
|
if (trimmed.startsWith(prefix)) {
|
|
return trimmed.slice(prefix.length);
|
|
}
|
|
}
|
|
return trimmed;
|
|
}
|