mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
refactor: remove ollama settings
This commit is contained in:
parent
36c87451d9
commit
e8384db91a
@ -1,18 +0,0 @@
|
|||||||
import store, { useAppSelector } from '@renderer/store'
|
|
||||||
import { setOllamaKeepAliveTime } from '@renderer/store/llm'
|
|
||||||
import { useDispatch } from 'react-redux'
|
|
||||||
|
|
||||||
export function useOllamaSettings() {
|
|
||||||
const settings = useAppSelector((state) => state.llm.settings.ollama)
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
|
|
||||||
return { ...settings, setKeepAliveTime: (time: number) => dispatch(setOllamaKeepAliveTime(time)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getOllamaSettings() {
|
|
||||||
return store.getState().llm.settings.ollama
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getOllamaKeepAliveTime() {
|
|
||||||
return store.getState().llm.settings.ollama.keepAliveTime + 'm'
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import { useOllamaSettings } from '@renderer/hooks/useOllama'
|
|
||||||
import { InputNumber } from 'antd'
|
|
||||||
import { FC, useState } from 'react'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
import styled from 'styled-components'
|
|
||||||
|
|
||||||
import { SettingHelpText, SettingHelpTextRow, SettingSubtitle } from '..'
|
|
||||||
|
|
||||||
const OllamSettings: FC = () => {
|
|
||||||
const { keepAliveTime, setKeepAliveTime } = useOllamaSettings()
|
|
||||||
const [keepAliveMinutes, setKeepAliveMinutes] = useState(keepAliveTime)
|
|
||||||
const { t } = useTranslation()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<SettingSubtitle style={{ marginBottom: 5 }}>{t('ollama.keep_alive_time.title')}</SettingSubtitle>
|
|
||||||
<InputNumber
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
value={keepAliveMinutes}
|
|
||||||
onChange={(e) => setKeepAliveMinutes(Number(e))}
|
|
||||||
onBlur={() => setKeepAliveTime(keepAliveMinutes)}
|
|
||||||
suffix={t('ollama.keep_alive_time.placeholder')}
|
|
||||||
step={5}
|
|
||||||
/>
|
|
||||||
<SettingHelpTextRow>
|
|
||||||
<SettingHelpText>{t('ollama.keep_alive_time.description')}</SettingHelpText>
|
|
||||||
</SettingHelpTextRow>
|
|
||||||
</Container>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Container = styled.div``
|
|
||||||
|
|
||||||
export default OllamSettings
|
|
||||||
@ -35,7 +35,6 @@ import HealthCheckPopup from './HealthCheckPopup'
|
|||||||
import LMStudioSettings from './LMStudioSettings'
|
import LMStudioSettings from './LMStudioSettings'
|
||||||
import ModelList, { ModelStatus } from './ModelList'
|
import ModelList, { ModelStatus } from './ModelList'
|
||||||
import ModelListSearchBar from './ModelListSearchBar'
|
import ModelListSearchBar from './ModelListSearchBar'
|
||||||
import OllamSettings from './OllamaSettings'
|
|
||||||
import ProviderOAuth from './ProviderOAuth'
|
import ProviderOAuth from './ProviderOAuth'
|
||||||
import ProviderSettingsPopup from './ProviderSettingsPopup'
|
import ProviderSettingsPopup from './ProviderSettingsPopup'
|
||||||
import SelectProviderModelPopup from './SelectProviderModelPopup'
|
import SelectProviderModelPopup from './SelectProviderModelPopup'
|
||||||
@ -348,7 +347,7 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
onUpdateApiKey()
|
onUpdateApiKey()
|
||||||
}}
|
}}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
autoFocus={provider.enabled && apiKey === ''}
|
autoFocus={provider.enabled && apiKey === '' && !isProviderSupportAuth(provider)}
|
||||||
disabled={provider.id === 'copilot'}
|
disabled={provider.id === 'copilot'}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@ -405,7 +404,6 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
</Space.Compact>
|
</Space.Compact>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{provider.id === 'ollama' && <OllamSettings />}
|
|
||||||
{provider.id === 'lmstudio' && <LMStudioSettings />}
|
{provider.id === 'lmstudio' && <LMStudioSettings />}
|
||||||
{provider.id === 'gpustack' && <GPUStackSettings />}
|
{provider.id === 'gpustack' && <GPUStackSettings />}
|
||||||
{provider.id === 'copilot' && <GithubCopilotSettings provider={provider} setApiKey={setApiKey} />}
|
{provider.id === 'copilot' && <GithubCopilotSettings provider={provider} setApiKey={setApiKey} />}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { REFERENCE_PROMPT } from '@renderer/config/prompts'
|
import { REFERENCE_PROMPT } from '@renderer/config/prompts'
|
||||||
import { getLMStudioKeepAliveTime } from '@renderer/hooks/useLMStudio'
|
import { getLMStudioKeepAliveTime } from '@renderer/hooks/useLMStudio'
|
||||||
import { getOllamaKeepAliveTime } from '@renderer/hooks/useOllama'
|
|
||||||
import type {
|
import type {
|
||||||
Assistant,
|
Assistant,
|
||||||
GenerateImageParams,
|
GenerateImageParams,
|
||||||
@ -78,11 +77,7 @@ export default abstract class BaseProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get keepAliveTime() {
|
public get keepAliveTime() {
|
||||||
return this.provider.id === 'ollama'
|
return this.provider.id === 'lmstudio' ? getLMStudioKeepAliveTime() : undefined
|
||||||
? getOllamaKeepAliveTime()
|
|
||||||
: this.provider.id === 'lmstudio'
|
|
||||||
? getLMStudioKeepAliveTime()
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fakeCompletions({ onChunk }: CompletionsParams) {
|
public async fakeCompletions({ onChunk }: CompletionsParams) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user