mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 23:10:20 +08:00
feat: initialize painting model with first available option and update default provider to 'cherryin'
This commit is contained in:
parent
b8da00a99f
commit
7fb6b1377b
@ -481,6 +481,13 @@ const NewApiPage: FC<{ Options: string[] }> = ({ Options }) => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
// if painting.model is not set, set it to the first model in modelOptions
|
||||
useEffect(() => {
|
||||
if (!painting.model && modelOptions.length > 0) {
|
||||
updatePaintingState({ model: modelOptions[0].value })
|
||||
}
|
||||
}, [modelOptions, painting.model, updatePaintingState])
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Navbar>
|
||||
|
||||
@ -3,8 +3,10 @@ import { isNewApiProvider } from '@renderer/config/providers'
|
||||
import { useAllProviders } from '@renderer/hooks/useProvider'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setDefaultPaintingProvider } from '@renderer/store/settings'
|
||||
import { PaintingProvider, SystemProviderId } from '@renderer/types'
|
||||
import { FC, useEffect, useMemo } from 'react'
|
||||
import { updateTab } from '@renderer/store/tabs'
|
||||
import type { PaintingProvider, SystemProviderId } from '@renderer/types'
|
||||
import type { FC } from 'react'
|
||||
import { useEffect, useMemo } from 'react'
|
||||
import { Route, Routes, useParams } from 'react-router-dom'
|
||||
|
||||
import AihubmixPage from './AihubmixPage'
|
||||
@ -23,31 +25,30 @@ const PaintingsRoutePage: FC = () => {
|
||||
const provider = params['*']
|
||||
const dispatch = useAppDispatch()
|
||||
const providers = useAllProviders()
|
||||
const Options = useMemo(() => {
|
||||
return [...BASE_OPTIONS, ...providers.filter((p) => isNewApiProvider(p)).map((p) => p.id)]
|
||||
}, [providers])
|
||||
|
||||
const Options = useMemo(() => [...BASE_OPTIONS, ...providers.filter(isNewApiProvider).map((p) => p.id)], [providers])
|
||||
const newApiProviders = useMemo(() => providers.filter(isNewApiProvider), [providers])
|
||||
|
||||
useEffect(() => {
|
||||
logger.debug(`defaultPaintingProvider: ${provider}`)
|
||||
if (provider && Options.includes(provider)) {
|
||||
dispatch(setDefaultPaintingProvider(provider as PaintingProvider))
|
||||
dispatch(updateTab({ id: 'paintings', updates: { path: `/paintings/${provider}` } }))
|
||||
}
|
||||
}, [provider, dispatch, Options])
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="*" element={<ZhipuPage Options={Options} />} />
|
||||
<Route path="*" element={<NewApiPage Options={Options} />} />
|
||||
<Route path="/zhipu" element={<ZhipuPage Options={Options} />} />
|
||||
<Route path="/aihubmix" element={<AihubmixPage Options={Options} />} />
|
||||
<Route path="/silicon" element={<SiliconPage Options={Options} />} />
|
||||
<Route path="/dmxapi" element={<DmxapiPage Options={Options} />} />
|
||||
<Route path="/tokenflux" element={<TokenFluxPage Options={Options} />} />
|
||||
{/* new-api family providers are mounted dynamically below */}
|
||||
{providers
|
||||
.filter((p) => isNewApiProvider(p))
|
||||
.map((p) => (
|
||||
<Route key={p.id} path={`/${p.id}`} element={<NewApiPage Options={Options} />} />
|
||||
))}
|
||||
{newApiProviders.map((p) => (
|
||||
<Route key={p.id} path={`/${p.id}`} element={<NewApiPage Options={Options} />} />
|
||||
))}
|
||||
</Routes>
|
||||
)
|
||||
}
|
||||
|
||||
@ -2614,6 +2614,7 @@ const migrateConfig = {
|
||||
try {
|
||||
addProvider(state, 'sophnet')
|
||||
state.llm.providers = moveProvider(state.llm.providers, 'sophnet', 17)
|
||||
state.settings.defaultPaintingProvider = 'cherryin'
|
||||
return state
|
||||
} catch (error) {
|
||||
logger.error('migrate 164 error', error as Error)
|
||||
|
||||
@ -388,7 +388,7 @@ export const initialState: SettingsState = {
|
||||
localBackupSyncInterval: 0,
|
||||
localBackupMaxBackups: 0,
|
||||
localBackupSkipBackupFile: false,
|
||||
defaultPaintingProvider: 'zhipu',
|
||||
defaultPaintingProvider: 'cherryin',
|
||||
s3: {
|
||||
endpoint: '',
|
||||
region: '',
|
||||
|
||||
@ -425,7 +425,7 @@ export type PaintingParams = {
|
||||
providerId?: string
|
||||
}
|
||||
|
||||
export type PaintingProvider = 'zhipu' | 'aihubmix' | 'silicon' | 'dmxapi' | 'new-api'
|
||||
export type PaintingProvider = 'zhipu' | 'aihubmix' | 'silicon' | 'dmxapi' | 'new-api' | 'cherryin'
|
||||
|
||||
export interface Painting extends PaintingParams {
|
||||
model?: string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user