/** 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 }; }