Files
openchamber/packages/ui/src/lib/modelIdentifier.ts
T
ArtёmandBohdan Triapitsyn d35ff8a2db fix: support slash-containing model IDs (#1074)
* fix: support slash-containing model IDs

* fix: parse worktree default model identifiers

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-05-01 00:34:36 +03:00

21 lines
469 B
TypeScript

export interface ParsedModelIdentifier {
providerId: string;
modelId: string;
}
export const parseModelIdentifier = (value: string | undefined): ParsedModelIdentifier | null => {
if (!value) {
return null;
}
const separatorIndex = value.indexOf('/');
if (separatorIndex <= 0 || separatorIndex >= value.length - 1) {
return null;
}
return {
providerId: value.slice(0, separatorIndex),
modelId: value.slice(separatorIndex + 1),
};
};