Skip to content

Commit

Permalink
fix: Fixed the problem of abnormal list items in the model list due t…
Browse files Browse the repository at this point in the history
…o non-unique official displayName
  • Loading branch information
Amery2010 committed Dec 9, 2024
1 parent de239e7 commit 0d7dd47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
12 changes: 7 additions & 5 deletions components/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import locales from '@/constant/locales'
import { Model } from '@/constant/model'
import { useSettingStore } from '@/store/setting'
import { useModelStore } from '@/store/model'
import { toPairs, values, has, omitBy, isFunction } from 'lodash-es'
import { toPairs, values, keys, omitBy, isFunction } from 'lodash-es'

import pkg from '@/package.json'

Expand Down Expand Up @@ -71,16 +71,18 @@ function Setting({ open, hiddenTalkPanel, onClose }: SettingProps) {
const { update } = useSettingStore.getState()

if (modelStore.models.length > 0) {
const models = values(Model)
modelStore.models.forEach((item) => {
if (!has(Model, item.displayName)) {
Model[item.displayName] = item.name.replace('models/', '')
const modelName = item.name.replace('models/', '')
if (!models.includes(modelName)) {
Model[modelName] = item.displayName
}
})
}

let modelList: string[] = []
let defaultModel = 'gemini-1.5-flash-latest'
const defaultModelList: string[] = Object.values(Model)
const defaultModelList: string[] = keys(Model)
const userModels: string[] = GEMINI_MODEL_LIST ? GEMINI_MODEL_LIST.split(',') : []

userModels.forEach((modelName) => {
Expand Down Expand Up @@ -354,7 +356,7 @@ function Setting({ open, hiddenTalkPanel, onClose }: SettingProps) {
{modelOptions.map((name) => {
return (
<SelectItem key={name} value={name}>
{name}
{Model[name]}
</SelectItem>
)
})}
Expand Down
24 changes: 12 additions & 12 deletions constant/model.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export const Model: Record<string, string> = {
'Gemini 1.5 Pro': 'gemini-1.5-pro',
'Gemini 1.5 Pro Latest': 'gemini-1.5-pro-latest',
'Gemini 1.5 Flash': 'gemini-1.5-flash',
'Gemini 1.5 Flash Latest': 'gemini-1.5-flash-latest',
'Gemini 1.5 Flash-8B': 'gemini-1.5-flash-8b',
'Gemini 1.5 Flash-8B Latest': 'gemini-1.5-flash-8b-latest',
'Gemini 1.0 Pro Vision': 'gemini-1.0-pro-vision',
'Gemini 1.0 Pro Vision Latest': 'gemini-1.0-pro-vision-latest',
'Gemini 1.0 Pro': 'gemini-1.0-pro',
'Gemini 1.0 Pro Latest': 'gemini-1.0-pro-latest',
'Gemini Pro Vision': 'gemini-pro-vision',
'Gemini Pro': 'gemini-pro',
'gemini-1.5-pro': 'Gemini 1.5 Pro',
'gemini-1.5-pro-latest': 'Gemini 1.5 Pro Latest',
'gemini-1.5-flash': 'Gemini 1.5 Flash',
'gemini-1.5-flash-latest': 'Gemini 1.5 Flash Latest',
'gemini-1.5-flash-8b': 'Gemini 1.5 Flash-8B',
'gemini-1.5-flash-8b-latest': 'Gemini 1.5 Flash-8B Latest',
'gemini-1.0-pro-vision': 'Gemini 1.0 Pro Vision',
'gemini-1.0-pro-vision-latest': 'Gemini 1.0 Pro Vision Latest',
'gemini-1.0-pro': 'Gemini 1.0 Pro',
'gemini-1.0-pro-latest': 'Gemini 1.0 Pro Latest',
'gemini-pro-vision': 'Gemini Pro Vision',
'gemini-pro': 'Gemini Pro',
}

export const OldVisionModel = ['gemini-pro-vision', 'gemini-1.0-pro-vision-latest']
Expand Down

0 comments on commit 0d7dd47

Please sign in to comment.