diff --git a/src/main/presenter/configPresenter/index.ts b/src/main/presenter/configPresenter/index.ts index 69fdf1f610caa070258cfccf17dd81d763847388..455ef2d091f826a6d03a1d75033eceaaf99aae00 100644 --- a/src/main/presenter/configPresenter/index.ts +++ b/src/main/presenter/configPresenter/index.ts @@ -57,6 +57,7 @@ interface IAppSettings { customSearchEngines?: string // Custom search engines JSON string soundEnabled?: boolean // Whether sound effects are enabled copyWithCotEnabled?: boolean + useBuiltInTools?: boolean loggingEnabled?: boolean // Whether logging is enabled floatingButtonEnabled?: boolean // Whether floating button is enabled default_system_prompt?: string // Default system prompt @@ -122,6 +123,7 @@ export class ConfigPresenter implements IConfigPresenter { lastSyncTime: 0, soundEnabled: false, copyWithCotEnabled: true, + useBuiltInTools: false, loggingEnabled: false, floatingButtonEnabled: false, default_system_prompt: '', @@ -978,6 +980,15 @@ export class ConfigPresenter implements IConfigPresenter { eventBus.sendToRenderer(CONFIG_EVENTS.COPY_WITH_COT_CHANGED, SendTarget.ALL_WINDOWS, enabled) } + getUseBuiltInTools(): boolean { + const value = this.getSetting('useBuiltInTools') + return value === undefined || value === null ? false : value + } + + setUseBuiltInTools(enabled: boolean): void { + this.setSetting('useBuiltInTools', enabled) + } + // Get floating button switch status getFloatingButtonEnabled(): boolean { const value = this.getSetting('floatingButtonEnabled') ?? false @@ -1252,10 +1263,9 @@ export class ConfigPresenter implements IConfigPresenter { } private async getBuildInSystemPrompt(): Promise { - //获取内置的系统提示词 - return await (async () => { - return SYSTEM_PROMPT('', '', this.getLanguage(), '') - })() + // 获取内置的系统提示词 + const useBuiltInTools = this.getUseBuiltInTools() + return await SYSTEM_PROMPT('', '', this.getLanguage(), '', useBuiltInTools) } async getSystemPrompts(): Promise { diff --git a/src/main/presenter/promptPresenter/sections/objective.ts b/src/main/presenter/promptPresenter/sections/objective.ts index 36e3eab92d645ac57d117024a130c98e3b1cdb00..0ef98a82e605fe40d7e4f4c89d883479b5fbf22d 100644 --- a/src/main/presenter/promptPresenter/sections/objective.ts +++ b/src/main/presenter/promptPresenter/sections/objective.ts @@ -3,6 +3,7 @@ export function getObjectiveSection(): string { OBJECTIVE +Please answer the questions using your own knowledge first. Do not call on tools unless it is necessary. You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically. 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order. diff --git a/src/main/presenter/promptPresenter/sections/tool-descriptions.ts b/src/main/presenter/promptPresenter/sections/tool-descriptions.ts index 0668aa87652c18dc4175a88b5824882ce2a47ce4..c7bcfdb3062ef257ba093cc4bf85979d221db45e 100644 --- a/src/main/presenter/promptPresenter/sections/tool-descriptions.ts +++ b/src/main/presenter/promptPresenter/sections/tool-descriptions.ts @@ -1,7 +1,7 @@ export function getToolDescriptionsSection(): string { - return `## Tool Descriptions + return `# Tool Descriptions -### read_file +## read_file Description: Requests to read the content of a file at a specified path. Use this tool when you need to inspect an existing file whose content you are unaware of, such as analyzing code, viewing a text file, or extracting information from a configuration file. The output content will have line numbers prefixed to each line (e.g., "1 | const x = 1"), making it easier to reference specific lines when creating diffs or discussing code. @@ -22,7 +22,7 @@ Example: Request to read the frontend-config.json file -### write_file +## write_file Description: Requests to write the complete content to a file at a specified path. If the file already exists, it will be overwritten with the provided content. If the file does not exist, a new file will be created. This tool automatically creates all necessary directories required to write the file. Parameters: @@ -64,7 +64,7 @@ Example: Request to write to frontend-config.json -### list_files +## list_files Description: Requests to list the names of files and subdirectories in a specified directory. Use this tool when you need to understand the directory structure or confirm the existence of files. By default, it only lists the current level, recursion can be enabled if necessary. @@ -87,7 +87,7 @@ Example: Request to list the src/main directory -### execute_command +## execute_command Description: Requests the execution of a command line instruction and returns the standard output and standard error. Use this tool only when needing to run commands related to the system itself; it cannot be used for network requests or accessing external websites. That is, use it only when there is a clear need, and carefully evaluate the potential side effects of the command. You must tailor the command to the user's system and clearly explain its function. For command chaining, use the appropriate chaining syntax for the user's shell. By default, it runs in the current working directory; other directories or shells can be specified as needed. diff --git a/src/main/presenter/promptPresenter/sections/tool-use-guidelines.ts b/src/main/presenter/promptPresenter/sections/tool-use-guidelines.ts index 3e18fa02b03ba8f7b07bc6804c6942f76bb123fc..e9af01b4b2fe5b6b81d32558a8c2f81b63d84dd6 100644 --- a/src/main/presenter/promptPresenter/sections/tool-use-guidelines.ts +++ b/src/main/presenter/promptPresenter/sections/tool-use-guidelines.ts @@ -1,5 +1,5 @@ export function getToolUseGuidelinesSection(): string { - return `## Tool Use Guidelines + return `# Tool Use Guidelines 1. Analyze user intent, determine whether to call the tool based on its description, and select the most matching tool or tools. 2. Assess what information you already have ,and proactively and clearly inquire about missing necessary parameters to ensure that the format of the call request fully complies with the tool interface specifications. diff --git a/src/main/presenter/promptPresenter/sections/tool-use.ts b/src/main/presenter/promptPresenter/sections/tool-use.ts index a3f43a2b4a9ff54f60aed3bdd8c5352a10638596..2fb66849304e59fb03bd5c63f7a48e662b07a9cf 100644 --- a/src/main/presenter/promptPresenter/sections/tool-use.ts +++ b/src/main/presenter/promptPresenter/sections/tool-use.ts @@ -2,14 +2,11 @@ export function getSharedToolUseSection(): string { return `==== # TOOL USE -- Tool Use Formatting -- Tool Descriptions -- Tool Use Guidelines -Tools should be called only when necessary, only to solve direct problems, only system operations, command line execution related, other problems priority to use knowledge base or other methods to solve. +First, try to answer directly using your knowledge. Unless it is confirmed that reliance on tools is necessary, only to solve direct problems、 system operations、 command line execution related, other problems priority to use knowledge base or other methods to solve. You have access to a set of tools that are executed upon the user's approval, you can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use. -## Tool Use Formatting +# Tool Use Formatting Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: diff --git a/src/main/presenter/promptPresenter/system.ts b/src/main/presenter/promptPresenter/system.ts index 25e97d4179698a3490f98f7c30ede9ebc4a54a69..6ad2091b3c679b76927d3e51c4ab263a770c161d 100644 --- a/src/main/presenter/promptPresenter/system.ts +++ b/src/main/presenter/promptPresenter/system.ts @@ -28,26 +28,39 @@ async function generatePrompt( cwd?: string, globalCustomInstructions?: string, language?: string, - IgnoreInstructions?: string + IgnoreInstructions?: string, + useBuiltInTools?: boolean ): Promise { - const basePrompt = ` - - ${markdownFormattingSection()} + const promptSections = [markdownFormattingSection()] - ${getSharedToolUseSection()} + if (useBuiltInTools) { + promptSections.push(`${getSharedToolUseSection()} ${getToolDescriptionsSection()} - ${getToolUseGuidelinesSection()} - - ${getSystemInfoSection()} + ${getToolUseGuidelinesSection()}`) + } - ${getObjectiveSection()} + promptSections.push(getSystemInfoSection(), getObjectiveSection()) - ${await addCustomInstructions('', globalCustomInstructions || '', cwd || '', '', { + const customInstructions = await addCustomInstructions( + '', + globalCustomInstructions || '', + cwd || '', + '', + { language: language ?? formatLanguage(presenter.configPresenter.getLanguage()), IgnoreInstructions - })} + } + ) + + promptSections.push(customInstructions) + + const basePrompt = ` + + ${promptSections.join(` + + `)} ` return basePrompt @@ -57,7 +70,14 @@ export const SYSTEM_PROMPT = async ( cwd?: string, globalCustomInstructions?: string, language?: string, - IgnoreInstructions?: string + IgnoreInstructions?: string, + useBuiltInTools?: boolean ): Promise => { - return generatePrompt(cwd, globalCustomInstructions, language, IgnoreInstructions) + return generatePrompt( + cwd, + globalCustomInstructions, + language, + IgnoreInstructions, + useBuiltInTools + ) } diff --git a/src/renderer/src/components/settings/CommonSettings.vue b/src/renderer/src/components/settings/CommonSettings.vue index 20d09f56b9f1ca37c90c7e75d320d24a61a9a826..65cdd264bba1f31f23f1a8bc418e49903d75aa73 100644 --- a/src/renderer/src/components/settings/CommonSettings.vue +++ b/src/renderer/src/components/settings/CommonSettings.vue @@ -219,6 +219,21 @@ + +
+ + + {{ t('settings.common.useBuiltInTools') }} + +
+ +
+
+
@@ -796,6 +811,21 @@ const handleSoundChange = (value: boolean) => { soundStore.setSoundEnabled(value) } +// 内置工具开关相关 +const builtInToolsEnabled = computed({ + get: () => { + return settingsStore.useBuiltInTools + }, + set: (value: boolean) => { + settingsStore.setUseBuiltInTools(value) + } +}) + +// 处理内置工具开关状态变更 +const handleBuiltInToolsChange = (value: boolean) => { + settingsStore.setUseBuiltInTools(value) +} + const copyWithCotEnabled = computed({ get: () => { return settingsStore.copyWithCotEnabled diff --git a/src/renderer/src/i18n/en-US/settings.json b/src/renderer/src/i18n/en-US/settings.json index c5166384c045cf1ba5414e67187638a4e27ef4f0..4a11c5e7bedcbdcec3d4982711533f08d893429e 100644 --- a/src/renderer/src/i18n/en-US/settings.json +++ b/src/renderer/src/i18n/en-US/settings.json @@ -39,6 +39,7 @@ "contentProtectionRestartNotice": "Changing this setting will restart the application. Do you want to continue?", "soundEnabled": "Enable Sound Effects", "copyWithCotEnabled": "Copy COT Details", + "useBuiltInTools": "Use Built-in Tools", "loggingEnabled": "Enable Logging", "loggingDialogTitle": "Confirm Logging Setting Change", "loggingEnableDesc": "Enabling logging will help us diagnose issues and improve the application. Log files may contain sensitive information.", diff --git a/src/renderer/src/i18n/fa-IR/settings.json b/src/renderer/src/i18n/fa-IR/settings.json index e18d61e862fb948745e96de58feb29c0e0989c5b..066d353e574b6d0d1df2d32e6bf3e0b8441179c3 100644 --- a/src/renderer/src/i18n/fa-IR/settings.json +++ b/src/renderer/src/i18n/fa-IR/settings.json @@ -40,6 +40,7 @@ "contentProtectionRestartNotice": "تغییر این تنظیم برنامه را بازراه‌اندازی می‌کند. آیا می‌خواهید ادامه دهید؟", "soundEnabled": "روشن کردن جلوه‌های صوتی", "copyWithCotEnabled": "رونوشت دارای جزئیات COT", + "useBuiltInTools": "استفاده از ابزارهای داخلی", "loggingEnabled": "روشن کردن ثبت رخدادها", "loggingDialogTitle": "پذیرش تغییر تنظیم ثبت رخدادها", "loggingEnableDesc": "روشن کردن ثبت رخدادها به ما کمک می‌کند مشکلات را عیب‌یابی کرده و برنامه را بهبود دهیم. پرونده‌های رخدادها ممکن است دارای اطلاعات حساس باشند.", diff --git a/src/renderer/src/i18n/fr-FR/settings.json b/src/renderer/src/i18n/fr-FR/settings.json index 17c74adc9ddb19041882569d5ad3044e5103c7ce..966561a8834fabf1afb3154c1a9dd81be43a44e1 100644 --- a/src/renderer/src/i18n/fr-FR/settings.json +++ b/src/renderer/src/i18n/fr-FR/settings.json @@ -40,6 +40,7 @@ "contentProtectionRestartNotice": "La modification de ce paramètre redémarrera l'application. Voulez-vous continuer ?", "soundEnabled": "Activer le son", "copyWithCotEnabled": "Copier les infos COT", + "useBuiltInTools": "Utiliser les outils intégrés", "loggingEnabled": "Activer la journalisation", "loggingDialogTitle": "Confirmer le changement de paramètre de journalisation", "loggingEnableDesc": "L'activation de la journalisation nous aidera à diagnostiquer les problèmes et à améliorer l'application. Les fichiers journaux peuvent contenir des informations sensibles.", diff --git a/src/renderer/src/i18n/ja-JP/settings.json b/src/renderer/src/i18n/ja-JP/settings.json index 9529510044b600d688074218b58ed5d18a471119..892475f686a4fc362a468fb2a0aa8fef638cc668 100644 --- a/src/renderer/src/i18n/ja-JP/settings.json +++ b/src/renderer/src/i18n/ja-JP/settings.json @@ -25,6 +25,7 @@ "contentProtectionRestartNotice": "この設定を変更するとアプリケーションが再起動します。続行しますか?", "soundEnabled": "サウンドを有効にする", "copyWithCotEnabled": "COT情報をコピー", + "useBuiltInTools": "内蔵ツールを使用", "loggingEnabled": "ログを有効にする", "loggingDialogTitle": "ログ設定の変更確認", "loggingEnableDesc": "ログを有効にすると、問題の診断とアプリケーションの改善に役立ちます。ログファイルには機密情報が含まれる可能性があります。", diff --git a/src/renderer/src/i18n/ko-KR/settings.json b/src/renderer/src/i18n/ko-KR/settings.json index 6868c14f430ac425ea596d84221b8cc8975c6127..fdcc7ed5676b13d669489e51a7fee538390fd589 100644 --- a/src/renderer/src/i18n/ko-KR/settings.json +++ b/src/renderer/src/i18n/ko-KR/settings.json @@ -40,6 +40,7 @@ "contentProtectionRestartNotice": "이 설정을 변경하면 프로그램이 재시작됩니다. 계속하시겠습니까?", "soundEnabled": "소리 활성화", "copyWithCotEnabled": "COT 정보 복사", + "useBuiltInTools": "내장 도구 사용", "loggingEnabled": "로그 활성화", "loggingDialogTitle": "로그 설정 변경 확인", "loggingEnableDesc": "로그를 활성화하면 문제 진단 및 애플리케이션 개선에 도움이 됩니다. 로그 파일에는 민감한 정보가 포함될 수 있습니다.", diff --git a/src/renderer/src/i18n/ru-RU/settings.json b/src/renderer/src/i18n/ru-RU/settings.json index 5834a30159eb36cdd136a0a6e1452d9893596eed..3e748270cf23036f574459e1d91113cd5433ada7 100644 --- a/src/renderer/src/i18n/ru-RU/settings.json +++ b/src/renderer/src/i18n/ru-RU/settings.json @@ -38,6 +38,7 @@ "theme": "Тема", "soundEnabled": "Звуковые уведомления", "copyWithCotEnabled": "Скопировать информацию COT", + "useBuiltInTools": "Использовать встроенные инструменты", "loggingEnabled": "Включить логирование", "loggingDialogTitle": "Подтверждение изменения настроек логирования", "loggingEnableDesc": "Включение логирования поможет нам диагностировать проблемы и улучшить приложение. Файлы логов могут содержать конфиденциальную информацию.", diff --git a/src/renderer/src/i18n/zh-CN/settings.json b/src/renderer/src/i18n/zh-CN/settings.json index 96d513a35243bbc9a2e06be4e624fce442c0327b..316258c8e4b940ca1df3218586f7d2a7a85a75b9 100644 --- a/src/renderer/src/i18n/zh-CN/settings.json +++ b/src/renderer/src/i18n/zh-CN/settings.json @@ -44,6 +44,7 @@ "contentProtectionRestartNotice": "切换此设置将导致程序重启,请确认是否继续?", "soundEnabled": "启用音效", "copyWithCotEnabled": "复制COT信息", + "useBuiltInTools": "启用内置工具", "loggingEnabled": "启用日志", "loggingDialogTitle": "确认日志设置更改", "loggingEnableDesc": "启用日志将帮助我们诊断问题并改进应用程序。日志文件可能包含敏感信息。", diff --git a/src/renderer/src/i18n/zh-HK/settings.json b/src/renderer/src/i18n/zh-HK/settings.json index d69a2b739afbaa7296be64d9dffb426d6ed3ccb8..7d18c338489937c6db7ca3ab0aafd5a792ceaeaf 100644 --- a/src/renderer/src/i18n/zh-HK/settings.json +++ b/src/renderer/src/i18n/zh-HK/settings.json @@ -40,6 +40,7 @@ "contentProtectionRestartNotice": "切換此設置將導致程序重啟,請確認是否繼續?", "soundEnabled": "啟用音效", "copyWithCotEnabled": "複製COT資訊", + "useBuiltInTools": "啟用內建工具", "loggingEnabled": "啟用日誌", "loggingDialogTitle": "確認日誌設定變更", "loggingEnableDesc": "啟用日誌將幫助我們診斷問題並改進應用程式。日誌檔案可能包含敏感資訊。", diff --git a/src/renderer/src/i18n/zh-TW/settings.json b/src/renderer/src/i18n/zh-TW/settings.json index 2912db1f8ed0f5dc2bc67ec2f0b24dc4225aa1e9..68b60d85d14e5101d9f02a198c1ab4b3fa0cbc75 100644 --- a/src/renderer/src/i18n/zh-TW/settings.json +++ b/src/renderer/src/i18n/zh-TW/settings.json @@ -40,6 +40,7 @@ "contentProtectionRestartNotice": "切換此設定將會重新啟動應用程式,請問您是否要繼續?", "soundEnabled": "啟用音效", "copyWithCotEnabled": "複製COT資訊", + "useBuiltInTools": "啟用內建工具", "loggingEnabled": "啟用日誌", "loggingDialogTitle": "確認日誌設定變更", "loggingEnableDesc": "啟用日誌將幫助我們診斷問題並改進應用程式。日誌檔案可能包含敏感資訊。", diff --git a/src/renderer/src/stores/settings.ts b/src/renderer/src/stores/settings.ts index 015659f514496c50113b25a4ba8157af1b840221..d9ad8fe2c5df740143133971e9b3ce48ba40c8e8 100644 --- a/src/renderer/src/stores/settings.ts +++ b/src/renderer/src/stores/settings.ts @@ -33,6 +33,7 @@ export const useSettingsStore = defineStore('settings', () => { const searchPreviewEnabled = ref(true) // 搜索预览是否启用,默认启用 const contentProtectionEnabled = ref(true) // 投屏保护是否启用,默认启用 const copyWithCotEnabled = ref(true) + const useBuiltInTools = ref(false) // 内置工具是否启用,默认不启用 const notificationsEnabled = ref(true) // 系统通知是否启用,默认启用 const fontSizeLevel = ref(DEFAULT_FONT_SIZE_LEVEL) // 字体大小级别,默认为 1 // Ollama 相关状态 @@ -296,6 +297,7 @@ export const useSettingsStore = defineStore('settings', () => { try { loggingEnabled.value = await configP.getLoggingEnabled() copyWithCotEnabled.value = await configP.getCopyWithCotEnabled() + useBuiltInTools.value = await configP.getUseBuiltInTools() // 获取全部 provider providers.value = await configP.getProviders() @@ -1474,6 +1476,11 @@ export const useSettingsStore = defineStore('settings', () => { await configP.setCopyWithCotEnabled(enabled) } + const setUseBuiltInTools = async (enabled: boolean) => { + useBuiltInTools.value = Boolean(enabled) + await configP.setUseBuiltInTools(enabled) + } + const getCopyWithCotEnabled = async (): Promise => { return await configP.getCopyWithCotEnabled() } @@ -1701,6 +1708,7 @@ export const useSettingsStore = defineStore('settings', () => { searchPreviewEnabled, contentProtectionEnabled, copyWithCotEnabled, + useBuiltInTools, notificationsEnabled, // 暴露系统通知状态 loggingEnabled, updateProvider, @@ -1750,6 +1758,7 @@ export const useSettingsStore = defineStore('settings', () => { setLoggingEnabled, getCopyWithCotEnabled, setCopyWithCotEnabled, + setUseBuiltInTools, setupCopyWithCotEnabledListener, testSearchEngine, refreshSearchEngines, diff --git a/src/shared/types/presenters/legacy.presenters.d.ts b/src/shared/types/presenters/legacy.presenters.d.ts index 78d12334e2616c5fec71072eb80527be7a08f168..1e0310f71ab8aa132bbb259ed303c7a8f6dd71ef 100644 --- a/src/shared/types/presenters/legacy.presenters.d.ts +++ b/src/shared/types/presenters/legacy.presenters.d.ts @@ -389,6 +389,9 @@ export interface IConfigPresenter { // Chain of Thought copy settings getCopyWithCotEnabled(): boolean setCopyWithCotEnabled(enabled: boolean): void + // Built-in tools settings + getUseBuiltInTools(): boolean + setUseBuiltInTools(enabled: boolean): void // Floating button settings getFloatingButtonEnabled(): boolean setFloatingButtonEnabled(enabled: boolean): void