()
| 2177 | } |
| 2178 | |
| 2179 | export async function defaultModel() { |
| 2180 | const cfg = await Config.get() |
| 2181 | if (cfg.model) return parseModel(cfg.model) |
| 2182 | |
| 2183 | const provider = await list() |
| 2184 | .then((val) => Object.values(val)) |
| 2185 | .then((x) => x.find((p) => !cfg.provider || Object.keys(cfg.provider).includes(p.id))) |
| 2186 | if (!provider) throw new Error("no providers found") |
| 2187 | const [model] = sort(Object.values(provider.models)) |
| 2188 | if (!model) throw new Error("no models found") |
| 2189 | return { |
| 2190 | providerID: provider.id, |
| 2191 | modelID: model.id, |
| 2192 | } |
| 2193 | } |
| 2194 | |
| 2195 | export function parseModel(model: string) { |
| 2196 | const [providerPart, ...rest] = model.split("/") |
nothing calls this directly
no test coverage detected