diff --git a/config/config.yaml b/config/config.yaml index 693a7064..7cdb6e31 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -23,7 +23,7 @@ conversation: - 使用礼貌、专业的语气 ## 用户的问题是: - {{.Query}} + {{query}} enable_rewrite: true enable_query_expansion: true enable_rerank: true @@ -82,15 +82,10 @@ conversation: 改写后: 国外手机号是否可以注册微信账号 rewrite_prompt_user: | ## 历史对话背景 - {{range .Conversation}} - ------BEGIN------ - 用户的问题是:{{.Query}} - 助手的回答是:{{.Answer}} - ------END------ - {{end}} + {{conversation}} ## 需要改写的用户问题 - {{.Query}} + {{query}} ## 改写后的问题 keywords_extraction_prompt: | @@ -134,7 +129,7 @@ conversation: Output: iPhone, 连接WiFi, 使用iPhone连接WiFi # Real Data - USER: {{.Query}} + USER: {{query}} keywords_extraction_prompt_user: | Output: @@ -483,11 +478,11 @@ conversation: generate_questions_prompt: | 你是一个专业的问题生成助手。你的任务是根据给定的【主要内容】生成用户可能会问的相关问题。 - {{.Context}} + {{context}} ## 主要内容(请基于此内容生成问题) - 文档名称:{{.DocName}} + 文档名称:{{doc_name}} 文档内容: - {{.Content}} + {{content}} ## 核心要求 - 生成的问题必须与【主要内容】直接相关 @@ -496,7 +491,7 @@ conversation: - 问题应该是用户在实际场景中可能会提出的自然问题 - 问题应该多样化,覆盖内容的不同方面 - 每个问题应该简洁明了,长度控制在30字以内 - - 生成的问题数量为 {{.QuestionCount}} 个 + - 生成的问题数量为 {{question_count}} 个 ## 问题类型建议 - 定义类:什么是...?...是什么? diff --git a/config/prompt_templates/fallback.yaml b/config/prompt_templates/fallback.yaml index e1902d11..5f0e722a 100644 --- a/config/prompt_templates/fallback.yaml +++ b/config/prompt_templates/fallback.yaml @@ -44,4 +44,4 @@ templates: 2. 如果问题涉及特定领域或需要最新信息,建议用户查阅官方资料 3. 保持回答的准确性和客观性 - 用户问题:{{.Query}} + 用户问题:{{query}} diff --git a/config/prompt_templates/rewrite_user.yaml b/config/prompt_templates/rewrite_user.yaml index 54e0f994..8605c1af 100644 --- a/config/prompt_templates/rewrite_user.yaml +++ b/config/prompt_templates/rewrite_user.yaml @@ -5,15 +5,10 @@ templates: description: "标准的改写用户提示词格式" content: | ## 历史对话背景 - {{range .Conversation}} - ------BEGIN------ - 用户的问题是:{{.Query}} - 助手的回答是:{{.Answer}} - ------END------ - {{end}} + {{conversation}} ## 需要改写的用户问题 - {{.Query}} + {{query}} ## 改写后的问题 @@ -24,14 +19,10 @@ templates: ## 历史对话背景 以下是用户与助手的对话历史,请仔细阅读以理解上下文: - {{range .Conversation}} - 【用户】{{.Query}} - 【助手】{{.Answer}} - - {{end}} + {{conversation}} ## 当前用户问题 - {{.Query}} + {{query}} ## 任务要求 请根据以上对话历史,将当前问题改写为一个独立、完整、可以脱离上下文理解的问题。 diff --git a/frontend/src/api/agent/index.ts b/frontend/src/api/agent/index.ts index 43987153..927daa63 100644 --- a/frontend/src/api/agent/index.ts +++ b/frontend/src/api/agent/index.ts @@ -1,12 +1,9 @@ import { get, post, put, del } from "../../utils/request"; -// 智能体类型 -export type CustomAgentType = 'normal' | 'agent' | 'custom'; - // 智能体配置 export interface CustomAgentConfig { // ===== 基础设置 ===== - agent_mode?: 'normal' | 'agent'; // 运行模式:normal=RAG模式, agent=ReAct Agent模式 + agent_mode?: 'quick-answer' | 'smart-reasoning'; // 运行模式:quick-answer=RAG模式, smart-reasoning=ReAct Agent模式 system_prompt?: string; // 系统提示词(普通模式,或Agent模式网络搜索关闭时) system_prompt_web_enabled?: string; // Agent模式网络搜索开启时的系统提示词 context_template?: string; // 上下文模板(普通模式) @@ -21,15 +18,14 @@ export interface CustomAgentConfig { max_iterations?: number; // 最大迭代次数 allowed_tools?: string[]; // 允许的工具 reflection_enabled?: boolean; // 是否启用反思 + // MCP服务选择模式:all=全部启用的MCP服务, selected=指定服务, none=不使用MCP + mcp_selection_mode?: 'all' | 'selected' | 'none'; + mcp_services?: string[]; // 选择的MCP服务ID列表 // ===== 知识库设置 ===== // 知识库选择模式:all=全部知识库, selected=指定知识库, none=不使用知识库 kb_selection_mode?: 'all' | 'selected' | 'none'; knowledge_bases?: string[]; - // 当没有配置知识库时,是否允许用户自由选择知识库 - // true (默认): 用户可以自由选择任意知识库 - // false: 禁用知识库选择功能 - allow_user_kb_selection?: boolean; // ===== 网络搜索设置 ===== web_search_enabled?: boolean; @@ -67,7 +63,6 @@ export interface CustomAgent { description?: string; avatar?: string; is_builtin: boolean; - type: CustomAgentType; tenant_id?: number; created_by?: string; config: CustomAgentConfig; @@ -80,7 +75,6 @@ export interface CreateAgentRequest { name: string; description?: string; avatar?: string; - type?: CustomAgentType; config?: CustomAgentConfig; } @@ -89,13 +83,27 @@ export interface UpdateAgentRequest { name: string; description?: string; avatar?: string; - type?: CustomAgentType; config?: CustomAgentConfig; } // 内置智能体 ID -export const BUILTIN_AGENT_NORMAL_ID = 'builtin-normal'; -export const BUILTIN_AGENT_AGENT_ID = 'builtin-agent'; +export const BUILTIN_QUICK_ANSWER_ID = 'builtin-quick-answer'; +export const BUILTIN_SMART_REASONING_ID = 'builtin-smart-reasoning'; + +// AgentMode 常量 +export const AGENT_MODE_QUICK_ANSWER = 'quick-answer'; +export const AGENT_MODE_SMART_REASONING = 'smart-reasoning'; + +// Deprecated: Use BUILTIN_QUICK_ANSWER_ID instead +export const BUILTIN_AGENT_NORMAL_ID = BUILTIN_QUICK_ANSWER_ID; +// Deprecated: Use BUILTIN_SMART_REASONING_ID instead +export const BUILTIN_AGENT_AGENT_ID = BUILTIN_SMART_REASONING_ID; + +// 所有内置智能体 ID 列表(便于扩展) +export const BUILTIN_AGENT_IDS = [ + BUILTIN_QUICK_ANSWER_ID, + BUILTIN_SMART_REASONING_ID, +] as const; // 获取智能体列表(包括内置智能体) export function listAgents() { @@ -122,7 +130,35 @@ export function deleteAgent(id: string) { return del<{ success: boolean }>(`/api/v1/agents/${id}`); } +// 复制智能体 +export function copyAgent(id: string) { + return post<{ data: CustomAgent }>(`/api/v1/agents/${id}/copy`); +} + // 判断是否为内置智能体 export function isBuiltinAgent(agentId: string): boolean { - return agentId === BUILTIN_AGENT_NORMAL_ID || agentId === BUILTIN_AGENT_AGENT_ID; + return (BUILTIN_AGENT_IDS as readonly string[]).includes(agentId); +} + +// 占位符定义 +export interface PlaceholderDefinition { + name: string; + label: string; + description: string; +} + +// 占位符响应 +export interface PlaceholdersResponse { + all: PlaceholderDefinition[]; + system_prompt: PlaceholderDefinition[]; + agent_system_prompt: PlaceholderDefinition[]; + context_template: PlaceholderDefinition[]; + rewrite_system_prompt: PlaceholderDefinition[]; + rewrite_prompt: PlaceholderDefinition[]; + fallback_prompt: PlaceholderDefinition[]; +} + +// 获取占位符定义 +export function getPlaceholders() { + return get<{ data: PlaceholdersResponse }>('/api/v1/agents/placeholders'); } diff --git a/frontend/src/components/AgentAvatar.vue b/frontend/src/components/AgentAvatar.vue index 570e5181..af91eb24 100644 --- a/frontend/src/components/AgentAvatar.vue +++ b/frontend/src/components/AgentAvatar.vue @@ -110,12 +110,17 @@ const letterStyle = computed(() => { overflow: hidden; &.agent-avatar-small { - width: 24px; - height: 24px; - border-radius: 6px; + width: 22px; + height: 22px; + border-radius: 5px; + box-shadow: none; .agent-avatar-letter { - font-size: 12px; + font-size: 11px; + } + + .agent-sparkles { + display: none; } } diff --git a/frontend/src/components/AgentSelector.vue b/frontend/src/components/AgentSelector.vue index e8d6701f..701da0ae 100644 --- a/frontend/src/components/AgentSelector.vue +++ b/frontend/src/components/AgentSelector.vue @@ -32,8 +32,8 @@ :class="{ 'selected': currentAgentId === agent.id }" @click="selectAgent(agent)" > -