mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
17 lines
578 B
TypeScript
17 lines
578 B
TypeScript
|
|
export function extractProviderId(modelId: string): string | null {
|
||
|
|
const trimmed = modelId.trim();
|
||
|
|
if (!trimmed.includes("/")) return null;
|
||
|
|
const provider = trimmed.slice(0, trimmed.indexOf("/")).trim();
|
||
|
|
return provider || null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function extractProviderIdWithFallback(modelId: string, fallback = "other"): string {
|
||
|
|
return extractProviderId(modelId) ?? fallback;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function extractModelName(modelId: string): string {
|
||
|
|
const trimmed = modelId.trim();
|
||
|
|
if (!trimmed.includes("/")) return trimmed;
|
||
|
|
return trimmed.slice(trimmed.indexOf("/") + 1);
|
||
|
|
}
|