Files
stanp-opencode/src/model.ts
StanPonomarev deaa4bfd07
CI / verify (pull_request) Successful in 10s
fix: fix configurations
2026-10-08 09:18:01 +02:00

10 lines
494 B
TypeScript

/** Parses `provider/model[#variant]`; `name` prefixes the error for the offending option. */
export function model(reference: string, name: string) {
const [path = "", variant] = reference.split("#");
const slash = path.indexOf("/");
if (slash <= 0) throw new Error(`${name} must be provider/model[#variant]: ${reference}`);
const providerID = path.slice(0, slash);
const id = path.slice(slash + 1);
return variant ? { providerID, id, variant } : { providerID, id };
}