feat: add model variant selection dialog (#19488)
This commit is contained in:
@@ -5,6 +5,7 @@ import { map, pipe, flatMap, entries, filter, sortBy, take } from "remeda"
|
|||||||
import { DialogSelect } from "@tui/ui/dialog-select"
|
import { DialogSelect } from "@tui/ui/dialog-select"
|
||||||
import { useDialog } from "@tui/ui/dialog"
|
import { useDialog } from "@tui/ui/dialog"
|
||||||
import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
|
import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
|
||||||
|
import { DialogVariant } from "./dialog-variant"
|
||||||
import { useKeybind } from "../context/keybind"
|
import { useKeybind } from "../context/keybind"
|
||||||
import * as fuzzysort from "fuzzysort"
|
import * as fuzzysort from "fuzzysort"
|
||||||
|
|
||||||
@@ -50,8 +51,7 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
disabled: provider.id === "opencode" && model.id.includes("-nano"),
|
disabled: provider.id === "opencode" && model.id.includes("-nano"),
|
||||||
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
||||||
onSelect: () => {
|
onSelect: () => {
|
||||||
dialog.clear()
|
onSelect(provider.id, model.id)
|
||||||
local.model.set({ providerID: provider.id, modelID: model.id }, { recent: true })
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -88,8 +88,7 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
disabled: provider.id === "opencode" && model.includes("-nano"),
|
disabled: provider.id === "opencode" && model.includes("-nano"),
|
||||||
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
||||||
onSelect() {
|
onSelect() {
|
||||||
dialog.clear()
|
onSelect(provider.id, model)
|
||||||
local.model.set({ providerID: provider.id, modelID: model }, { recent: true })
|
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
filter((x) => {
|
filter((x) => {
|
||||||
@@ -135,6 +134,15 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
|
|
||||||
const title = createMemo(() => provider()?.name ?? "Select model")
|
const title = createMemo(() => provider()?.name ?? "Select model")
|
||||||
|
|
||||||
|
function onSelect(providerID: string, modelID: string) {
|
||||||
|
local.model.set({ providerID, modelID }, { recent: true })
|
||||||
|
if (local.model.variant.list().length > 0) {
|
||||||
|
dialog.replace(() => <DialogVariant />)
|
||||||
|
} else {
|
||||||
|
dialog.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogSelect<ReturnType<typeof options>[number]["value"]>
|
<DialogSelect<ReturnType<typeof options>[number]["value"]>
|
||||||
options={options()}
|
options={options()}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { createMemo } from "solid-js"
|
||||||
|
import { useLocal } from "@tui/context/local"
|
||||||
|
import { useSync } from "@tui/context/sync"
|
||||||
|
import { DialogSelect } from "@tui/ui/dialog-select"
|
||||||
|
import { useDialog } from "@tui/ui/dialog"
|
||||||
|
|
||||||
|
export function DialogVariant() {
|
||||||
|
const local = useLocal()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
const options = createMemo(() => {
|
||||||
|
return local.model.variant.list().map((variant) => ({
|
||||||
|
value: variant,
|
||||||
|
title: variant,
|
||||||
|
onSelect: () => {
|
||||||
|
dialog.clear()
|
||||||
|
local.model.variant.set(variant)
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogSelect<string>
|
||||||
|
options={options()}
|
||||||
|
title={"Select variant"}
|
||||||
|
current={local.model.variant.current()}
|
||||||
|
flat={true}
|
||||||
|
skipFilter={true}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user