parent
fc35df65b8
commit
e7545c5a94
@ -45,7 +45,7 @@ export const AGENT_PROMPT = `
|
||||
`
|
||||
|
||||
export const SUMMARIZE_PROMPT =
|
||||
'你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,不要使用标点符号和其他特殊符号。'
|
||||
'你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,标题语言与用户的首要语言一致,不要使用标点符号和其他特殊符号'
|
||||
|
||||
export const TRANSLATE_PROMPT =
|
||||
'You are a translation expert. Translate from input language to {{target_language}}, provide the translation result directly without any explanation and keep original format. Do not translate if the target language is the same as the source language.'
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { useAppDispatch, useAppSelector } from '@renderer/store'
|
||||
import store, { useAppDispatch, useAppSelector } from '@renderer/store'
|
||||
import {
|
||||
SendMessageShortcut,
|
||||
setSendMessageShortcut as _setSendMessageShortcut,
|
||||
setTheme,
|
||||
SettingsState,
|
||||
setTopicPosition,
|
||||
setTray,
|
||||
setWindowStyle
|
||||
@ -41,3 +42,7 @@ export function useMessageStyle() {
|
||||
isBubbleStyle
|
||||
}
|
||||
}
|
||||
|
||||
export const getStoreSetting = (key: keyof SettingsState) => {
|
||||
return store.getState().settings[key]
|
||||
}
|
||||
|
||||
@ -417,6 +417,7 @@
|
||||
"models.translate_model_prompt_title": "Translate Model Prompt",
|
||||
"models.topic_naming_model_setting_title": "Topic Naming Model Settings",
|
||||
"models.enable_topic_naming": "Topic Auto Naming",
|
||||
"models.topic_naming_prompt": "Topic Naming Prompt",
|
||||
"provider": {
|
||||
"add.name": "Provider Name",
|
||||
"add.name.placeholder": "Example: OpenAI",
|
||||
@ -586,6 +587,9 @@
|
||||
"embedding_model": "Embedding Model",
|
||||
"embedding_model_tooltip": "Add in Settings->Model Provider->Manage",
|
||||
"dimensions": "Dimensions {{dimensions}}"
|
||||
},
|
||||
"prompts": {
|
||||
"summarize": "You are an assistant who is good at conversation. You need to summarize the user's conversation into a title of 10 characters or less, ensuring it matches the user's primary language without using punctuation or other special symbols."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,6 +415,7 @@
|
||||
"models.translate_model_prompt_title": "翻訳モデルのプロンプト",
|
||||
"models.topic_naming_model_setting_title": "トピック命名モデルの設定",
|
||||
"models.enable_topic_naming": "トピックの自動命名",
|
||||
"models.topic_naming_prompt": "トピック命名プロンプト",
|
||||
"provider": {
|
||||
"add.name": "プロバイダー名",
|
||||
"add.name.placeholder": "例:OpenAI",
|
||||
@ -568,6 +569,9 @@
|
||||
"embedding": "埋め込みモデル",
|
||||
"embedding_model": "埋め込みモデル",
|
||||
"embedding_model_tooltip": "設定->モデルサービス->管理で追加"
|
||||
},
|
||||
"prompts": {
|
||||
"summarize": "あなたは会話を得意とするアシスタントです。ユーザーの会話を10文字以内のタイトルに要約し、ユーザーの主言語と一致していることを確認してください。句読点や特殊記号は使用しないでください。"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,6 +417,7 @@
|
||||
"models.translate_model_prompt_title": "Модель перевода",
|
||||
"models.topic_naming_model_setting_title": "Настройки модели именования топика",
|
||||
"models.enable_topic_naming": "Автоматическое переименование топика",
|
||||
"models.topic_naming_prompt": "Подсказка для именования топика",
|
||||
"provider": {
|
||||
"add.name": "Имя провайдера",
|
||||
"add.name.placeholder": "Пример: OpenAI",
|
||||
@ -586,6 +587,9 @@
|
||||
"embedding_model": "Встраиваемые модели",
|
||||
"embedding_model_tooltip": "Добавьте в настройки->модель сервиса->управление",
|
||||
"dimensions": "{{dimensions}} мер"
|
||||
},
|
||||
"prompts": {
|
||||
"summarize": "Вы - эксперт в общении, который суммирует разговоры пользователя в 10-символьном заголовке, совпадающем с языком пользователя, без использования знаков препинания и других специальных символов"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,6 +418,7 @@
|
||||
"models.translate_model_prompt_title": "翻译模型提示词",
|
||||
"models.topic_naming_model_setting_title": "话题命名模型设置",
|
||||
"models.enable_topic_naming": "话题自动重命名",
|
||||
"models.topic_naming_prompt": "话题命名提示词",
|
||||
"provider": {
|
||||
"add.name": "提供商名称",
|
||||
"add.name.placeholder": "例如 OpenAI",
|
||||
@ -575,6 +576,9 @@
|
||||
"embedding_model": "嵌入模型",
|
||||
"embedding_model_tooltip": "在设置->模型服务中点击管理按钮添加",
|
||||
"dimensions": "{{dimensions}} 维"
|
||||
},
|
||||
"prompts": {
|
||||
"summarize": "你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,标题语言与用户的首要语言一致,不要使用标点符号和其他特殊符号"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,6 +417,7 @@
|
||||
"models.translate_model_prompt_title": "翻譯模型提示詞",
|
||||
"models.topic_naming_model_setting_title": "話題命名模型設定",
|
||||
"models.enable_topic_naming": "話題自動重命名",
|
||||
"models.topic_naming_prompt": "話題命名提示詞",
|
||||
"provider": {
|
||||
"add.name": "提供者名稱",
|
||||
"add.name.placeholder": "例如:OpenAI",
|
||||
@ -574,6 +575,9 @@
|
||||
"embedding_model": "嵌入模型",
|
||||
"embedding_model_tooltip": "在设置->模型服务中点击管理按钮添加",
|
||||
"dimensions": "{{dimensions}} 維"
|
||||
},
|
||||
"prompts": {
|
||||
"summarize": "你是一名擅長會話的助理,你需要將用戶的會話總結為 10 個字以內的標題,標題語言與用戶的首要語言一致,不要使用標點符號和其他特殊符號"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { HStack } from '@renderer/components/Layout'
|
||||
import { useSettings } from '@renderer/hooks/useSettings'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setEnableTopicNaming } from '@renderer/store/settings'
|
||||
import { Divider, Modal, Switch } from 'antd'
|
||||
import { setEnableTopicNaming, setTopicNamingPrompt } from '@renderer/store/settings'
|
||||
import { Button, Divider, Input, Modal, Switch } from 'antd'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
@ -15,7 +15,7 @@ interface Props {
|
||||
const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
const [open, setOpen] = useState(true)
|
||||
const { t } = useTranslation()
|
||||
const { enableTopicNaming } = useSettings()
|
||||
const { enableTopicNaming, topicNamingPrompt } = useSettings()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
const onOk = () => {
|
||||
@ -30,6 +30,10 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
resolve({})
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
dispatch(setTopicNamingPrompt(''))
|
||||
}
|
||||
|
||||
TopicNamingModalPopup.hide = onCancel
|
||||
|
||||
return (
|
||||
@ -47,6 +51,21 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
<div>{t('settings.models.enable_topic_naming')}</div>
|
||||
<Switch checked={enableTopicNaming} onChange={(v) => dispatch(setEnableTopicNaming(v))} />
|
||||
</HStack>
|
||||
<Divider style={{ margin: '10px 0' }} />
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<div style={{ marginBottom: 10 }}>{t('settings.models.topic_naming_prompt')}</div>
|
||||
<Input.TextArea
|
||||
rows={4}
|
||||
value={topicNamingPrompt || t('prompts.summarize')}
|
||||
onChange={(e) => dispatch(setTopicNamingPrompt(e.target.value.trim()))}
|
||||
placeholder={t('prompts.summarize')}
|
||||
/>
|
||||
{topicNamingPrompt && (
|
||||
<Button style={{ marginTop: 10 }} onClick={handleReset}>
|
||||
{t('common.reset')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@ -2,7 +2,8 @@ import Anthropic from '@anthropic-ai/sdk'
|
||||
import { MessageCreateParamsNonStreaming, MessageParam } from '@anthropic-ai/sdk/resources'
|
||||
import { DEFAULT_MAX_TOKENS } from '@renderer/config/constant'
|
||||
import { isEmbeddingModel } from '@renderer/config/models'
|
||||
import { SUMMARIZE_PROMPT } from '@renderer/config/prompts'
|
||||
import { getStoreSetting } from '@renderer/hooks/useSettings'
|
||||
import i18n from '@renderer/i18n'
|
||||
import { getAssistantSettings, getDefaultModel, getTopNamingModel } from '@renderer/services/AssistantService'
|
||||
import { EVENT_NAMES } from '@renderer/services/EventService'
|
||||
import { filterContextMessages } from '@renderer/services/MessagesService'
|
||||
@ -188,7 +189,7 @@ export default class AnthropicProvider extends BaseProvider {
|
||||
|
||||
const systemMessage = {
|
||||
role: 'system',
|
||||
content: SUMMARIZE_PROMPT
|
||||
content: (getStoreSetting('topicNamingPrompt') as string) || i18n.t('prompts.summarize')
|
||||
}
|
||||
|
||||
const userMessage = {
|
||||
|
||||
@ -9,7 +9,8 @@ import {
|
||||
TextPart
|
||||
} from '@google/generative-ai'
|
||||
import { isEmbeddingModel, isWebSearchModel } from '@renderer/config/models'
|
||||
import { SUMMARIZE_PROMPT } from '@renderer/config/prompts'
|
||||
import { getStoreSetting } from '@renderer/hooks/useSettings'
|
||||
import i18n from '@renderer/i18n'
|
||||
import { getAssistantSettings, getDefaultModel, getTopNamingModel } from '@renderer/services/AssistantService'
|
||||
import { EVENT_NAMES } from '@renderer/services/EventService'
|
||||
import { filterContextMessages } from '@renderer/services/MessagesService'
|
||||
@ -198,7 +199,7 @@ export default class GeminiProvider extends BaseProvider {
|
||||
|
||||
const systemMessage = {
|
||||
role: 'system',
|
||||
content: SUMMARIZE_PROMPT
|
||||
content: (getStoreSetting('topicNamingPrompt') as string) || i18n.t('prompts.summarize')
|
||||
}
|
||||
|
||||
const userMessage = {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { isEmbeddingModel, isSupportedModel, isVisionModel } from '@renderer/config/models'
|
||||
import { SUMMARIZE_PROMPT } from '@renderer/config/prompts'
|
||||
import { getStoreSetting } from '@renderer/hooks/useSettings'
|
||||
import i18n from '@renderer/i18n'
|
||||
import { getAssistantSettings, getDefaultModel, getTopNamingModel } from '@renderer/services/AssistantService'
|
||||
import { EVENT_NAMES } from '@renderer/services/EventService'
|
||||
import { filterContextMessages } from '@renderer/services/MessagesService'
|
||||
@ -219,7 +220,7 @@ export default class OpenAIProvider extends BaseProvider {
|
||||
|
||||
const systemMessage = {
|
||||
role: 'system',
|
||||
content: SUMMARIZE_PROMPT
|
||||
content: getStoreSetting('topicNamingPrompt') || i18n.t('prompts.summarize')
|
||||
}
|
||||
|
||||
const userMessage = {
|
||||
|
||||
@ -28,7 +28,7 @@ const persistedReducer = persistReducer(
|
||||
{
|
||||
key: 'cherry-studio',
|
||||
storage,
|
||||
version: 50,
|
||||
version: 51,
|
||||
blacklist: ['runtime'],
|
||||
migrate
|
||||
},
|
||||
|
||||
@ -771,6 +771,10 @@ const migrateConfig = {
|
||||
enabled: false
|
||||
})
|
||||
return state
|
||||
},
|
||||
'51': (state: RootState) => {
|
||||
state.settings.topicNamingPrompt = ''
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ export interface SettingsState {
|
||||
showMinappIcon: boolean
|
||||
showFilesIcon: boolean
|
||||
customCss: string
|
||||
topicNamingPrompt: string
|
||||
}
|
||||
|
||||
const initialState: SettingsState = {
|
||||
@ -85,7 +86,8 @@ const initialState: SettingsState = {
|
||||
enableTopicNaming: true,
|
||||
showMinappIcon: true,
|
||||
showFilesIcon: true,
|
||||
customCss: ''
|
||||
customCss: '',
|
||||
topicNamingPrompt: ''
|
||||
}
|
||||
|
||||
const settingsSlice = createSlice({
|
||||
@ -212,6 +214,9 @@ const settingsSlice = createSlice({
|
||||
},
|
||||
setCustomCss: (state, action: PayloadAction<string>) => {
|
||||
state.customCss = action.payload
|
||||
},
|
||||
setTopicNamingPrompt: (state, action: PayloadAction<string>) => {
|
||||
state.topicNamingPrompt = action.payload
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -256,7 +261,8 @@ export const {
|
||||
setShowMinappIcon,
|
||||
setShowFilesIcon,
|
||||
setPasteLongTextThreshold,
|
||||
setCustomCss
|
||||
setCustomCss,
|
||||
setTopicNamingPrompt
|
||||
} = settingsSlice.actions
|
||||
|
||||
export default settingsSlice.reducer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user