fix: show model display name in message footer and transcript (#20539)
This commit is contained in:
parent
b1c07488bd
commit
c526caae7b
4 changed files with 170 additions and 13 deletions
23
packages/opencode/src/cli/cmd/tui/util/model.ts
Normal file
23
packages/opencode/src/cli/cmd/tui/util/model.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import type { Provider } from "@opencode-ai/sdk/v2"
|
||||
|
||||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue