mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
mark if model is detected locally
This commit is contained in:
parent
0c10cb73f6
commit
0a444f6ff8
3 changed files with 12 additions and 13 deletions
|
|
@ -222,7 +222,7 @@ class VoidSettingsService extends Disposable implements IVoidSettingsService {
|
|||
|
||||
setDefaultModels(providerName: ProviderName, newDefaultModelNames: string[]) {
|
||||
const { models } = this.state.settingsOfProvider[providerName]
|
||||
const newDefaultModels = modelInfoOfDefaultNames(newDefaultModelNames, models)
|
||||
const newDefaultModels = modelInfoOfDefaultNames(newDefaultModelNames, { isAutodetected: true, existingModels: models })
|
||||
const newModels = [
|
||||
...newDefaultModels,
|
||||
...models.filter(m => !m.isDefault), // keep any non-default models
|
||||
|
|
|
|||
|
|
@ -11,18 +11,21 @@ export type VoidModelInfo = {
|
|||
modelName: string,
|
||||
isDefault: boolean, // whether or not it's a default for its provider
|
||||
isHidden: boolean, // whether or not the user is hiding it
|
||||
isAutodetected?: boolean, // whether the model was autodetected by polling
|
||||
}
|
||||
|
||||
type ModelInfoOfDefaultNamesOptions = { isAutodetected: true, existingModels: VoidModelInfo[] } // | { isOtherOption: true, ...otherOptions }
|
||||
export const modelInfoOfDefaultNames = (modelNames: string[], options?: ModelInfoOfDefaultNamesOptions): VoidModelInfo[] => {
|
||||
|
||||
export const modelInfoOfDefaultNames = (modelNames: string[], existingModels?: VoidModelInfo[]): VoidModelInfo[] => {
|
||||
|
||||
const { isAutodetected, existingModels } = options ?? {}
|
||||
const isDefault = true
|
||||
const isHidden = modelNames.length >= 10 // hide all models if there are a ton of them, and make user enable them individually
|
||||
|
||||
|
||||
if (!existingModels) {
|
||||
return modelNames.map((modelName, i) => ({ modelName, isDefault: true, isHidden, }))
|
||||
|
||||
return modelNames.map((modelName, i) => ({ modelName, isDefault, isAutodetected, isHidden, }))
|
||||
|
||||
} else {
|
||||
// merge `modelNames` with `existingModels`
|
||||
// keep existing `isHidden` property
|
||||
|
||||
const existingModelsMap: Record<string, VoidModelInfo> = {}
|
||||
|
|
@ -30,11 +33,7 @@ export const modelInfoOfDefaultNames = (modelNames: string[], existingModels?: V
|
|||
existingModelsMap[em.modelName] = em
|
||||
}
|
||||
|
||||
return modelNames.map((modelName, i) => ({
|
||||
modelName,
|
||||
isDefault: true,
|
||||
isHidden: !!existingModelsMap[modelName]?.isHidden,
|
||||
}))
|
||||
return modelNames.map((modelName, i) => ({ modelName, isDefault, isAutodetected, isHidden: !!existingModelsMap[modelName]?.isHidden, }))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ export const ModelDump = () => {
|
|||
|
||||
return <div className=''>
|
||||
{modelDump.map(m => {
|
||||
const { isHidden, isDefault, modelName, providerName, providerEnabled } = m
|
||||
const { isHidden, isDefault, isAutodetected, modelName, providerName, providerEnabled } = m
|
||||
|
||||
const disabled = !providerEnabled
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ export const ModelDump = () => {
|
|||
</div>
|
||||
{/* right part is anything that fits */}
|
||||
<div className='w-fit flex items-center gap-4'>
|
||||
<span className='opacity-50 whitespace-nowrap'>{isDefault ? '' : '(custom model)'}</span>
|
||||
<span className='opacity-50 whitespace-nowrap'>{isAutodetected ? '(detected locally)' : isDefault ? '' : '(custom model)'}</span>
|
||||
|
||||
<VoidSwitch
|
||||
value={disabled ? false : !isHidden}
|
||||
|
|
|
|||
Loading…
Reference in a new issue