diff --git a/config/config.yaml b/config/config.yaml index 11cdafee..2c7f2dae 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -590,19 +590,6 @@ extract: 请随机生成一段文本,要求内容与 %s 等相关,字数在 [50-200] 之间,并且尽量包含一些与这些标签相关的专业术语或典型元素,使文本更具针对性和相关性。 with_no_tag: | 请随机生成一段文本,内容请自由发挥,字数在 [50-200] 之间。 -# Agent 配置 -agent: - enabled: true - default_max_iterations: 5 - default_temperature: 0.7 - reflection_enabled: false - default_tools: - - knowledge_search - - multi_kb_search - - list_knowledge_bases - - get_related_chunks - - query_knowledge_graph - - get_document_info # WebSearch 配置 web_search: diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index f1b24d86..28ecdca8 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -79,7 +79,7 @@ services: - WeKnora-network-dev docreader: - image: wechatopenai/weknora-docreader:latest + image: wechatopenai/weknora-docreader:main container_name: WeKnora-docreader-dev ports: - "${DOCREADER_PORT:-50051}:50051" diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.ts index c5883559..b610c07a 100644 --- a/frontend/src/api/system/index.ts +++ b/frontend/src/api/system/index.ts @@ -32,7 +32,8 @@ export interface AgentConfig { thinking_model_id: string rerank_model_id: string knowledge_bases?: string[] - system_prompt?: string // System prompt template with placeholders (optional) + system_prompt_web_enabled?: string // Custom system prompt when web search is enabled + system_prompt_web_disabled?: string // Custom system prompt when web search is disabled use_custom_system_prompt?: boolean available_tools?: ToolDefinition[] // GET 响应中包含,POST/PUT 不需要 available_placeholders?: PlaceholderDefinition[] // GET 响应中包含,POST/PUT 不需要 @@ -42,7 +43,7 @@ export interface ConversationConfig { prompt: string context_template: string temperature: number - max_tokens: number + max_completion_tokens: number use_custom_system_prompt?: boolean use_custom_context_template?: boolean max_rounds: number diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 409726e2..f7913e47 100644 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -1343,7 +1343,10 @@ export default { hintSuffix: 'will show available placeholders automatically', custom: 'Custom Prompt', disabledHint: 'Currently using the default prompt. Enable custom to apply the content below.', - placeholder: 'Enter the system prompt, or leave blank to use the default...' + placeholder: 'Enter the system prompt, or leave blank to use the default...', + tabHint: 'Configure separate prompts for sessions with web search on or off.', + tabWebOn: 'Web search enabled', + tabWebOff: 'Web search disabled' }, reset: { header: 'Reset to Default Prompt', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 16a4a089..4cb6eee8 100644 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -1207,7 +1207,10 @@ export default { hintSuffix: 'откроется список доступных подстановок', custom: 'Пользовательский промпт', disabledHint: 'Сейчас используется промпт по умолчанию. Включите пользовательский, чтобы применить содержимое ниже.', - placeholder: 'Введите системный промпт или оставьте пустым для значения по умолчанию...' + placeholder: 'Введите системный промпт или оставьте пустым для значения по умолчанию...', + tabHint: 'Настройте разные промпты для режимов с включённым и отключённым веб-поиском.', + tabWebOn: 'Веб-поиск включён', + tabWebOff: 'Веб-поиск отключён' }, reset: { header: 'Сбросить к промпту по умолчанию', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 64748267..0637ee7c 100644 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -1348,6 +1348,9 @@ export default { custom: "自定义 Prompt", disabledHint: "当前使用系统默认 Prompt,开启自定义后才会应用下方内容。", placeholder: "请输入系统 Prompt,或留空使用默认 Prompt...", + tabHint: "根据是否启用网络搜索分别配置系统 Prompt。", + tabWebOn: "网络搜索已启用", + tabWebOff: "网络搜索未启用", }, reset: { header: "恢复默认 Prompt", diff --git a/frontend/src/stores/settings.ts b/frontend/src/stores/settings.ts index 698bf957..031e136c 100644 --- a/frontend/src/stores/settings.ts +++ b/frontend/src/stores/settings.ts @@ -20,6 +20,9 @@ interface AgentConfig { thinkingModelId: string; rerankModelId: string; allowedTools: string[]; + system_prompt_web_enabled?: string; + system_prompt_web_disabled?: string; + use_custom_system_prompt?: boolean; } // 单个模型项接口 @@ -60,7 +63,10 @@ const defaultSettings: Settings = { temperature: 0.7, thinkingModelId: "", rerankModelId: "", - allowedTools: ["knowledge_search", "multi_kb_search", "list_knowledge_bases"] + allowedTools: ["knowledge_search", "multi_kb_search", "list_knowledge_bases"], + system_prompt_web_enabled: "", + system_prompt_web_disabled: "", + use_custom_system_prompt: false }, selectedKnowledgeBases: [], // 默认为空数组 modelConfig: { diff --git a/frontend/src/utils/tool-icons.ts b/frontend/src/utils/tool-icons.ts index 3fffddf2..8dd258f4 100644 --- a/frontend/src/utils/tool-icons.ts +++ b/frontend/src/utils/tool-icons.ts @@ -8,8 +8,8 @@ export const toolIcons: Record = { multi_kb_search: '🔍', knowledge_search: '📚', get_chunk_detail: '📄', - get_related_chunks: '🔗', list_knowledge_bases: '📂', + list_knowledge_chunks: '🧩', get_document_info: 'ℹ️', query_knowledge_graph: '🕸️', think: '💭', @@ -43,11 +43,11 @@ export function getToolDisplayName(toolName: string): string { multi_kb_search: '跨库搜索', knowledge_search: '知识库搜索', get_chunk_detail: '获取片段详情', - get_related_chunks: '获取相关片段', + list_knowledge_chunks: '查看知识分块', list_knowledge_bases: '列出知识库', get_document_info: '获取文档信息', query_knowledge_graph: '查询知识图谱', - think: '思考', + think: '深度思考', todo_write: '制定计划', }; return displayNames[toolName] || toolName; diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index f81cceae..1ecc9aaf 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -213,7 +213,7 @@ const TOOL_NAME_I18N: Record = { web_search: '网络搜索', web_fetch: '网页抓取', get_document_info: '获取文档信息', - get_related_chunks: '查找相关片段', + list_knowledge_chunks: '查看知识分块', get_related_documents: '查找相关文档', get_document_content: '获取文档内容', todo_write: '计划管理', @@ -511,7 +511,7 @@ const intermediateStepsSummary = computed(() => { if (toolCalls.length > 0) { const toolNames = toolCalls.map(name => { if (name === 'get_document_info') return '获取文档'; - if (name === 'get_related_chunks') return '获取相关片段'; + if (name === 'list_knowledge_chunks') return '查看知识分块'; return name; }); if (toolNames.length === 1) { @@ -1080,9 +1080,10 @@ const getToolSummary = (event: any): string => { if (toolData?.title) { return `获取文档:${toolData.title}`; } - } else if (toolName === 'get_related_chunks') { - if (toolData?.count !== undefined) { - return `找到 ${toolData.count} 个相关片段`; + } else if (toolName === 'list_knowledge_chunks') { + if (toolData?.fetched_chunks !== undefined) { + const title = toolData?.knowledge_title || toolData?.knowledge_id || '文档'; + return `查看 ${title} 的 ${toolData.fetched_chunks}/${toolData.total_chunks ?? '?'} 个分块`; } } else if (toolName === 'todo_write') { // Extract steps from tool data @@ -1183,7 +1184,7 @@ const getToolIcon = (toolName: string): string => { return knowledgeIcon; } else if (toolName === 'web_search') { return webSearchGlobeGreenIcon; - } else if (toolName === 'get_document_info' || toolName === 'get_related_chunks') { + } else if (toolName === 'get_document_info' || toolName === 'list_knowledge_chunks') { return documentIcon; } else if (toolName === 'todo_write') { return fileAddIcon; diff --git a/frontend/src/views/chat/components/tool-results/DocumentInfo.vue b/frontend/src/views/chat/components/tool-results/DocumentInfo.vue index db296ec1..6d707caf 100644 --- a/frontend/src/views/chat/components/tool-results/DocumentInfo.vue +++ b/frontend/src/views/chat/components/tool-results/DocumentInfo.vue @@ -16,14 +16,6 @@ -
-
{{ $t('chat.statusDescription') }}
-
-
✓ {{ $t('chat.statusIndexed') }}
-
✓ {{ $t('chat.statusSearchable') }}
-
✓ {{ $t('chat.statusChunkDetailAvailable') }}
-
-
diff --git a/frontend/src/views/settings/AgentSettings.vue b/frontend/src/views/settings/AgentSettings.vue index c83ce698..8e0e1a53 100644 --- a/frontend/src/views/settings/AgentSettings.vue +++ b/frontend/src/views/settings/AgentSettings.vue @@ -151,22 +151,51 @@ {{ $t('common.resetToDefault') }} +

+ {{ $t('agentSettings.systemPrompt.tabHint') }} +

{{ $t('agentSettings.systemPrompt.disabledHint') }}

-
- +
+ + +
+ +
+
+ +
+ +
+
+
@@ -580,11 +609,11 @@
@@ -596,6 +625,7 @@