Skip to content
Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DeepChat",
"version": "0.3.3",
"version": "0.3.4",
"description": "DeepChat,一个简单易用的AI客户端",
"main": "./out/main/index.js",
"author": "ThinkInAIXYZ",
Expand Down
28 changes: 26 additions & 2 deletions src/main/presenter/configPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import { defaultShortcutKey, ShortcutKeySetting } from './shortcutKeySettings'
import { ModelConfigHelper } from './modelConfig'
import { KnowledgeConfHelper } from './knowledgeConfHelper'

// 默认系统提示词常量
const DEFAULT_SYSTEM_PROMPT = `You are DeepChat, a highly capable AI assistant. Your goal is to fully complete the user’s requested task before handing the conversation back to them. Keep working autonomously until the task is fully resolved.
Be thorough in gathering information. Before replying, make sure you have all the details necessary to provide a complete solution. Use additional tools or ask clarifying questions when needed, but if you can find the answer on your own, avoid asking the user for help.
When using tools, briefly describe your intended steps first—for example, which tool you’ll use and for what purpose.
Adhere to this in all languages.Always respond in the same language as the user's query.`

// 定义应用设置的接口
interface IAppSettings {
// 在这里定义你的配置项,例如:
Expand Down Expand Up @@ -147,7 +153,7 @@ export class ConfigPresenter implements IConfigPresenter {
const oldVersion = this.store.get('appVersion')
this.store.set('appVersion', this.currentAppVersion)
// 迁移数据
this.migrateModelData(oldVersion)
this.migrateConfigData(oldVersion)
this.mcpConfHelper.onUpgrade(oldVersion)
}

Expand Down Expand Up @@ -184,7 +190,7 @@ export class ConfigPresenter implements IConfigPresenter {
return this.providersModelStores.get(providerId)!
}

private migrateModelData(oldVersion: string | undefined): void {
private migrateConfigData(oldVersion: string | undefined): void {
// 0.2.4 版本之前,minimax 的 baseUrl 是错误的,需要修正
if (oldVersion && compare(oldVersion, '0.2.4', '<')) {
const providers = this.getProviders()
Expand Down Expand Up @@ -267,6 +273,14 @@ export class ConfigPresenter implements IConfigPresenter {
this.setProviders(filteredProviders)
}
}

// 0.3.4 版本之前,如果默认系统提示词为空,则设置为内置的默认提示词
if (oldVersion && compare(oldVersion, '0.3.4', '<')) {
const currentPrompt = this.getSetting<string>('default_system_prompt')
if (!currentPrompt || currentPrompt.trim() === '') {
this.setSetting('default_system_prompt', DEFAULT_SYSTEM_PROMPT)
}
}
Comment on lines +278 to +283
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Default prompt set only on upgrade; fresh installs still get empty default.

New users won’t receive DEFAULT_SYSTEM_PROMPT because defaults set default_system_prompt to ''. Either set the default in ElectronStore defaults or ensure migrate runs for first-run.

Apply this change to store defaults (shown as plain TS since it’s outside the changed hunk):

// in constructor defaults:
default_system_prompt: DEFAULT_SYSTEM_PROMPT,
🤖 Prompt for AI Agents
In src/main/presenter/configPresenter/index.ts around lines 278 to 283, the
migration only sets DEFAULT_SYSTEM_PROMPT for users upgrading from <0.3.4,
leaving fresh installs with an empty default; update the ElectronStore
constructor defaults to include default_system_prompt: DEFAULT_SYSTEM_PROMPT (or
alternatively ensure the migration runs on first-run by invoking it when no
prior version exists) so new installs receive the proper default prompt.

}

getSetting<T>(key: string): T | undefined {
Expand Down Expand Up @@ -1190,6 +1204,16 @@ export class ConfigPresenter implements IConfigPresenter {
this.setSetting('default_system_prompt', prompt)
}

// 重置为默认系统提示词
async resetToDefaultPrompt(): Promise<void> {
this.setSetting('default_system_prompt', DEFAULT_SYSTEM_PROMPT)
}

// 清空系统提示词
async clearSystemPrompt(): Promise<void> {
this.setSetting('default_system_prompt', '')
}

// 获取默认快捷键
getDefaultShortcutKey(): ShortcutKeySetting {
return {
Expand Down
Loading