regenerate OpenAPI spec and add model selection components

This commit is contained in:
Chris Scott committed 2026-01-10 18:39:12 -05:00
1 parent 9ed292af2a
commit 17ee96d316
12 files changed
+10266 -3453

No files matched your search

+37 -2
View File
@@ -9,11 +9,15 @@ export interface ModelSelection {
interface ModelStore {
model: ModelSelection | null
recentModels: ModelSelection[]
variants: Record<string, string | undefined>
isInitialized: boolean
setModel: (model: ModelSelection) => void
initializeFromConfig: (configModel: string | undefined) => void
getModelString: () => string | null
setVariant: (model: ModelSelection, variant: string | undefined) => void
getVariant: (model: ModelSelection) => string | undefined
clearVariant: (model: ModelSelection) => void
}
const MAX_RECENT_MODELS = 10
@@ -30,6 +34,7 @@ export const useModelStore = create<ModelStore>()(
(set, get) => ({
model: null,
recentModels: [],
variants: {},
isInitialized: false,
setModel: (model: ModelSelection) => {
@@ -67,13 +72,43 @@ export const useModelStore = create<ModelStore>()(
if (!model) return null
return `${model.providerID}/${model.modelID}`
},
setVariant: (model: ModelSelection, variant: string | undefined) => {
set((state) => {
const key = `${model.providerID}/${model.modelID}`
return {
variants: {
...state.variants,
[key]: variant,
},
}
})
},
getVariant: (model: ModelSelection) => {
const state = get()
const key = `${model.providerID}/${model.modelID}`
return state.variants[key]
},
clearVariant: (model: ModelSelection) => {
set((state) => {
const key = `${model.providerID}/${model.modelID}`
const newVariants = { ...state.variants }
delete newVariants[key]
return {
variants: newVariants,
}
})
},
}),
{
name: 'opencode-model-selection',
partialize: (state) => ({
model: state.model,
recentModels: state.recentModels,
variants: state.variants,
}),
}
)
)
)