Download packages/tui/src/util/model.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 850 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/util/model.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/tui/src/util/model.ts
-
curl -L -o model.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/util/model.ts
850 Bytes
| import type { Provider } from "@opencode-ai/sdk/v2" | |
| export function parse(value: string) { | |
| const [providerID, ...modelID] = value.split("/") | |
| return { providerID, modelID: modelID.join("/") } | |
| } | |
| export function index(list: Provider[] | undefined) { | |
| return new Map((list ?? []).map((item) => [item.id, item] as const)) | |
| } | |
| export function get(list: Provider[] | ReadonlyMap<string, Provider> | undefined, providerID: string, modelID: string) { | |
| const provider = | |
| list instanceof Map | |
| ? list.get(providerID) | |
| : Array.isArray(list) | |
| ? list.find((item) => item.id === providerID) | |
| : undefined | |
| return provider?.models[modelID] | |
| } | |
| export function name( | |
| list: Provider[] | ReadonlyMap<string, Provider> | undefined, | |
| providerID: string, | |
| modelID: string, | |
| ) { | |
| return get(list, providerID, modelID)?.name ?? modelID | |
| } | |