Merge branch 'custom_agent'

This commit is contained in:
wizardchen
2025-12-29 17:01:23 +08:00
64 changed files with 10364 additions and 1965 deletions
+163
View File
@@ -0,0 +1,163 @@
import { get, post, put, del } from "../../utils/request";
// 智能体配置
export interface CustomAgentConfig {
// ===== 基础设置 =====
agent_mode?: 'quick-answer' | 'smart-reasoning'; // 运行模式:quick-answer=RAG模式, smart-reasoning=ReAct Agent模式
system_prompt?: string; // 统一系统提示词(使用 {{web_search_status}} 占位符动态控制行为)
context_template?: string; // 上下文模板(普通模式)
// ===== 模型设置 =====
model_id?: string;
rerank_model_id?: string; // ReRank 模型 ID
temperature?: number;
max_completion_tokens?: number; // 最大生成token数(普通模式)
// ===== Agent模式设置 =====
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[];
// ===== 网络搜索设置 =====
web_search_enabled?: boolean;
web_search_max_results?: number;
// ===== 多轮对话设置 =====
multi_turn_enabled?: boolean; // 是否启用多轮对话
history_turns?: number; // 保留历史轮数
// ===== 检索策略设置 =====
embedding_top_k?: number; // 向量召回TopK
keyword_threshold?: number; // 关键词召回阈值
vector_threshold?: number; // 向量召回阈值
rerank_top_k?: number; // 重排TopK
rerank_threshold?: number; // 重排阈值
// ===== 高级设置(主要用于普通模式)=====
enable_query_expansion?: boolean; // 是否启用查询扩展
enable_rewrite?: boolean; // 是否启用问题改写
rewrite_prompt_system?: string; // 改写系统提示词
rewrite_prompt_user?: string; // 改写用户提示词模板
fallback_strategy?: 'fixed' | 'model'; // 兜底策略
fallback_response?: string; // 固定兜底回复
fallback_prompt?: string; // 兜底提示词(模型生成时)
// ===== 已废弃字段(保留兼容)=====
welcome_message?: string;
suggested_prompts?: string[];
}
// 智能体
export interface CustomAgent {
id: string;
name: string;
description?: string;
avatar?: string;
is_builtin: boolean;
tenant_id?: number;
created_by?: string;
config: CustomAgentConfig;
created_at?: string;
updated_at?: string;
}
// 创建智能体请求
export interface CreateAgentRequest {
name: string;
description?: string;
avatar?: string;
config?: CustomAgentConfig;
}
// 更新智能体请求
export interface UpdateAgentRequest {
name: string;
description?: string;
avatar?: string;
config?: CustomAgentConfig;
}
// 内置智能体 ID
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() {
return get<{ data: CustomAgent[] }>('/api/v1/agents');
}
// 获取智能体详情
export function getAgentById(id: string) {
return get<{ data: CustomAgent }>(`/api/v1/agents/${id}`);
}
// 创建智能体
export function createAgent(data: CreateAgentRequest) {
return post<{ data: CustomAgent }>('/api/v1/agents', data);
}
// 更新智能体
export function updateAgent(id: string, data: UpdateAgentRequest) {
return put<{ data: CustomAgent }>(`/api/v1/agents/${id}`, data);
}
// 删除智能体
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 (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');
}
+5 -1
View File
@@ -28,7 +28,7 @@ export function useStream() {
let renderTimer: number | null = null
// 启动流式请求
const startStream = async (params: { session_id: any; query: any; knowledge_base_ids?: string[]; knowledge_ids?: string[]; agent_enabled?: boolean; web_search_enabled?: boolean; summary_model_id?: string; mcp_service_ids?: string[]; mentioned_items?: Array<{id: string; name: string; type: string; kb_type?: string}>; method: string; url: string }) => {
const startStream = async (params: { session_id: any; query: any; knowledge_base_ids?: string[]; knowledge_ids?: string[]; agent_enabled?: boolean; agent_id?: string; web_search_enabled?: boolean; summary_model_id?: string; mcp_service_ids?: string[]; mentioned_items?: Array<{id: string; name: string; type: string; kb_type?: string}>; method: string; url: string }) => {
// 重置状态
output.value = '';
error.value = null;
@@ -89,6 +89,10 @@ export function useStream() {
if (params.knowledge_ids !== undefined && params.knowledge_ids.length > 0) {
postBody.knowledge_ids = params.knowledge_ids;
}
// Include agent_id if provided (for custom agent configuration)
if (params.agent_id) {
postBody.agent_id = params.agent_id;
}
// Include web_search_enabled if provided
if (params.web_search_enabled !== undefined) {
postBody.web_search_enabled = params.web_search_enabled;
+22 -5
View File
@@ -29,9 +29,7 @@ export interface AgentConfig {
allowed_tools: string[]
temperature: number
knowledge_bases?: string[]
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
system_prompt?: string // Unified system prompt (uses {{web_search_status}} placeholder)
available_tools?: ToolDefinition[] // GET 响应中包含,POST/PUT 不需要
available_placeholders?: PlaceholderDefinition[] // GET 响应中包含,POST/PUT 不需要
}
@@ -41,8 +39,6 @@ export interface ConversationConfig {
context_template: string
temperature: number
max_completion_tokens: number
use_custom_system_prompt?: boolean
use_custom_context_template?: boolean
max_rounds: number
embedding_top_k: number
keyword_threshold: number
@@ -60,6 +56,23 @@ export interface ConversationConfig {
enable_query_expansion?: boolean
}
export interface PromptTemplate {
id: string
name: string
description: string
content: string
has_knowledge_base?: boolean
has_web_search?: boolean
}
export interface PromptTemplatesConfig {
system_prompt: PromptTemplate[]
context_template: PromptTemplate[]
rewrite_system: PromptTemplate[]
rewrite_user: PromptTemplate[]
fallback: PromptTemplate[]
}
export function getSystemInfo(): Promise<{ data: SystemInfo }> {
return get('/api/v1/system/info')
}
@@ -79,3 +92,7 @@ export function getConversationConfig(): Promise<{ data: ConversationConfig }> {
export function updateConversationConfig(config: ConversationConfig): Promise<{ data: ConversationConfig }> {
return put('/api/v1/tenants/kv/conversation-config', config)
}
export function getPromptTemplates(): Promise<{ data: PromptTemplatesConfig }> {
return get('/api/v1/tenants/kv/prompt-templates')
}
+5
View File
@@ -0,0 +1,5 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 996 B

+4 -4
View File
@@ -1,5 +1,5 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#000000" fill-opacity=".9" stroke="#000000" stroke-opacity=".9" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 1.1 KiB

+160
View File
@@ -0,0 +1,160 @@
<template>
<div
class="agent-avatar"
:style="avatarStyle"
:class="{ 'agent-avatar-small': size === 'small', 'agent-avatar-large': size === 'large' }"
>
<!-- 星星装饰 - 融入背景 -->
<svg class="agent-sparkles" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<!-- 右上角小星星 -->
<path d="M24 5L24.4 6.6C24.45 6.85 24.65 7.05 24.9 7.1L26.5 7.5L24.9 7.9C24.65 7.95 24.45 8.15 24.4 8.4L24 10L23.6 8.4C23.55 8.15 23.35 7.95 23.1 7.9L21.5 7.5L23.1 7.1C23.35 7.05 23.55 6.85 23.6 6.6L24 5Z" fill="rgba(255,255,255,0.6)"/>
<!-- 左下角小星星 -->
<path d="M7 22L7.4 23.6C7.45 23.85 7.65 24.05 7.9 24.1L9.5 24.5L7.9 24.9C7.65 24.95 7.45 25.15 7.4 25.4L7 27L6.6 25.4C6.55 25.15 6.35 24.95 6.1 24.9L4.5 24.5L6.1 24.1C6.35 24.05 6.55 23.85 6.6 23.6L7 22Z" fill="rgba(255,255,255,0.5)"/>
</svg>
<span class="agent-avatar-letter" :style="letterStyle">{{ letter }}</span>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = withDefaults(defineProps<{
name: string;
size?: 'small' | 'medium' | 'large';
}>(), {
size: 'medium'
});
// 预定义的渐变色方案 - 现代、柔和、专业
const gradients = [
{ from: '#667eea', to: '#764ba2' }, // 紫蓝渐变
{ from: '#4facfe', to: '#00f2fe' }, // 蓝青渐变
{ from: '#43e97b', to: '#38f9d7' }, // 绿青渐变
{ from: '#11998e', to: '#38ef7d' }, // 深绿渐变
{ from: '#5ee7df', to: '#b490ca' }, // 青紫渐变
{ from: '#48c6ef', to: '#6f86d6' }, // 蓝紫渐变
{ from: '#a8edea', to: '#fed6e3' }, // 青粉渐变(柔和)
{ from: '#667db6', to: '#0082c8' }, // 蓝色渐变
{ from: '#36d1dc', to: '#5b86e5' }, // 青蓝渐变
{ from: '#56ab2f', to: '#a8e063' }, // 草绿渐变
{ from: '#614385', to: '#516395' }, // 深紫蓝渐变
{ from: '#02aab0', to: '#00cdac' }, // 青绿渐变
{ from: '#6a82fb', to: '#fc5c7d' }, // 蓝粉渐变(柔和)
{ from: '#834d9b', to: '#d04ed6' }, // 紫色渐变
{ from: '#4776e6', to: '#8e54e9' }, // 蓝紫渐变
{ from: '#00b09b', to: '#96c93d' }, // 青绿渐变
];
// 根据名称生成一个稳定的哈希值
const hashCode = (str: string): number => {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash;
}
return Math.abs(hash);
};
// 获取首字母(支持中文)
const letter = computed(() => {
const name = props.name?.trim() || '';
if (!name) return '?';
// 获取第一个字符
const firstChar = name.charAt(0);
// 如果是英文字母,转大写
if (/[a-zA-Z]/.test(firstChar)) {
return firstChar.toUpperCase();
}
// 中文或其他字符直接返回
return firstChar;
});
// 根据名称选择渐变色
const gradient = computed(() => {
const hash = hashCode(props.name || '');
return gradients[hash % gradients.length];
});
// 生成样式
const avatarStyle = computed(() => {
const g = gradient.value;
return {
background: `linear-gradient(135deg, ${g.from} 0%, ${g.to} 100%)`
};
});
// 字母样式 - 白色 + 背景色阴影增加层次感
const letterStyle = computed(() => {
const g = gradient.value;
return {
textShadow: `0 1px 2px ${g.to}80, 0 0 8px ${g.from}30`
};
});
</script>
<style scoped lang="less">
.agent-avatar {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 8px;
flex-shrink: 0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
&.agent-avatar-small {
width: 22px;
height: 22px;
border-radius: 5px;
box-shadow: none;
.agent-avatar-letter {
font-size: 11px;
}
.agent-sparkles {
display: none;
}
}
&.agent-avatar-large {
width: 48px;
height: 48px;
border-radius: 12px;
.agent-avatar-letter {
font-size: 20px;
}
.agent-sparkles {
opacity: 0.9;
}
}
}
.agent-sparkles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.85;
}
.agent-avatar-letter {
position: relative;
z-index: 1;
color: #fff;
font-size: 14px;
font-weight: 600;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
</style>
+556
View File
@@ -0,0 +1,556 @@
<template>
<Teleport to="body">
<div v-if="visible" class="agent-selector-overlay" @click="$emit('close')">
<div
class="agent-selector-dropdown"
:style="dropdownStyle"
@click.stop
>
<!-- 头部 -->
<div class="agent-selector-header">
<span>{{ $t('agent.selectAgent') }}</span>
<router-link to="/platform/agents" class="agent-selector-add" @click="$emit('close')">
<span class="add-icon">+</span>
<span class="add-text">{{ $t('agent.manageAgents') }}</span>
</router-link>
</div>
<!-- 内容区域 -->
<div class="agent-selector-content">
<!-- 内置智能体分组 -->
<div class="agent-group">
<div class="agent-group-title">{{ $t('agent.builtinAgents') }}</div>
<t-popup
v-for="agent in builtinAgents"
:key="agent.id"
placement="right"
trigger="hover"
:show-arrow="true"
:overlay-inner-class-name="'agent-tooltip-popup'"
>
<div
class="agent-option"
:class="{ 'selected': currentAgentId === agent.id }"
@click="selectAgent(agent)"
>
<div class="builtin-icon" :class="agent.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'">
<TIcon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="14px" />
</div>
<span class="agent-option-name">{{ agent.name }}</span>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
</div>
<template #content>
<div class="agent-tooltip-content">
<div class="agent-tooltip-header">
<div class="builtin-icon" :class="agent.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'">
<TIcon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="14px" />
</div>
<div class="agent-tooltip-title">
<span class="agent-tooltip-name">{{ agent.name }}</span>
<span v-if="currentAgentId === agent.id" class="agent-tooltip-selected">{{ $t('agent.selector.current') }}</span>
</div>
</div>
<p class="agent-tooltip-desc">{{ agent.description || $t('agent.noDescription') }}</p>
<div class="agent-tooltip-capabilities">
<div class="capability-item">
<TIcon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="12px" />
<span>{{ agent.config?.agent_mode === 'smart-reasoning' ? $t('agent.type.agent') : $t('agent.type.normal') }}</span>
</div>
</div>
</div>
</template>
</t-popup>
</div>
<!-- 自定义智能体分组 -->
<div v-if="customAgents.length > 0" class="agent-group">
<div class="agent-group-title">{{ $t('agent.customAgents') }}</div>
<t-popup
v-for="agent in customAgents"
:key="agent.id"
placement="right"
trigger="hover"
:show-arrow="true"
:overlay-inner-class-name="'agent-tooltip-popup'"
>
<div
class="agent-option"
:class="{ 'selected': currentAgentId === agent.id }"
@click="selectAgent(agent)"
>
<AgentAvatar :name="agent.name" size="small" />
<span class="agent-option-name">{{ agent.name }}</span>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
</div>
<template #content>
<div class="agent-tooltip-content">
<div class="agent-tooltip-header">
<AgentAvatar :name="agent.name" size="small" />
<div class="agent-tooltip-title">
<span class="agent-tooltip-name">{{ agent.name }}</span>
<span v-if="currentAgentId === agent.id" class="agent-tooltip-selected">{{ $t('agent.selector.current') }}</span>
</div>
</div>
<p class="agent-tooltip-desc">{{ agent.description || $t('agent.noDescription') }}</p>
<div class="agent-tooltip-capabilities">
<div class="capability-item">
<TIcon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="12px" />
<span>{{ agent.config?.agent_mode === 'smart-reasoning' ? $t('agent.type.agent') : $t('agent.type.normal') }}</span>
</div>
<div v-if="getKbCapability(agent)" class="capability-item">
<TIcon name="folder" size="12px" />
<span>{{ getKbCapability(agent) }}</span>
</div>
<div v-if="agent.config?.web_search_enabled" class="capability-item">
<TIcon name="internet" size="12px" />
<span>{{ $t('agent.capabilities.webSearchOn') }}</span>
</div>
<div v-if="agent.config?.mcp_services?.length || agent.config?.mcp_selection_mode === 'all'" class="capability-item">
<TIcon name="extension" size="12px" />
<span>{{ $t('agent.capabilities.mcpEnabled') }}</span>
</div>
<div v-if="agent.config?.multi_turn_enabled" class="capability-item">
<TIcon name="chat-bubble" size="12px" />
<span>{{ $t('agent.capabilities.multiTurn') }}</span>
</div>
</div>
</div>
</template>
</t-popup>
</div>
<!-- 空状态 -->
<div v-if="builtinAgents.length === 0 && customAgents.length === 0" class="agent-option empty">
{{ $t('agent.noAgents') }}
</div>
</div>
</div>
</div>
</Teleport>
</template>
<script setup lang="ts">
import { ref, computed, watch, onMounted, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { Icon as TIcon, Popup as TPopup } from 'tdesign-vue-next';
import { listAgents, type CustomAgent, BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from '@/api/agent';
import AgentAvatar from '@/components/AgentAvatar.vue';
const { t } = useI18n();
const props = defineProps<{
visible: boolean;
anchorEl?: HTMLElement;
currentAgentId: string;
}>();
const emit = defineEmits<{
(e: 'close'): void;
(e: 'select', agent: CustomAgent): void;
}>();
const agents = ref<CustomAgent[]>([]);
const dropdownStyle = ref<Record<string, string>>({});
// 内置智能体
const builtinAgents = computed(() => {
return [
{
id: BUILTIN_QUICK_ANSWER_ID,
name: t('input.normalMode'),
description: t('input.normalModeDesc'),
is_builtin: true,
config: { agent_mode: 'quick-answer' as const }
},
{
id: BUILTIN_SMART_REASONING_ID,
name: t('input.agentMode'),
description: t('input.agentModeDesc'),
is_builtin: true,
config: { agent_mode: 'smart-reasoning' as const }
}
] as CustomAgent[];
});
// 自定义智能体
const customAgents = computed(() => {
return agents.value.filter(a => !a.is_builtin);
});
// 获取知识库能力描述
const getKbCapability = (agent: CustomAgent): string => {
const config = agent.config || {};
if (config.kb_selection_mode === 'none') {
return '';
} else if (config.knowledge_bases && config.knowledge_bases.length > 0) {
return t('agent.capabilities.kbCount', { count: config.knowledge_bases.length });
} else if (config.kb_selection_mode === 'all') {
return t('agent.capabilities.kbAll');
}
return '';
};
// 加载智能体列表
const loadAgents = async () => {
try {
const response = await listAgents();
agents.value = response.data || [];
} catch (error) {
console.error('Failed to load agents:', error);
}
};
// 选择智能体
const selectAgent = (agent: CustomAgent) => {
emit('select', agent);
};
// 更新下拉框位置(与模型选择器一致)
const updateDropdownPosition = () => {
if (!props.anchorEl) return;
const rect = props.anchorEl.getBoundingClientRect();
const dropdownWidth = 200;
const offsetY = 8;
const vh = window.innerHeight;
const vw = window.innerWidth;
// 水平位置:左对齐
let left = Math.floor(rect.left);
const minLeft = 16;
const maxLeft = Math.max(16, vw - dropdownWidth - 16);
left = Math.max(minLeft, Math.min(maxLeft, left));
// 垂直位置
const preferredDropdownHeight = 320;
const minDropdownHeight = 100;
const topMargin = 20;
const spaceBelow = vh - rect.bottom;
const spaceAbove = rect.top;
let actualHeight: number;
if (spaceBelow >= minDropdownHeight + offsetY) {
// 向下弹出
actualHeight = Math.min(preferredDropdownHeight, spaceBelow - offsetY - 16);
const top = Math.floor(rect.bottom + offsetY);
dropdownStyle.value = {
position: 'fixed',
width: `${dropdownWidth}px`,
left: `${left}px`,
top: `${top}px`,
maxHeight: `${actualHeight}px`,
zIndex: '9999'
};
} else {
// 向上弹出
const availableHeight = spaceAbove - offsetY - topMargin;
actualHeight = availableHeight >= preferredDropdownHeight
? preferredDropdownHeight
: Math.max(minDropdownHeight, availableHeight);
const bottom = vh - rect.top + offsetY;
dropdownStyle.value = {
position: 'fixed',
width: `${dropdownWidth}px`,
left: `${left}px`,
bottom: `${bottom}px`,
maxHeight: `${actualHeight}px`,
zIndex: '9999'
};
}
};
// 监听显示状态
watch(() => props.visible, (newVal) => {
if (newVal) {
loadAgents();
nextTick(() => {
updateDropdownPosition();
});
}
});
onMounted(() => {
if (props.visible) {
loadAgents();
}
});
</script>
<style scoped lang="less">
.agent-selector-overlay {
position: fixed;
inset: 0;
z-index: 9998;
background: transparent;
touch-action: none;
}
.agent-selector-dropdown {
position: fixed;
background: var(--td-bg-color-container, #fff);
border-radius: 10px;
box-shadow: var(--td-shadow-2, 0 6px 28px rgba(15, 23, 42, 0.08));
border: 1px solid var(--td-component-border, #e7e9eb);
overflow: hidden;
display: flex;
flex-direction: column;
}
.agent-selector-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
border-bottom: 1px solid var(--td-component-stroke, #f0f0f0);
background: var(--td-bg-color-container, #fff);
font-size: 12px;
font-weight: 500;
color: var(--td-text-color-secondary, #666);
}
.agent-selector-add {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
border-radius: 4px;
border: 1px solid transparent;
background: transparent;
color: var(--td-brand-color, #07c05f);
font-size: 12px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
text-decoration: none;
.add-icon {
font-size: 14px;
line-height: 1;
font-weight: 400;
}
&:hover {
color: var(--td-brand-color-hover, #05a04f);
background: var(--td-bg-color-secondarycontainer, #f3f3f3);
}
}
.agent-selector-content {
flex: 1;
min-height: 0;
overflow-y: auto;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
padding: 6px 8px;
}
.agent-group {
&:not(:last-child) {
margin-bottom: 8px;
padding-bottom: 8px;
border-bottom: 1px solid var(--td-component-stroke, #f0f0f0);
}
}
.agent-group-title {
font-size: 11px;
color: var(--td-text-color-placeholder, #999);
padding: 4px 8px 6px;
font-weight: 500;
}
.agent-option {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 8px;
cursor: pointer;
transition: background 0.12s;
border-radius: 6px;
margin-bottom: 4px;
&:last-child {
margin-bottom: 0;
}
&:hover {
background: var(--td-bg-color-container-hover, #f6f8f7);
}
&.selected {
background: var(--td-brand-color-light, #eefdf5);
.agent-option-name {
color: #10b981;
font-weight: 600;
}
}
&.empty {
color: var(--td-text-color-disabled, #9aa0a6);
cursor: default;
text-align: center;
padding: 20px 8px;
&:hover {
background: transparent;
}
}
}
.agent-option-name {
font-size: 12px;
color: var(--td-text-color-primary, #222);
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 1.4;
}
.builtin-icon {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border-radius: 6px;
flex-shrink: 0;
&.normal {
background: rgba(7, 192, 95, 0.1);
color: #059669;
}
&.agent {
background: rgba(124, 77, 255, 0.1);
color: #7c4dff;
}
}
.check-icon {
width: 14px;
height: 14px;
color: #10b981;
flex-shrink: 0;
margin-left: 6px;
}
// Tooltip 内容样式
.agent-tooltip-content {
padding: 4px 0;
min-width: 200px;
max-width: 280px;
}
.agent-tooltip-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
.builtin-icon {
width: 28px;
height: 28px;
}
}
.agent-tooltip-title {
display: flex;
flex-direction: column;
gap: 2px;
flex: 1;
min-width: 0;
}
.agent-tooltip-name {
font-size: 13px;
font-weight: 600;
color: var(--td-text-color-primary, #222);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-tooltip-selected {
font-size: 10px;
color: #10b981;
font-weight: 500;
}
.agent-tooltip-desc {
font-size: 12px;
color: var(--td-text-color-secondary, #666);
line-height: 1.5;
margin: 0 0 10px 0;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-tooltip-capabilities {
display: flex;
flex-wrap: wrap;
gap: 6px;
padding-top: 8px;
border-top: 1px solid var(--td-component-stroke, #f0f0f0);
}
.capability-item {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 3px 8px;
background: var(--td-bg-color-secondarycontainer, #f5f5f5);
border-radius: 4px;
font-size: 11px;
color: var(--td-text-color-secondary, #666);
:deep(.t-icon) {
color: var(--td-text-color-placeholder, #999);
}
}
</style>
<!-- 全局样式覆盖 TDesign Popup -->
<style lang="less">
.agent-tooltip-popup {
&.t-popup__content {
background: var(--td-bg-color-container, #fff) !important;
border: 1px solid var(--td-component-border, #e7e9eb) !important;
border-radius: 8px !important;
box-shadow: var(--td-shadow-2, 0 6px 28px rgba(15, 23, 42, 0.08)) !important;
padding: 10px 12px !important;
}
.t-popup__arrow {
&::before {
background: var(--td-bg-color-container, #fff) !important;
border-color: var(--td-component-border, #e7e9eb) !important;
}
}
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,261 @@
<template>
<div class="prompt-template-selector" :class="{ 'position-corner': position === 'corner' }">
<t-popup
trigger="click"
placement="top-right"
:visible="popupVisible"
@visible-change="handleVisibleChange"
>
<template #content>
<div class="template-popup">
<div class="template-header">
<span class="template-title">{{ $t('promptTemplate.selectTemplate') }}</span>
</div>
<div v-if="loading" class="template-loading">
<t-loading size="small" />
</div>
<div v-else-if="templates.length === 0" class="template-empty">
{{ $t('promptTemplate.noTemplates') || '暂无模板' }}
</div>
<div v-else class="template-list">
<div
v-for="template in templates"
:key="template.id"
class="template-item"
@click="selectTemplate(template)"
>
<div class="template-item-header">
<span class="template-name">{{ template.name }}</span>
<span v-if="template.has_knowledge_base" class="template-tag kb-tag">
<t-icon name="folder" size="12px" />
{{ $t('promptTemplate.withKnowledgeBase') }}
</span>
<span v-if="template.has_web_search" class="template-tag web-tag">
<t-icon name="internet" size="12px" />
{{ $t('promptTemplate.withWebSearch') }}
</span>
</div>
<p class="template-desc">{{ template.description }}</p>
</div>
</div>
</div>
</template>
<t-button
variant="outline"
size="small"
class="template-trigger-btn"
:loading="loading"
>
<t-icon name="view-module" />
<span>{{ $t('promptTemplate.useTemplate') }}</span>
</t-button>
</t-popup>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { getPromptTemplates, type PromptTemplate, type PromptTemplatesConfig } from '@/api/system';
const props = defineProps<{
type: 'systemPrompt' | 'contextTemplate' | 'rewriteSystem' | 'rewriteUser' | 'fallback';
hasKnowledgeBase?: boolean;
position?: 'inline' | 'corner'; // inline: 行内显示, corner: 输入框右下角
}>();
const emit = defineEmits<{
(e: 'select', content: string): void;
}>();
const popupVisible = ref(false);
const loading = ref(false);
const templatesConfig = ref<PromptTemplatesConfig | null>(null);
const handleVisibleChange = async (visible: boolean) => {
popupVisible.value = visible;
// 首次打开时加载模板
if (visible && !templatesConfig.value) {
await loadTemplates();
}
};
const loadTemplates = async () => {
if (loading.value) return;
loading.value = true;
try {
const response = await getPromptTemplates();
templatesConfig.value = response.data;
} catch (error) {
console.error('Failed to load prompt templates:', error);
} finally {
loading.value = false;
}
};
// 根据类型获取对应的模板列表
const templates = computed<PromptTemplate[]>(() => {
if (!templatesConfig.value) return [];
switch (props.type) {
case 'systemPrompt':
return templatesConfig.value.system_prompt || [];
case 'contextTemplate':
return templatesConfig.value.context_template || [];
case 'rewriteSystem':
return templatesConfig.value.rewrite_system || [];
case 'rewriteUser':
return templatesConfig.value.rewrite_user || [];
case 'fallback':
return templatesConfig.value.fallback || [];
default:
return [];
}
});
const selectTemplate = (template: PromptTemplate) => {
emit('select', template.content);
popupVisible.value = false;
};
// 预加载模板(可选)
onMounted(() => {
// 可以在这里预加载,也可以等用户点击时再加载
// loadTemplates();
});
</script>
<style scoped lang="less">
.prompt-template-selector {
display: inline-flex;
&.position-corner {
position: absolute;
right: 8px;
bottom: 8px;
z-index: 10;
}
}
.template-trigger-btn {
display: inline-flex;
align-items: center;
gap: 4px;
color: #666;
border-color: #d9d9d9;
font-size: 12px;
height: 26px;
padding: 0 8px;
background: rgba(255, 255, 255, 0.95);
&:hover {
color: #07c05f;
border-color: #07c05f;
background: #fff;
}
:deep(.t-button__text) {
display: inline-flex;
align-items: center;
gap: 4px;
}
:deep(.t-icon) {
vertical-align: middle;
line-height: 1;
}
}
.template-popup {
width: 420px;
max-height: 400px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.template-header {
padding: 12px 16px;
border-bottom: 1px solid #e5e7eb;
flex-shrink: 0;
}
.template-title {
font-size: 14px;
font-weight: 500;
color: #333;
}
.template-loading,
.template-empty {
padding: 40px 16px;
text-align: center;
color: #999;
font-size: 13px;
}
.template-list {
overflow-y: auto;
padding: 8px;
flex: 1;
}
.template-item {
padding: 12px;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
margin-bottom: 4px;
&:last-child {
margin-bottom: 0;
}
&:hover {
background: #f5f7fa;
}
}
.template-item-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
flex-wrap: wrap;
}
.template-name {
font-size: 14px;
font-weight: 500;
color: #333;
}
.template-tag {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 2px 6px;
border-radius: 4px;
font-size: 11px;
&.kb-tag {
background: #e6f7ff;
color: #1890ff;
}
&.web-tag {
background: #f0faf5;
color: #07c05f;
}
}
.template-desc {
font-size: 12px;
color: #666;
margin: 0;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
-4
View File
@@ -24,10 +24,6 @@
<t-icon name="server" class="menu-icon" />
<span>Ollama</span>
</div>
<div class="menu-item" @click="handleQuickNav('agent')">
<t-icon name="chat" class="menu-icon" />
<span>{{ $t('settings.conversationStrategy') }}</span>
</div>
<div class="menu-item" @click="handleQuickNav('websearch')">
<svg
width="16"
+38 -4
View File
@@ -24,6 +24,18 @@
</div>
</div>
</template>
<template v-else-if="showCreateAgentAction">
<div class="menu_item kb-action-item" @click.stop="handleCreateAgent">
<div class="kb-action-icon-wrapper">
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 18 18" fill="none">
<path d="M9 3.75V14.25M3.75 9H14.25" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="kb-action-content">
<span class="kb-action-title">{{ t('agent.createAgent') }}</span>
</div>
</div>
</template>
<template v-else-if="showDocActions">
<div class="menu_item kb-action-item" @click.stop="handleDocUploadClick">
<div class="kb-action-icon-wrapper">
@@ -138,7 +150,7 @@
:class="['menu_item', item.childrenPath && item.childrenPath == currentpath ? 'menu_item_c_active' : isMenuItemActive(item.path) ? 'menu_item_active' : '']">
<div class="menu_item-box">
<div class="menu_icon">
<img class="icon" :src="getImgSrc(item.icon == 'zhishiku' ? knowledgeIcon : item.icon == 'logout' ? logoutIcon : item.icon == 'setting' ? settingIcon : prefixIcon)" alt="">
<img class="icon" :src="getImgSrc(item.icon == 'zhishiku' ? knowledgeIcon : item.icon == 'agent' ? agentIcon : item.icon == 'logout' ? logoutIcon : item.icon == 'setting' ? settingIcon : prefixIcon)" alt="">
</div>
<span class="menu_title" :title="item.title">{{ item.title }}</span>
<t-icon v-if="item.path === 'creatChat'" name="add" class="menu-create-hint" />
@@ -253,6 +265,9 @@ const isInCreatChat = computed<boolean>(() => {
// 是否在对话详情页
const isInChatDetail = computed<boolean>(() => route.name === 'chat');
// 是否在智能体列表页面
const isInAgentList = computed<boolean>(() => route.name === 'agentList');
// 统一的菜单项激活状态判断
const isMenuItemActive = (itemPath: string): boolean => {
const currentRoute = route.name;
@@ -262,6 +277,8 @@ const isMenuItemActive = (itemPath: string): boolean => {
return currentRoute === 'knowledgeBaseList' ||
currentRoute === 'knowledgeBaseDetail' ||
currentRoute === 'knowledgeBaseSettings';
case 'agents':
return currentRoute === 'agentList';
case 'creatChat':
return currentRoute === 'kbCreatChat' || currentRoute === 'globalCreatChat';
case 'settings':
@@ -290,13 +307,13 @@ const getIconActiveState = (itemPath: string) => {
// 分离上下两部分菜单
const topMenuItems = computed<MenuItem[]>(() => {
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
item.path === 'knowledge-bases' || item.path === 'creatChat'
item.path === 'knowledge-bases' || item.path === 'agents' || item.path === 'creatChat'
);
});
const bottomMenuItems = computed<MenuItem[]>(() => {
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
if (item.path === 'knowledge-bases' || item.path === 'creatChat') {
if (item.path === 'knowledge-bases' || item.path === 'agents' || item.path === 'creatChat') {
return false;
}
return true;
@@ -325,12 +342,14 @@ const showKbActions = computed(() =>
(isInKnowledgeBase.value && !!currentKbInfo.value) ||
isInKnowledgeBaseList.value ||
isInCreatChat.value ||
isInChatDetail.value
isInChatDetail.value ||
isInAgentList.value
)
const currentKbType = computed(() => currentKbInfo.value?.type || 'document')
const showDocActions = computed(() => showKbActions.value && isInKnowledgeBase.value && currentKbType.value !== 'faq')
const showFaqActions = computed(() => showKbActions.value && isInKnowledgeBase.value && currentKbType.value === 'faq')
const showCreateKbAction = computed(() => showKbActions.value && (isInKnowledgeBaseList.value || isInCreatChat.value || isInChatDetail.value))
const showCreateAgentAction = computed(() => showKbActions.value && isInAgentList.value)
// 时间分组函数
const getTimeCategory = (dateStr: string): string => {
@@ -570,16 +589,21 @@ let knowledgeIcon = ref('zhishiku-green.svg');
let prefixIcon = ref('prefixIcon.svg');
let logoutIcon = ref('logout.svg');
let settingIcon = ref('setting.svg'); // 设置图标
let agentIcon = ref('agent.svg'); // 智能体图标
let pathPrefix = ref(route.name)
const getIcon = (path: string) => {
// 根据当前路由状态更新所有图标
const kbActiveState = getIconActiveState('knowledge-bases');
const creatChatActiveState = getIconActiveState('creatChat');
const settingsActiveState = getIconActiveState('settings');
const agentsActiveState = route.name === 'agentList';
// 知识库图标:只在知识库页面显示绿色
knowledgeIcon.value = kbActiveState.isKbActive ? 'zhishiku-green.svg' : 'zhishiku.svg';
// 智能体图标:只在智能体页面显示绿色
agentIcon.value = agentsActiveState ? 'agent-green.svg' : 'agent.svg';
// 对话图标:只在对话创建页面显示绿色,在知识库页面显示灰色,其他情况显示默认
prefixIcon.value = creatChatActiveState.isCreatChatActive ? 'prefixIcon-green.svg' :
kbActiveState.isKbActive ? 'prefixIcon-grey.svg' :
@@ -601,6 +625,9 @@ const handleMenuClick = async (path: string) => {
} else {
router.push('/platform/knowledge-bases')
}
} else if (path === 'agents') {
// 智能体菜单项:跳转到智能体列表
router.push('/platform/agents')
} else if (path === 'settings') {
// 设置菜单项:打开设置弹窗并跳转路由
uiStore.openSettings()
@@ -1238,6 +1265,13 @@ const handleCreateKnowledgeBase = () => {
uiStore.openCreateKB()
}
const handleCreateAgent = () => {
// 触发创建智能体事件,由 AgentList 页面监听处理
window.dispatchEvent(new CustomEvent('openAgentEditor', {
detail: { mode: 'create' }
}))
}
</script>
<style lang="less" scoped>
.aside_box {
+307 -11
View File
@@ -1,6 +1,7 @@
export default {
menu: {
knowledgeBase: 'Knowledge Base',
agents: 'Agents',
chat: 'Chat',
createChat: 'Create Chat',
tenant: 'Account Info',
@@ -204,7 +205,197 @@ export default {
updatePlan: 'Update Plan',
webSearchFound: 'Found <strong>{count}</strong> web search result(s)',
argumentsLabel: 'Arguments',
toolFallback: 'Tool'
toolFallback: 'Tool',
title: 'Agents',
subtitle: 'Configure and manage your agents to customize conversation behavior and capabilities',
createAgent: 'Create Agent',
builtin: 'Built-in',
noDescription: 'No description',
selectAgent: 'Select Agent',
noAgents: 'No agents',
manageAgents: 'Manage',
builtinAgents: 'Built-in Agents',
customAgents: 'Custom Agents',
capabilities: {
normal: 'Quick response, direct answers',
agent: 'Multi-step thinking, deep analysis for complex questions',
modelSpecified: 'Model specified',
kbCount: '{count} knowledge base(s) specified',
kbAll: 'Access to all knowledge bases',
kbDisabled: 'Knowledge base disabled',
rerankSpecified: 'ReRank model specified',
webSearchOn: 'Web search enabled',
webSearchOff: 'Web search disabled',
hasPrompt: 'Custom prompt',
default: 'Default configuration',
mcpEnabled: 'MCP services enabled',
multiTurn: 'Multi-turn conversation',
},
type: {
normal: 'Quick Answer',
agent: 'Smart Reasoning',
custom: 'Custom',
},
mode: {
normal: 'Quick Answer',
agent: 'Smart Reasoning',
},
features: {
webSearch: 'Web Search Enabled',
knowledgeBase: 'Knowledge Base Linked',
mcp: 'MCP Services Enabled',
multiTurn: 'Multi-turn Conversation',
},
empty: {
title: 'No Custom Agents',
description: 'Click the button in the top right to create your first agent',
},
delete: {
confirmTitle: 'Delete Agent',
confirmMessage: 'Are you sure you want to delete agent "{name}"? This action cannot be undone.',
confirmButton: 'Confirm Delete',
},
messages: {
created: 'Agent created successfully',
updated: 'Agent updated successfully',
deleted: 'Agent deleted',
deleteFailed: 'Delete failed',
saveFailed: 'Save failed',
builtinReadonly: 'Built-in agents cannot be edited',
copied: 'Agent copied successfully',
copyFailed: 'Copy failed',
},
editor: {
createTitle: 'Create Agent',
editTitle: 'Edit Agent',
basicInfo: 'Basic Info',
basicInfoDesc: 'Configure agent basic information',
modelConfig: 'Model Config',
modelConfigDesc: 'Configure agent model parameters',
capabilities: 'Capabilities',
capabilitiesDesc: 'Configure agent capabilities and tools',
toolsConfig: 'Tools',
toolsConfigDesc: 'Configure tools available to the Agent',
knowledgeConfig: 'Knowledge Base',
knowledgeConfigDesc: 'Configure knowledge bases for the agent',
webSearchConfig: 'Web Search',
webSearchConfigDesc: 'Configure web search capabilities for the agent',
configuration: 'Configuration',
name: 'Name',
namePlaceholder: 'Enter agent name',
nameRequired: 'Agent name is required',
systemPromptRequired: 'System prompt is required',
modelRequired: 'Please select a model',
rerankModelRequired: 'ReRank model is required when using knowledge bases',
contextsMissing: 'Context template must contain {{contexts}} placeholder when knowledge base is enabled',
queryMissingInContext: 'Context template must contain {{query}} placeholder',
knowledgeBasesMissing: 'It is recommended to include {{knowledge_bases}} placeholder in system prompt so the model knows available knowledge bases',
queryMissingInRewrite: 'Rewrite user prompt must contain {{query}} placeholder',
conversationMissing: 'Rewrite user prompt must contain {{conversation}} placeholder',
queryMissingInFallback: 'Fallback prompt must contain {{query}} placeholder',
avatar: 'Avatar',
avatarPlaceholder: 'Enter Emoji or select',
description: 'Description',
descriptionPlaceholder: 'Enter agent description',
baseType: 'Base Type',
normalDesc: 'Quick response, direct answers',
agentDesc: 'Multi-step thinking, deep analysis for complex questions',
model: 'Model',
modelPlaceholder: 'Select Model',
systemPrompt: 'System Prompt',
systemPromptPlaceholder: 'Custom system prompt to define agent behavior and role (use {{web_search_status}} placeholder for dynamic web search behavior)',
defaultPromptHint: 'Leave empty to use the following default system prompt:',
defaultContextTemplateHint: 'Leave empty to use the following default context template:',
contextTemplateRequired: 'Context template is required',
availablePlaceholders: 'Available Placeholders',
placeholderHint: 'Type {{ to trigger autocomplete',
temperature: 'Temperature',
welcomeMessage: 'Welcome Message',
welcomeMessagePlaceholder: 'Message displayed when this agent is selected',
suggestedPrompts: 'Suggested Prompts',
mode: 'Running Mode',
webSearch: 'Web Search',
webSearchMaxResults: 'Max Search Results',
knowledgeBases: 'Knowledge Bases',
allKnowledgeBases: 'All Knowledge Bases',
allKnowledgeBasesDesc: 'Agent can access all knowledge bases',
selectedKnowledgeBases: 'Selected Knowledge Bases',
selectedKnowledgeBasesDesc: 'Only access selected knowledge bases',
noKnowledgeBase: 'No Knowledge Base',
noKnowledgeBaseDesc: 'Pure model conversation, no knowledge retrieval',
selectKnowledgeBases: 'Select Knowledge Bases',
rerankModel: 'ReRank Model',
rerankModelDesc: 'Used to rerank knowledge base retrieval results for better accuracy',
rerankModelPlaceholder: 'Select ReRank Model',
maxIterations: 'Max Iterations',
allowedTools: 'Allowed Tools',
multiTurn: 'Multi-turn Conversation',
historyTurns: 'History Turns',
// Retrieval Strategy
retrievalStrategy: 'Retrieval Strategy',
embeddingTopK: 'Embedding Top K',
keywordThreshold: 'Keyword Threshold',
vectorThreshold: 'Vector Threshold',
rerankTopK: 'Rerank Top K',
rerankThreshold: 'Rerank Threshold',
// Conversation Settings
conversationSettings: 'Conversation',
// Advanced Settings
advancedSettings: 'Advanced Settings',
contextTemplate: 'Context Template',
contextTemplatePlaceholder: 'Custom context template...',
availableContextPlaceholders: 'Available Placeholders',
placeholderQuery: 'User query',
placeholderContexts: 'Retrieved content list',
placeholderCurrentTime: 'Current time (format: 2006-01-02 15:04:05)',
placeholderCurrentWeek: 'Current weekday (e.g., Monday)',
enableQueryExpansion: 'Query Expansion',
enableRewrite: 'Query Rewrite',
rewritePromptSystem: 'Rewrite System Prompt',
rewritePromptSystemPlaceholder: 'Leave empty to use default prompt',
rewritePromptUser: 'Rewrite User Prompt',
rewritePromptUserPlaceholder: 'Leave empty to use default prompt',
maxCompletionTokens: 'Max Completion Tokens',
fallbackStrategy: 'Fallback Strategy',
fallbackResponse: 'Fixed Response',
fallbackResponsePlaceholder: 'Sorry, I cannot answer this question.',
fallbackPrompt: 'Fallback Prompt',
fallbackPromptPlaceholder: 'Leave empty to use default prompt',
},
selector: {
title: 'Select Agent',
builtinSection: 'Built-in Agents',
customSection: 'My Agents',
addNew: 'Add New Agent',
current: 'Current',
},
// Built-in agent information
builtinInfo: {
quickAnswer: {
name: 'Quick Answer',
description: 'Knowledge base RAG Q&A for fast and accurate answers',
},
smartReasoning: {
name: 'Smart Reasoning',
description: 'ReAct reasoning framework with multi-step thinking and tool calling',
},
deepResearcher: {
name: 'Deep Researcher',
description: 'Focused on in-depth research and comprehensive analysis, capable of creating research plans, multi-dimensional information retrieval, deep thinking and providing thorough analysis reports',
},
dataAnalyst: {
name: 'Data Analyst',
description: 'Focused on database queries and data analysis, capable of understanding business needs, building SQL queries, analyzing data and providing insights',
},
knowledgeGraphExpert: {
name: 'Knowledge Graph Expert',
description: 'Focused on knowledge graph queries and relationship analysis, capable of exploring entity relationships, discovering hidden connections and building knowledge networks',
},
documentAssistant: {
name: 'Document Assistant',
description: 'Focused on document retrieval and content organization, capable of quickly locating documents, extracting key information and generating summaries',
},
},
},
settings: {
title: 'Settings',
@@ -604,6 +795,7 @@ export default {
save: 'Save',
delete: 'Delete',
edit: 'Edit',
copy: 'Copy',
default: 'Default',
create: 'Create',
search: 'Search',
@@ -752,16 +944,25 @@ export default {
placeholderWithContext: 'Enter your question, will answer based on selected knowledge bases/files above',
placeholderWebOnly: 'Enter your question, will answer with web search',
placeholderKbAndWeb: 'Enter your question, will answer based on knowledge base and web search',
agentMode: 'Agent Mode',
normalMode: 'Normal Mode',
placeholderAgent: 'Ask {name}',
agentMode: 'Smart Reasoning',
normalMode: 'Quick Answer',
normalModeDesc: 'Knowledge base RAG Q&A',
agentModeDesc: 'ReAct reasoning framework with multi-step thinking',
agentModeDesc: 'Multi-step thinking, deep analysis',
agentNotReadyTooltip: 'Agent is not ready. Please finish configuration first.',
agentNotReadyDetail: 'Agent is not ready. Please configure the following: {reasons}',
agentMissingAllowedTools: 'Allowed tools',
agentMissingSummaryModel: 'Chat Model (Summary Model)',
agentMissingRerankModel: 'Rerank Model',
goToSettings: 'Go to settings →',
customAgentNotReadyTooltip: 'Agent is not ready. Please finish configuration first.',
customAgentNotReadyDetail: 'Agent is not ready. Please configure the following: {reasons}',
customAgentMissingSummaryModel: 'Chat Model (Summary Model)',
customAgentMissingRerankModel: 'Rerank Model',
goToAgentEditor: 'Go to configure →',
builtinAgentNotReadyDetail: 'Built-in agent "{agentName}" is not ready. Please configure: {reasons}',
builtinAgentSettingName: 'Intelligent Reasoning',
builtinNormalSettingName: 'Quick Q&A',
webSearch: {
toggleOn: 'Enable Web Search',
toggleOff: 'Disable Web Search',
@@ -780,8 +981,9 @@ export default {
enterContent: 'Please enter content first!',
selectKnowledge: 'Please select a knowledge base first!',
replying: 'Currently replying, please try again later!',
agentSwitchedOn: 'Switched to Agent Mode',
agentSwitchedOff: 'Switched to Normal Mode',
agentSwitchedOn: 'Switched to Intelligent Reasoning',
agentSwitchedOff: 'Switched to Quick Q&A',
agentSelected: 'Selected agent "{name}"',
agentEnabled: 'Agent Mode enabled',
agentDisabled: 'Agent Mode disabled',
agentNotReadyDetail: 'Agent is not ready. Please configure the following: {reasons}',
@@ -795,7 +997,15 @@ export default {
messageMissing: 'Unable to get message ID. Please refresh the page and try again.',
stopSuccess: 'Generation stopped',
stopFailed: 'Failed to stop. Please try again.'
}
},
webSearchDisabledByAgent: 'Web search is disabled by the current agent',
webSearchForcedByAgent: 'Web search is enabled by the current agent and cannot be turned off',
kbLockedByAgent: 'Knowledge base configuration is locked by the current agent',
kbDisabledByAgent: 'Knowledge base is disabled by the current agent',
cannotRemoveAgentKb: 'Cannot remove knowledge base configured by agent',
agentConfiguredKb: 'Configured by agent, cannot be removed',
modelLockedByAgent: 'Model selection is locked by the current agent',
goToAgentSettings: 'Go to agent settings'
},
createChat: {
title: 'Knowledge-base Q&A - AI Assistant',
@@ -1589,9 +1799,7 @@ export default {
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...',
tabHint: 'Configure separate prompts for sessions with web search on or off.',
tabWebOn: 'Web search enabled',
tabWebOff: 'Web search disabled'
tabHint: 'Unified system prompt using {{web_search_status}} placeholder for dynamic web search behavior'
},
reset: {
header: 'Reset to Default Prompt',
@@ -1931,5 +2139,93 @@ export default {
createFailed: 'Failed to create MCP service',
updateFailed: 'Failed to update MCP service'
}
}
},
promptTemplate: {
selectTemplate: 'Select Template',
useTemplate: 'Use Template',
withKnowledgeBase: 'KB',
withWebSearch: 'Web Search',
systemPrompt: {
defaultKB: {
name: 'Knowledge Base Assistant',
desc: 'Basic knowledge base Q&A template for most scenarios',
},
expert: {
name: 'Domain Expert',
desc: 'Professional and in-depth answers for technical domains',
},
customerService: {
name: 'Customer Service',
desc: 'Friendly and warm service style for customer support',
},
techSupport: {
name: 'Technical Support',
desc: 'Professional technical problem solving with code examples',
},
pureChat: {
name: 'General Chat',
desc: 'General conversation assistant without knowledge base',
},
webSearch: {
name: 'Web Search Assistant',
desc: 'Combines web search for up-to-date information',
},
},
contextTemplate: {
default: {
name: 'Standard Template',
desc: 'Basic context template with clear references and questions',
},
detailed: {
name: 'Detailed Template',
desc: 'Complete template with detailed instructions and requirements',
},
simple: {
name: 'Simple Template',
desc: 'Minimal template format for simple Q&A scenarios',
},
qa: {
name: 'Q&A Template',
desc: 'Optimized template for Q&A scenarios',
},
},
rewriteSystem: {
default: {
name: 'Standard Rewrite',
desc: 'Standard rules for resolving references and completing omissions',
},
strict: {
name: 'Strict Rewrite',
desc: 'Stricter requirements for complete and independent questions',
},
},
rewriteUser: {
default: {
name: 'Standard Format',
desc: 'Standard format with conversation history and current question',
},
detailed: {
name: 'Detailed Format',
desc: 'Detailed format with task instructions',
},
},
fallback: {
default: {
name: 'Standard Fallback',
desc: 'Friendly message with suggestions when unable to answer',
},
polite: {
name: 'Polite Fallback',
desc: 'More polite and detailed unable-to-answer message',
},
brief: {
name: 'Brief Fallback',
desc: 'Short unable-to-answer message',
},
model: {
name: 'Model Fallback Prompt',
desc: 'Prompt to guide model to answer with general knowledge',
},
},
},
}
+4 -3
View File
@@ -1733,10 +1733,11 @@ export default {
placeholderWithContext: 'Введите вопрос, ответ будет основан на выбранных выше базах знаний/файлах',
placeholderWebOnly: 'Введите вопрос, ответ будет основан на веб-поиске',
placeholderKbAndWeb: 'Введите вопрос, ответ будет основан на базе знаний и веб-поиске',
agentMode: 'Agent режим',
normalMode: 'Обычный режим',
placeholderAgent: 'Спросить {name}',
agentMode: 'Умный анализ',
normalMode: 'Быстрый ответ',
normalModeDesc: 'RAG-вопросы и ответы по базе знаний',
agentModeDesc: 'Шаблон рассуждений ReAct, многошаговое мышление',
agentModeDesc: 'Многошаговое мышление, глубокий анализ',
agentNotReadyTooltip: 'Agent не готов. Пожалуйста, завершите настройку.',
agentNotReadyDetail: 'Agent не готов. Пожалуйста, настройте следующее: {reasons}',
agentMissingAllowedTools: 'Разрешённые инструменты',
+313 -17
View File
@@ -1,6 +1,7 @@
export default {
menu: {
knowledgeBase: "知识库",
agents: "智能体",
chat: "对话",
createChat: "创建对话",
tenant: "账户信息",
@@ -297,15 +298,6 @@ export default {
selectKnowledgeBaseWarning: "请至少选择一个知识库",
processError: "处理出错",
},
agent: {
taskLabel: "任务:",
copy: "复制",
addToKnowledgeBase: "添加到知识库",
updatePlan: "更新计划",
webSearchFound: "找到 <strong>{count}</strong> 个网络搜索结果",
argumentsLabel: "参数",
toolFallback: "工具",
},
settings: {
title: "设置",
modelConfig: "模型配置",
@@ -697,6 +689,7 @@ export default {
save: "保存",
delete: "删除",
edit: "编辑",
copy: "复制",
default: "默认",
create: "创建",
search: "搜索",
@@ -735,6 +728,205 @@ export default {
knowledgeBase: "知识库",
noResult: "无结果",
},
agent: {
taskLabel: "任务:",
copy: "复制",
addToKnowledgeBase: "添加到知识库",
updatePlan: "更新计划",
webSearchFound: "找到 <strong>{count}</strong> 个网络搜索结果",
argumentsLabel: "参数",
toolFallback: "工具",
title: "智能体",
subtitle: "配置和管理您的智能体,自定义对话行为和能力",
createAgent: "创建智能体",
builtin: "内置",
noDescription: "暂无描述",
selectAgent: "选择智能体",
noAgents: "暂无智能体",
manageAgents: "管理",
builtinAgents: "内置智能体",
customAgents: "自定义智能体",
capabilities: {
normal: "快速响应,直接回答问题",
agent: "多步思考,深度分析复杂问题",
modelSpecified: "指定模型",
kbCount: "指定 {count} 个知识库",
kbAll: "可访问全部知识库",
kbDisabled: "禁用知识库",
rerankSpecified: "指定 ReRank 模型",
webSearchOn: "启用网络搜索",
webSearchOff: "禁用网络搜索",
hasPrompt: "自定义提示词",
default: "默认配置",
mcpEnabled: "启用 MCP 服务",
multiTurn: "多轮对话",
},
type: {
normal: "快速问答",
agent: "智能推理",
custom: "自定义",
},
mode: {
normal: "快速问答",
agent: "智能推理",
},
features: {
webSearch: "支持网络搜索",
knowledgeBase: "关联知识库",
mcp: "支持MCP服务",
multiTurn: "多轮对话",
},
empty: {
title: "暂无自定义智能体",
description: "点击右上角按钮创建您的第一个智能体",
},
delete: {
confirmTitle: "删除智能体",
confirmMessage: "确定要删除智能体「{name}」吗?此操作不可恢复。",
confirmButton: "确认删除",
},
messages: {
created: "智能体创建成功",
updated: "智能体更新成功",
deleted: "智能体已删除",
deleteFailed: "删除失败",
saveFailed: "保存失败",
builtinReadonly: "内置智能体不可编辑",
copied: "智能体复制成功",
copyFailed: "复制失败",
},
editor: {
createTitle: "创建智能体",
editTitle: "编辑智能体",
basicInfo: "基本信息",
basicInfoDesc: "配置智能体的基本信息",
modelConfig: "模型配置",
modelConfigDesc: "配置智能体的模型参数",
capabilities: "能力与工具",
capabilitiesDesc: "配置智能体的能力和工具",
toolsConfig: "工具配置",
toolsConfigDesc: "配置 Agent 可以使用的工具",
knowledgeConfig: "知识库",
knowledgeConfigDesc: "配置智能体可访问的知识库",
webSearchConfig: "网络搜索",
webSearchConfigDesc: "配置智能体的网络搜索能力",
configuration: "配置项",
name: "名称",
namePlaceholder: "请输入智能体名称",
nameRequired: "请输入智能体名称",
systemPromptRequired: "请输入系统提示词",
modelRequired: "请选择模型",
rerankModelRequired: "使用知识库时请选择 ReRank 模型",
contextsMissing: "开启知识库时,上下文模板必须包含 {{contexts}} 占位符",
queryMissingInContext: "上下文模板必须包含 {{query}} 占位符",
knowledgeBasesMissing: "建议在系统提示词中包含 {{knowledge_bases}} 占位符,以便模型了解可用的知识库",
queryMissingInRewrite: "改写用户提示词必须包含 {{query}} 占位符",
conversationMissing: "改写用户提示词必须包含 {{conversation}} 占位符",
queryMissingInFallback: "兜底提示词必须包含 {{query}} 占位符",
avatar: "图标",
avatarPlaceholder: "输入 Emoji 或点击选择",
description: "描述",
descriptionPlaceholder: "请输入智能体描述",
baseType: "基础类型",
normalDesc: "快速响应,直接回答问题",
agentDesc: "多步思考,深度分析复杂问题",
model: "模型",
modelPlaceholder: "请选择模型",
systemPrompt: "系统提示词",
systemPromptPlaceholder: "自定义系统提示词,定义智能体的行为和角色(使用 {{web_search_status}} 占位符动态控制网络搜索行为)",
defaultPromptHint: "留空将使用以下系统默认提示词:",
defaultContextTemplateHint: "留空将使用以下系统默认上下文模板:",
contextTemplateRequired: "请输入上下文模板",
availablePlaceholders: "可用占位符",
placeholderHint: "输入 {{ 触发自动补全",
temperature: "温度",
welcomeMessage: "欢迎消息",
welcomeMessagePlaceholder: "选择该智能体时显示的欢迎消息",
suggestedPrompts: "推荐问题",
mode: "运行模式",
webSearch: "网络搜索",
webSearchMaxResults: "最大搜索结果数",
knowledgeBases: "关联知识库",
allKnowledgeBases: "全部知识库",
allKnowledgeBasesDesc: "智能体可访问所有知识库",
selectedKnowledgeBases: "指定知识库",
selectedKnowledgeBasesDesc: "仅访问选定的知识库",
noKnowledgeBase: "不使用知识库",
noKnowledgeBaseDesc: "纯模型对话,不检索知识库",
selectKnowledgeBases: "选择知识库",
rerankModel: "ReRank 模型",
rerankModelDesc: "用于对知识库检索结果进行重排序,提高回答准确性",
rerankModelPlaceholder: "请选择 ReRank 模型",
maxIterations: "最大迭代次数",
allowedTools: "允许的工具",
multiTurn: "多轮对话",
historyTurns: "保留轮数",
// 检索策略
retrievalStrategy: "检索策略",
embeddingTopK: "向量召回数量",
keywordThreshold: "关键词阈值",
vectorThreshold: "向量阈值",
rerankTopK: "重排数量",
rerankThreshold: "重排阈值",
// 多轮对话
conversationSettings: "多轮对话",
// 高级设置
advancedSettings: "高级设置",
contextTemplate: "上下文模板",
contextTemplatePlaceholder: "自定义上下文模板...",
availableContextPlaceholders: "可用占位符",
placeholderQuery: "用户的问题",
placeholderContexts: "检索到的内容列表",
placeholderCurrentTime: "当前时间(格式:2006-01-02 15:04:05)",
placeholderCurrentWeek: "当前星期(如:星期一)",
enableQueryExpansion: "查询扩展",
enableRewrite: "问题改写",
rewritePromptSystem: "改写系统提示词",
rewritePromptSystemPlaceholder: "留空使用系统默认提示词",
rewritePromptUser: "改写用户提示词",
rewritePromptUserPlaceholder: "留空使用系统默认提示词",
maxCompletionTokens: "最大生成Token数",
fallbackStrategy: "兜底策略",
fallbackResponse: "固定回复内容",
fallbackResponsePlaceholder: "抱歉,我无法回答这个问题。",
fallbackPrompt: "兜底提示词",
fallbackPromptPlaceholder: "留空使用系统默认提示词",
},
selector: {
title: "选择智能体",
builtinSection: "内置智能体",
customSection: "我的智能体",
addNew: "添加新智能体",
current: "当前",
},
// 内置智能体信息
builtinInfo: {
quickAnswer: {
name: "快速问答",
description: "基于知识库的 RAG 问答,快速准确地回答问题",
},
smartReasoning: {
name: "智能推理",
description: "ReAct 推理框架,支持多步思考和工具调用",
},
deepResearcher: {
name: "深度研究员",
description: "专注于深度研究和综合分析,能够制定研究计划、多维度检索信息、深入思考并给出全面的分析报告",
},
dataAnalyst: {
name: "数据分析师",
description: "专注于数据库查询和数据分析,能够理解业务需求、构建SQL查询、分析数据并提供洞察",
},
knowledgeGraphExpert: {
name: "知识图谱专家",
description: "专注于知识图谱查询和关系分析,能够探索实体关系、发现隐藏联系并构建知识网络",
},
documentAssistant: {
name: "文档助手",
description: "专注于文档检索和内容整理,能够快速定位文档、提取关键信息并生成摘要",
},
},
},
file: {
upload: "上传文件",
uploadSuccess: "文件上传成功",
@@ -1465,10 +1657,11 @@ export default {
placeholderWithContext: "输入问题,将基于上方选中的知识库/文件回答",
placeholderWebOnly: "输入问题,将结合网络搜索回答",
placeholderKbAndWeb: "输入问题,将基于知识库和网络搜索回答",
agentMode: "Agent 模式",
normalMode: "普通模式",
placeholderAgent: "向 {name} 提问",
agentMode: "智能推理",
normalMode: "快速问答",
normalModeDesc: "基于知识库的 RAG 问答",
agentModeDesc: "ReAct 推理框架,多步思考",
agentModeDesc: "多步思考,深度分析",
agentNotReadyTooltip: "Agent 未就绪,请先在设置中完成配置",
agentNotReadyDetail:
"Agent 未就绪,需要配置以下内容:{reasons}",
@@ -1476,6 +1669,14 @@ export default {
agentMissingSummaryModel: "对话模型(Summary Model)",
agentMissingRerankModel: "重排模型(Rerank Model)",
goToSettings: "前往设置 →",
customAgentNotReadyTooltip: "智能体未就绪,请先完成配置",
customAgentNotReadyDetail: "智能体未就绪,需要配置以下内容:{reasons}",
customAgentMissingSummaryModel: "对话模型(Summary Model)",
customAgentMissingRerankModel: "重排模型(Rerank Model)",
goToAgentEditor: "前往配置 →",
builtinAgentNotReadyDetail: "内置智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",
builtinAgentSettingName: "智能推理",
builtinNormalSettingName: "快速问答",
webSearch: {
toggleOn: "开启网络搜索",
toggleOff: "关闭网络搜索",
@@ -1494,8 +1695,9 @@ export default {
enterContent: "请先输入内容!",
selectKnowledge: "请先选择知识库!",
replying: "正在回复中,请稍后再试!",
agentSwitchedOn: "已切换到 Agent 模式",
agentSwitchedOff: "已切换到普通模式",
agentSwitchedOn: "已切换到智能推理",
agentSwitchedOff: "已切换到快速问答",
agentSelected: "已选择智能体「{name}」",
agentEnabled: "Agent 模式已启用",
agentDisabled: "Agent 模式已禁用",
agentNotReadyDetail:
@@ -1509,6 +1711,14 @@ export default {
stopSuccess: "已停止生成",
stopFailed: "停止失败,请重试",
},
webSearchDisabledByAgent: "当前智能体已禁用网络搜索",
webSearchForcedByAgent: "当前智能体已启用网络搜索,无法关闭",
kbLockedByAgent: "当前智能体已锁定知识库配置",
kbDisabledByAgent: "当前智能体已禁用知识库功能",
cannotRemoveAgentKb: "智能体配置的知识库无法移除",
agentConfiguredKb: "由智能体配置,不可删除",
modelLockedByAgent: "当前智能体已锁定模型配置",
goToAgentSettings: "去设置智能体",
},
agentSettings: {
title: "Agent 配置",
@@ -1568,9 +1778,7 @@ export default {
custom: "自定义 Prompt",
disabledHint: "当前使用系统默认 Prompt,开启自定义后才会应用下方内容。",
placeholder: "请输入系统 Prompt,或留空使用默认 Prompt...",
tabHint: "根据是否启用网络搜索分别配置系统 Prompt。",
tabWebOn: "网络搜索已启用",
tabWebOff: "网络搜索未启用",
tabHint: "统一的系统提示词,使用 {{web_search_status}} 占位符动态控制网络搜索行为",
},
reset: {
header: "恢复默认 Prompt",
@@ -1913,4 +2121,92 @@ export default {
updateFailed: "更新 MCP 服务失败",
},
},
promptTemplate: {
selectTemplate: "选择模板",
useTemplate: "使用模板",
withKnowledgeBase: "知识库",
withWebSearch: "网络搜索",
systemPrompt: {
defaultKB: {
name: "知识库问答助手",
desc: "基础的知识库问答模板,适用于大多数场景",
},
expert: {
name: "领域专家助手",
desc: "专业深入的解答风格,适合技术或专业领域",
},
customerService: {
name: "客服助手",
desc: "友善热情的服务风格,适合客户服务场景",
},
techSupport: {
name: "技术支持",
desc: "专业的技术问题解答,包含代码示例",
},
pureChat: {
name: "通用对话",
desc: "不依赖知识库的通用对话助手",
},
webSearch: {
name: "网络搜索助手",
desc: "结合网络搜索获取最新信息",
},
},
contextTemplate: {
default: {
name: "标准模板",
desc: "基础的上下文模板,清晰展示参考资料和问题",
},
detailed: {
name: "详细模板",
desc: "包含详细说明和回答要求的完整模板",
},
simple: {
name: "简洁模板",
desc: "精简的模板格式,适合简单问答场景",
},
qa: {
name: "问答模板",
desc: "针对问答场景优化的模板",
},
},
rewriteSystem: {
default: {
name: "标准改写",
desc: "消解指代、补全省略的标准改写规则",
},
strict: {
name: "严格改写",
desc: "更严格的改写要求,确保问题完整独立",
},
},
rewriteUser: {
default: {
name: "标准格式",
desc: "包含对话历史和当前问题的标准格式",
},
detailed: {
name: "详细格式",
desc: "带有任务说明的详细格式",
},
},
fallback: {
default: {
name: "标准兜底",
desc: "友好告知无法回答并提供建议",
},
polite: {
name: "礼貌兜底",
desc: "更加礼貌详细的无法回答提示",
},
brief: {
name: "简洁兜底",
desc: "简短的无法回答提示",
},
model: {
name: "模型兜底提示",
desc: "引导模型基于通用知识回答的提示词",
},
},
},
};
+6
View File
@@ -51,6 +51,12 @@ const router = createRouter({
component: () => import("../views/knowledge/KnowledgeBase.vue"),
meta: { requiresInit: true, requiresAuth: true }
},
{
path: "agents",
name: "agentList",
component: () => import("../views/agent/AgentList.vue"),
meta: { requiresInit: true, requiresAuth: true }
},
{
path: "creatChat",
name: "globalCreatChat",
+5 -4
View File
@@ -18,6 +18,7 @@ const createMenuChildren = () => reactive<MenuChild[]>([])
export const useMenuStore = defineStore('menuStore', () => {
const menuArr = reactive<MenuItem[]>([
{ title: '', titleKey: 'menu.knowledgeBase', icon: 'zhishiku', path: 'knowledge-bases' },
{ title: '', titleKey: 'menu.agents', icon: 'agent', path: 'agents' },
{
title: '',
titleKey: 'menu.chat',
@@ -52,14 +53,14 @@ export const useMenuStore = defineStore('menuStore', () => {
)
const clearMenuArr = () => {
const chatMenu = menuArr[1]
const chatMenu = menuArr[2]
if (chatMenu && chatMenu.children) {
chatMenu.children = createMenuChildren()
}
}
const updatemenuArr = (obj: any) => {
const chatMenu = menuArr[1]
const chatMenu = menuArr[2]
if (!chatMenu.children) {
chatMenu.children = createMenuChildren()
}
@@ -70,7 +71,7 @@ export const useMenuStore = defineStore('menuStore', () => {
}
const updataMenuChildren = (item: MenuChild) => {
const chatMenu = menuArr[1]
const chatMenu = menuArr[2]
if (!chatMenu.children) {
chatMenu.children = createMenuChildren()
}
@@ -78,7 +79,7 @@ export const useMenuStore = defineStore('menuStore', () => {
}
const updatasessionTitle = (sessionId: string, title: string) => {
const chatMenu = menuArr[1]
const chatMenu = menuArr[2]
chatMenu.children?.forEach((item: MenuChild) => {
if (item.id === sessionId) {
item.title = title
+43 -7
View File
@@ -1,4 +1,5 @@
import { defineStore } from "pinia";
import { BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from "@/api/agent";
// 定义设置接口
interface Settings {
@@ -13,6 +14,7 @@ interface Settings {
ollamaConfig: OllamaConfig; // Ollama配置
webSearchEnabled: boolean; // 网络搜索是否启用
conversationModels: ConversationModels;
selectedAgentId: string; // 当前选中的智能体ID
}
// Agent 配置接口
@@ -20,9 +22,7 @@ interface AgentConfig {
maxIterations: number;
temperature: number;
allowedTools: string[];
system_prompt_web_enabled?: string;
system_prompt_web_disabled?: string;
use_custom_system_prompt?: boolean;
system_prompt?: string; // Unified system prompt (uses {{web_search_status}} placeholder)
}
interface ConversationModels {
@@ -68,9 +68,7 @@ const defaultSettings: Settings = {
maxIterations: 5,
temperature: 0.7,
allowedTools: [], // 默认为空,需要通过 API 从后端加载
system_prompt_web_enabled: "",
system_prompt_web_disabled: "",
use_custom_system_prompt: false
system_prompt: "",
},
selectedKnowledgeBases: [], // 默认为空数组
selectedFiles: [], // 默认为空数组
@@ -89,7 +87,8 @@ const defaultSettings: Settings = {
summaryModelId: "",
rerankModelId: "",
selectedChatModelId: "", // 用户当前选择的对话模型ID
}
},
selectedAgentId: BUILTIN_QUICK_ANSWER_ID, // 默认选中快速问答模式
};
export const useSettingsStore = defineStore("settings", {
@@ -114,6 +113,16 @@ export const useSettingsStore = defineStore("settings", {
)
},
// 普通模式(快速回答)是否就绪
// 需要满足:1) 设置了对话模型 2) 设置了重排模型
isNormalModeReady: (state) => {
const models = state.settings.conversationModels || defaultSettings.conversationModels
return Boolean(
models.summaryModelId && models.summaryModelId.trim() !== '' &&
models.rerankModelId && models.rerankModelId.trim() !== ''
)
},
// 获取 Agent 配置
agentConfig: (state) => state.settings.agentConfig || defaultSettings.agentConfig,
@@ -124,6 +133,9 @@ export const useSettingsStore = defineStore("settings", {
// 网络搜索是否启用
isWebSearchEnabled: (state) => state.settings.webSearchEnabled || false,
// 当前选中的智能体ID
selectedAgentId: (state) => state.settings.selectedAgentId || BUILTIN_QUICK_ANSWER_ID,
},
actions: {
@@ -301,6 +313,30 @@ export const useSettingsStore = defineStore("settings", {
getSelectedFiles(): string[] {
return this.settings.selectedFiles || [];
},
// 选择智能体
selectAgent(agentId: string) {
this.settings.selectedAgentId = agentId;
// 根据智能体类型自动切换 Agent 模式
if (agentId === BUILTIN_QUICK_ANSWER_ID) {
this.settings.isAgentEnabled = false;
} else if (agentId === BUILTIN_SMART_REASONING_ID) {
this.settings.isAgentEnabled = true;
}
// 自定义智能体需要根据其配置来决定
// 切换智能体时重置知识库和文件选择状态
// 因为不同智能体关联的知识库不同,需要清空用户之前的选择
this.settings.selectedKnowledgeBases = [];
this.settings.selectedFiles = [];
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
},
// 获取选中的智能体ID
getSelectedAgentId(): string {
return this.settings.selectedAgentId || BUILTIN_QUICK_ANSWER_ID;
},
},
});
File diff suppressed because it is too large Load Diff
+894
View File
@@ -0,0 +1,894 @@
<template>
<div class="agent-list-container">
<!-- 头部 -->
<div class="header">
<div class="header-title">
<h2>{{ $t('agent.title') }}</h2>
<p class="header-subtitle">{{ $t('agent.subtitle') }}</p>
</div>
</div>
<div class="header-divider"></div>
<!-- 卡片网格 -->
<div v-if="agents.length > 0" class="agent-card-wrap">
<div
v-for="agent in agents"
:key="agent.id"
class="agent-card"
:class="{
'is-builtin': agent.is_builtin,
'agent-mode-normal': agent.config?.agent_mode === 'quick-answer',
'agent-mode-agent': agent.config?.agent_mode === 'smart-reasoning'
}"
@click="handleCardClick(agent)"
>
<!-- 装饰星星 -->
<div class="card-decoration">
<svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
</svg>
<svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
</svg>
</div>
<!-- 卡片头部 -->
<div class="card-header">
<div class="card-header-left">
<!-- 内置智能体使用简洁图标 -->
<div v-if="agent.is_builtin" class="builtin-avatar" :class="agent.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'">
<t-icon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="18px" />
</div>
<!-- 自定义智能体使用 AgentAvatar -->
<AgentAvatar v-else :name="agent.name" size="medium" />
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
</div>
<t-popup
v-model="agent.showMore"
overlayClassName="card-more-popup"
:on-visible-change="(visible: boolean) => onVisibleChange(visible, agent)"
trigger="click"
destroy-on-close
placement="bottom-right"
>
<div
class="more-wrap"
@click.stop
:class="{ 'active-more': agent.showMore }"
>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
</div>
<template #content>
<div class="popup-menu">
<div class="popup-menu-item" @click="handleEdit(agent)">
<t-icon class="menu-icon" name="edit" />
<span>{{ $t('common.edit') }}</span>
</div>
<div class="popup-menu-item" @click="handleCopy(agent)">
<t-icon class="menu-icon" name="file-copy" />
<span>{{ $t('common.copy') }}</span>
</div>
<div v-if="!agent.is_builtin" class="popup-menu-item delete" @click="handleDelete(agent)">
<t-icon class="menu-icon" name="delete" />
<span>{{ $t('common.delete') }}</span>
</div>
</div>
</template>
</t-popup>
</div>
<!-- 卡片内容 -->
<div class="card-content">
<div class="card-description">
{{ agent.description || $t('agent.noDescription') }}
</div>
</div>
<!-- 卡片底部 -->
<div class="card-bottom">
<div class="bottom-left">
<div class="feature-badges">
<t-tooltip :content="agent.config?.agent_mode === 'smart-reasoning' ? $t('agent.mode.agent') : $t('agent.mode.normal')" placement="top">
<div class="feature-badge" :class="{ 'mode-normal': agent.config?.agent_mode === 'quick-answer', 'mode-agent': agent.config?.agent_mode === 'smart-reasoning' }">
<t-icon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="14px" />
</div>
</t-tooltip>
<t-tooltip v-if="agent.config?.web_search_enabled" :content="$t('agent.features.webSearch')" placement="top">
<div class="feature-badge web-search">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.2" fill="none"/>
<ellipse cx="8" cy="8" rx="2.5" ry="6" stroke="currentColor" stroke-width="1.2" fill="none"/>
<line x1="2" y1="6" x2="14" y2="6" stroke="currentColor" stroke-width="1.2"/>
<line x1="2" y1="10" x2="14" y2="10" stroke="currentColor" stroke-width="1.2"/>
</svg>
</div>
</t-tooltip>
<t-tooltip v-if="agent.config?.knowledge_bases?.length || agent.config?.kb_selection_mode === 'all'" :content="$t('agent.features.knowledgeBase')" placement="top">
<div class="feature-badge knowledge">
<t-icon name="folder" size="16px" />
</div>
</t-tooltip>
<t-tooltip v-if="agent.config?.mcp_services?.length || agent.config?.mcp_selection_mode === 'all'" :content="$t('agent.features.mcp')" placement="top">
<div class="feature-badge mcp">
<t-icon name="extension" size="16px" />
</div>
</t-tooltip>
<t-tooltip v-if="agent.config?.multi_turn_enabled" :content="$t('agent.features.multiTurn')" placement="top">
<div class="feature-badge multi-turn">
<t-icon name="chat-bubble" size="16px" />
</div>
</t-tooltip>
</div>
</div>
<div v-if="agent.is_builtin" class="builtin-badge">
<t-icon name="lock-on" size="12px" />
<span>{{ $t('agent.builtin') }}</span>
</div>
<span v-else-if="agent.updated_at" class="card-time">{{ formatDate(agent.updated_at) }}</span>
</div>
</div>
</div>
<!-- 空状态 -->
<div v-else-if="!loading" class="empty-state">
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
<span class="empty-txt">{{ $t('agent.empty.title') }}</span>
<span class="empty-desc">{{ $t('agent.empty.description') }}</span>
</div>
<!-- 删除确认对话框 -->
<t-dialog
v-model:visible="deleteVisible"
dialogClassName="del-agent-dialog"
:closeBtn="false"
:cancelBtn="null"
:confirmBtn="null"
>
<div class="circle-wrap">
<div class="dialog-header">
<img class="circle-img" src="@/assets/img/circle.png" alt="">
<span class="circle-title">{{ $t('agent.delete.confirmTitle') }}</span>
</div>
<span class="del-circle-txt">
{{ $t('agent.delete.confirmMessage', { name: deletingAgent?.name ?? '' }) }}
</span>
<div class="circle-btn">
<span class="circle-btn-txt" @click="deleteVisible = false">{{ $t('common.cancel') }}</span>
<span class="circle-btn-txt confirm" @click="confirmDelete">{{ $t('agent.delete.confirmButton') }}</span>
</div>
</div>
</t-dialog>
<!-- 智能体编辑器弹窗 -->
<AgentEditorModal
:visible="editorVisible"
:mode="editorMode"
:agent="editingAgent"
:initialSection="editorInitialSection"
@update:visible="editorVisible = $event"
@success="handleEditorSuccess"
/>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
import { listAgents, deleteAgent, copyAgent, type CustomAgent } from '@/api/agent'
import { formatStringDate } from '@/utils/index'
import { useI18n } from 'vue-i18n'
import AgentEditorModal from './AgentEditorModal.vue'
import AgentAvatar from '@/components/AgentAvatar.vue'
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
interface AgentWithUI extends CustomAgent {
showMore?: boolean
}
const agents = ref<AgentWithUI[]>([])
const loading = ref(false)
const deleteVisible = ref(false)
const deletingAgent = ref<AgentWithUI | null>(null)
const editorVisible = ref(false)
const editorMode = ref<'create' | 'edit'>('create')
const editingAgent = ref<CustomAgent | null>(null)
const editorInitialSection = ref<string>('basic')
const fetchList = () => {
loading.value = true
return listAgents().then((res: any) => {
const data = res.data || []
// 显示所有智能体(包括内置智能体)
agents.value = data.map((agent: CustomAgent) => ({
...agent,
showMore: false
}))
// 检查 URL 中是否有 edit 参数,如果有则打开对应智能体的编辑模态框
checkAndOpenEditModal()
}).finally(() => loading.value = false)
}
// 检查 URL 参数并打开编辑模态框
const checkAndOpenEditModal = () => {
const editId = route.query.edit as string
const section = route.query.section as string
if (editId) {
const agent = agents.value.find(a => a.id === editId)
if (agent) {
editingAgent.value = agent
editorMode.value = 'edit'
editorInitialSection.value = section || 'basic'
editorVisible.value = true
}
// 清除 URL 中的参数
router.replace({ path: route.path, query: {} })
}
}
// 监听菜单创建智能体事件
const handleOpenAgentEditor = (event: CustomEvent) => {
if (event.detail?.mode === 'create') {
openCreateModal()
}
}
onMounted(() => {
fetchList()
window.addEventListener('openAgentEditor', handleOpenAgentEditor as EventListener)
})
onUnmounted(() => {
window.removeEventListener('openAgentEditor', handleOpenAgentEditor as EventListener)
})
const onVisibleChange = (visible: boolean, agent: AgentWithUI) => {
if (!visible) {
agent.showMore = false
}
}
const handleCardClick = (agent: AgentWithUI) => {
// 如果弹窗正在显示,不触发编辑
if (agent.showMore) {
return
}
// 点击卡片编辑(包括内置智能体)
handleEdit(agent)
}
const handleEdit = (agent: AgentWithUI) => {
agent.showMore = false
editingAgent.value = agent
editorMode.value = 'edit'
editorVisible.value = true
}
const handleDelete = (agent: AgentWithUI) => {
agent.showMore = false
deletingAgent.value = agent
deleteVisible.value = true
}
const handleCopy = (agent: AgentWithUI) => {
agent.showMore = false
copyAgent(agent.id).then((res: any) => {
if (res.data) {
MessagePlugin.success(t('agent.messages.copied'))
fetchList()
} else {
MessagePlugin.error(res.message || t('agent.messages.copyFailed'))
}
}).catch((e: any) => {
MessagePlugin.error(e?.message || t('agent.messages.copyFailed'))
})
}
const confirmDelete = () => {
if (!deletingAgent.value) return
deleteAgent(deletingAgent.value.id).then((res: any) => {
if (res.success) {
MessagePlugin.success(t('agent.messages.deleted'))
deleteVisible.value = false
deletingAgent.value = null
fetchList()
} else {
MessagePlugin.error(res.message || t('agent.messages.deleteFailed'))
}
}).catch((e: any) => {
MessagePlugin.error(e?.message || t('agent.messages.deleteFailed'))
})
}
const handleEditorSuccess = () => {
editorVisible.value = false
editingAgent.value = null
fetchList()
}
const formatDate = (dateStr: string) => {
if (!dateStr) return ''
return formatStringDate(new Date(dateStr))
}
// 暴露创建方法供外部调用
const openCreateModal = () => {
editingAgent.value = null
editorMode.value = 'create'
editorVisible.value = true
}
defineExpose({
openCreateModal
})
</script>
<style scoped lang="less">
.agent-list-container {
padding: 24px 44px;
margin: 0 20px;
height: calc(100vh);
overflow-y: auto;
box-sizing: border-box;
flex: 1;
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.header-title {
display: flex;
flex-direction: column;
gap: 4px;
}
h2 {
margin: 0;
color: #000000e6;
font-family: "PingFang SC";
font-size: 24px;
font-weight: 600;
line-height: 32px;
}
}
.header-subtitle {
margin: 0;
color: #00000099;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 20px;
}
.header-divider {
height: 1px;
background: #e7ebf0;
margin-bottom: 20px;
}
.agent-card-wrap {
display: grid;
gap: 16px;
grid-template-columns: 1fr;
}
.agent-card {
border: 1px solid #f0f0f0;
border-radius: 12px;
overflow: hidden;
box-sizing: border-box;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
background: #fff;
position: relative;
cursor: pointer;
transition: all 0.25s ease;
padding: 16px 18px;
display: flex;
flex-direction: column;
height: 160px;
&:hover {
border-color: #07c05f;
box-shadow: 0 4px 12px rgba(7, 192, 95, 0.12);
}
// 普通模式样式
&.agent-mode-normal {
background: linear-gradient(135deg, #ffffff 0%, #f8fcfa 100%);
border-color: #e8f5ed;
&:hover {
border-color: #07c05f;
background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}
.card-decoration {
color: rgba(7, 192, 95, 0.35);
}
&:hover .card-decoration {
color: rgba(7, 192, 95, 0.5);
}
}
// Agent 模式样式
&.agent-mode-agent {
background: linear-gradient(135deg, #ffffff 0%, #f8f5ff 100%);
border-color: #ede8ff;
&:hover {
border-color: #7c4dff;
box-shadow: 0 4px 12px rgba(124, 77, 255, 0.12);
background: linear-gradient(135deg, #ffffff 0%, #f3efff 100%);
}
.card-decoration {
color: rgba(124, 77, 255, 0.35);
}
&:hover .card-decoration {
color: rgba(124, 77, 255, 0.5);
}
}
// 确保内容在装饰之上
.card-header,
.card-content,
.card-bottom {
position: relative;
z-index: 1;
}
}
.card-decoration {
position: absolute;
top: 12px;
right: 50px;
display: flex;
align-items: flex-start;
gap: 4px;
pointer-events: none;
z-index: 0;
transition: color 0.25s ease;
.star-icon {
opacity: 0.9;
&.small {
margin-top: 14px;
opacity: 0.7;
}
}
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.card-header-left {
display: flex;
align-items: center;
gap: 10px;
flex: 1;
min-width: 0;
}
.card-title {
color: #1a1a1a;
font-family: "PingFang SC";
font-size: 15px;
font-weight: 600;
line-height: 22px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
}
.builtin-badge {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 2px 8px;
border-radius: 10px;
background: rgba(0, 0, 0, 0.04);
color: #666;
font-family: "PingFang SC";
font-size: 11px;
font-weight: 500;
flex-shrink: 0;
}
.builtin-avatar {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 8px;
flex-shrink: 0;
&.normal {
background: linear-gradient(135deg, rgba(7, 192, 95, 0.15) 0%, rgba(7, 192, 95, 0.08) 100%);
color: #059669;
}
&.agent {
background: linear-gradient(135deg, rgba(124, 77, 255, 0.15) 0%, rgba(124, 77, 255, 0.08) 100%);
color: #7c4dff;
}
}
.edit-btn {
display: flex;
width: 32px;
height: 32px;
justify-content: center;
align-items: center;
border-radius: 6px;
cursor: pointer;
flex-shrink: 0;
transition: all 0.2s ease;
color: #00000066;
&:hover {
background: rgba(0, 0, 0, 0.06);
color: #07c05f;
}
}
.more-wrap {
display: flex;
width: 28px;
height: 28px;
justify-content: center;
align-items: center;
border-radius: 6px;
cursor: pointer;
flex-shrink: 0;
transition: all 0.2s ease;
opacity: 0;
.agent-card:hover & {
opacity: 0.6;
}
&:hover {
background: rgba(0, 0, 0, 0.05);
opacity: 1 !important;
}
&.active-more {
background: rgba(0, 0, 0, 0.06);
opacity: 1 !important;
}
.more-icon {
width: 16px;
height: 16px;
}
}
.card-content {
flex: 1;
margin-bottom: 12px;
overflow: hidden;
}
.card-description {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
color: #666;
font-family: "PingFang SC";
font-size: 13px;
font-weight: 400;
line-height: 20px;
}
.card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: auto;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
}
.bottom-left {
display: flex;
align-items: center;
gap: 8px;
}
.feature-badges {
display: flex;
align-items: center;
gap: 4px;
}
.feature-badge {
display: flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
border-radius: 6px;
cursor: default;
transition: background 0.2s ease;
&.mode-normal {
background: rgba(7, 192, 95, 0.08);
color: #059669;
&:hover {
background: rgba(7, 192, 95, 0.12);
}
}
&.mode-agent {
background: rgba(124, 77, 255, 0.08);
color: #7c4dff;
&:hover {
background: rgba(124, 77, 255, 0.12);
}
}
&.web-search {
background: rgba(255, 152, 0, 0.08);
color: #f59e0b;
&:hover {
background: rgba(255, 152, 0, 0.12);
}
}
&.knowledge {
background: rgba(7, 192, 95, 0.08);
color: #059669;
&:hover {
background: rgba(7, 192, 95, 0.12);
}
}
&.mcp {
background: rgba(236, 72, 153, 0.08);
color: #ec4899;
&:hover {
background: rgba(236, 72, 153, 0.12);
}
}
&.multi-turn {
background: rgba(59, 130, 246, 0.08);
color: #3b82f6;
&:hover {
background: rgba(59, 130, 246, 0.12);
}
}
}
.card-time {
color: #999;
font-family: "PingFang SC";
font-size: 12px;
font-weight: 400;
}
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 60px 20px;
.empty-img {
width: 162px;
height: 162px;
margin-bottom: 20px;
}
.empty-txt {
color: #00000099;
font-family: "PingFang SC";
font-size: 16px;
font-weight: 600;
line-height: 26px;
margin-bottom: 8px;
}
.empty-desc {
color: #00000066;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 22px;
}
}
// 响应式布局
@media (min-width: 900px) {
.agent-card-wrap {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1250px) {
.agent-card-wrap {
grid-template-columns: repeat(3, 1fr);
}
}
@media (min-width: 1600px) {
.agent-card-wrap {
grid-template-columns: repeat(4, 1fr);
}
}
// 删除确认对话框样式
:deep(.del-agent-dialog) {
padding: 0px !important;
border-radius: 6px !important;
.t-dialog__header {
display: none;
}
.t-dialog__body {
padding: 16px;
}
.t-dialog__footer {
padding: 0;
}
}
:deep(.t-dialog__position.t-dialog--top) {
padding-top: 40vh !important;
}
.circle-wrap {
.dialog-header {
display: flex;
align-items: center;
margin-bottom: 8px;
}
.circle-img {
width: 20px;
height: 20px;
margin-right: 8px;
}
.circle-title {
color: #000000e6;
font-family: "PingFang SC";
font-size: 16px;
font-weight: 600;
line-height: 24px;
}
.del-circle-txt {
color: #00000099;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 22px;
display: inline-block;
margin-left: 29px;
margin-bottom: 21px;
}
.circle-btn {
height: 22px;
width: 100%;
display: flex;
justify-content: flex-end;
}
.circle-btn-txt {
color: #000000e6;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 22px;
cursor: pointer;
&:hover {
opacity: 0.8;
}
}
.confirm {
color: #FA5151;
margin-left: 40px;
&:hover {
opacity: 0.8;
}
}
}
</style>
<style lang="less">
// 更多操作弹窗样式
.card-more-popup {
z-index: 99 !important;
.t-popup__content {
padding: 6px 0 !important;
margin-top: 6px !important;
min-width: 140px;
border-radius: 6px !important;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1) !important;
border: 1px solid #e7ebf0 !important;
}
}
.popup-menu {
display: flex;
flex-direction: column;
}
.popup-menu-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 16px;
cursor: pointer;
transition: all 0.2s ease;
color: #000000e6;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 20px;
.menu-icon {
font-size: 16px;
flex-shrink: 0;
color: #00000099;
transition: color 0.2s ease;
}
&:hover {
background: #f7f9fc;
.menu-icon {
color: #000000e6;
}
}
&.delete {
color: #000000e6;
&:hover {
background: #fff1f0;
color: #fa5151;
.menu-icon {
color: #fa5151;
}
}
}
}
</style>
+3
View File
@@ -314,6 +314,8 @@ const sendMsg = async (value, modelId = '', mentionedItems = []) => {
const kbIds = useSettingsStoreInstance.settings.selectedKnowledgeBases || [];
const knowledgeIds = useSettingsStoreInstance.settings.selectedFiles || [];
// Get selected agent ID
const selectedAgentId = useSettingsStoreInstance.selectedAgentId || '';
// Use agent-chat endpoint when agent is enabled, otherwise use knowledge-chat
@@ -327,6 +329,7 @@ const sendMsg = async (value, modelId = '', mentionedItems = []) => {
knowledge_base_ids: kbIds,
knowledge_ids: knowledgeIds,
agent_enabled: agentEnabled,
agent_id: selectedAgentId, // 传递选中的智能体 ID
web_search_enabled: webSearchEnabled,
summary_model_id: modelId,
mcp_service_ids: mcpServiceIds,
+101 -102
View File
@@ -116,23 +116,14 @@
<!-- 卡片底部 -->
<div class="card-bottom">
<div class="bottom-left">
<div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }">
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" size="14px" />
<span>
{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}
({{ kb.type === 'faq' ? (kb.chunk_count || 0) : (kb.knowledge_count || 0) }})
</span>
<t-tooltip
v-if="kb.isProcessing"
:content="kb.type === 'document' && (kb.processing_count || 0) > 0
? $t('knowledgeList.processingDocuments', { count: kb.processing_count || 0 })
: $t('knowledgeList.processing')"
placement="top"
>
<t-icon name="loading" size="14px" class="processing-icon" />
</t-tooltip>
</div>
<div class="feature-badges">
<t-tooltip :content="kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument')" placement="top">
<div class="feature-badge" :class="{ 'type-document': (kb.type || 'document') === 'document', 'type-faq': kb.type === 'faq' }">
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" size="14px" />
<span class="badge-count">{{ kb.type === 'faq' ? (kb.chunk_count || 0) : (kb.knowledge_count || 0) }}</span>
<t-icon v-if="kb.isProcessing" name="loading" size="12px" class="processing-icon" />
</div>
</t-tooltip>
<t-tooltip v-if="kb.extract_config?.enabled" :content="$t('knowledgeList.features.knowledgeGraph')" placement="top">
<div class="feature-badge kg">
<t-icon name="relation" size="14px" />
@@ -700,27 +691,28 @@ const handleUploadFinishedEvent = (event: Event) => {
.kb-card-wrap {
display: grid;
gap: 20px;
gap: 16px;
grid-template-columns: 1fr;
}
.kb-card {
border: 2px solid #fbfbfb;
border-radius: 6px;
border: 1px solid #f0f0f0;
border-radius: 12px;
overflow: hidden;
box-sizing: border-box;
box-shadow: 0 0 8px 0 #00000005;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
background: #fff;
position: relative;
cursor: pointer;
transition: all 0.2s ease;
padding: 12px 16px 14px;
transition: all 0.25s ease;
padding: 16px 18px;
display: flex;
flex-direction: column;
min-height: 150px;
height: 160px;
&:hover {
border-color: #07c05f;
box-shadow: 0 4px 12px rgba(7, 192, 95, 0.12);
}
&.uninitialized {
@@ -731,12 +723,12 @@ const handleUploadFinishedEvent = (event: Event) => {
&.kb-type-document {
background: linear-gradient(135deg, #ffffff 0%, #f8fcfa 100%);
border-color: #e8f5ed;
&:hover {
border-color: #07c05f;
background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}
// 右上角装饰
&::after {
content: '';
@@ -746,7 +738,7 @@ const handleUploadFinishedEvent = (event: Event) => {
width: 60px;
height: 60px;
background: linear-gradient(135deg, rgba(7, 192, 95, 0.08) 0%, transparent 100%);
border-radius: 0 6px 0 100%;
border-radius: 0 12px 0 100%;
pointer-events: none;
z-index: 0;
}
@@ -756,12 +748,13 @@ const handleUploadFinishedEvent = (event: Event) => {
&.kb-type-faq {
background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
border-color: #e6f0ff;
&:hover {
border-color: #0052d9;
box-shadow: 0 4px 12px rgba(0, 82, 217, 0.12);
background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
}
// 右上角装饰
&::after {
content: '';
@@ -771,7 +764,7 @@ const handleUploadFinishedEvent = (event: Event) => {
width: 60px;
height: 60px;
background: linear-gradient(135deg, rgba(0, 82, 217, 0.08) 0%, transparent 100%);
border-radius: 0 6px 0 100%;
border-radius: 0 12px 0 100%;
pointer-events: none;
z-index: 0;
}
@@ -790,42 +783,46 @@ const handleUploadFinishedEvent = (event: Event) => {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
margin-bottom: 10px;
}
.card-title {
color: #000000e6;
color: #1a1a1a;
font-family: "PingFang SC";
font-size: 14px;
font-size: 15px;
font-weight: 600;
line-height: 22px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
margin-right: 8px;
min-width: 0;
}
.more-wrap {
display: flex;
width: 32px;
height: 32px;
width: 28px;
height: 28px;
justify-content: center;
align-items: center;
border-radius: 6px;
cursor: pointer;
flex-shrink: 0;
transition: all 0.2s ease;
opacity: 0.7;
opacity: 0;
.kb-card:hover & {
opacity: 0.6;
}
&:hover {
background: rgba(0, 0, 0, 0.06);
opacity: 1;
background: rgba(0, 0, 0, 0.05);
opacity: 1 !important;
}
&.active-more {
background: rgba(0, 0, 0, 0.08);
opacity: 1;
background: rgba(0, 0, 0, 0.06);
opacity: 1 !important;
}
.more-icon {
@@ -836,7 +833,8 @@ const handleUploadFinishedEvent = (event: Event) => {
.card-content {
flex: 1;
margin-bottom: 10px;
margin-bottom: 12px;
overflow: hidden;
}
.card-description {
@@ -845,21 +843,20 @@ const handleUploadFinishedEvent = (event: Event) => {
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
color: #00000066;
color: #666;
font-family: "PingFang SC";
font-size: 12px;
font-size: 13px;
font-weight: 400;
line-height: 20px;
min-height: 40px;
}
.card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 0 0;
border-top: 1px solid #f0f0f0;
margin-top: auto;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
}
.bottom-left {
@@ -868,88 +865,90 @@ const handleUploadFinishedEvent = (event: Event) => {
gap: 8px;
}
.type-badge {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 3px 10px;
border-radius: 4px;
font-family: "PingFang SC";
font-size: 12px;
font-weight: 500;
line-height: 18px;
&.document {
background: rgba(7, 192, 95, 0.1);
color: #059669;
border: 1px solid rgba(7, 192, 95, 0.2);
}
&.faq {
background: rgba(0, 82, 217, 0.1);
color: #0052d9;
border: 1px solid rgba(0, 82, 217, 0.2);
}
.processing-icon {
animation: spin 1s linear infinite;
margin-left: 4px;
}
&.document .processing-icon {
color: #059669;
}
&.faq .processing-icon {
color: #0052d9;
}
}
.feature-badges {
display: flex;
align-items: center;
gap: 6px;
gap: 4px;
}
.feature-badge {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border-radius: 4px;
cursor: pointer;
width: 26px;
height: 26px;
border-radius: 6px;
cursor: default;
transition: background 0.2s ease;
&.kg {
background: rgba(124, 77, 255, 0.1);
color: #7c4dff;
border: 1px solid rgba(124, 77, 255, 0.2);
&.type-document {
background: rgba(7, 192, 95, 0.08);
color: #059669;
width: auto;
padding: 0 8px;
gap: 4px;
&:hover {
background: rgba(124, 77, 255, 0.15);
background: rgba(7, 192, 95, 0.12);
}
.badge-count {
font-size: 12px;
font-weight: 500;
}
.processing-icon {
animation: spin 1s linear infinite;
}
}
&.type-faq {
background: rgba(0, 82, 217, 0.08);
color: #0052d9;
width: auto;
padding: 0 8px;
gap: 4px;
&:hover {
background: rgba(0, 82, 217, 0.12);
}
.badge-count {
font-size: 12px;
font-weight: 500;
}
.processing-icon {
animation: spin 1s linear infinite;
}
}
&.kg {
background: rgba(124, 77, 255, 0.08);
color: #7c4dff;
&:hover {
background: rgba(124, 77, 255, 0.12);
}
}
&.multimodal {
background: rgba(255, 152, 0, 0.1);
color: #ff9800;
border: 1px solid rgba(255, 152, 0, 0.2);
background: rgba(255, 152, 0, 0.08);
color: #f59e0b;
&:hover {
background: rgba(255, 152, 0, 0.15);
background: rgba(255, 152, 0, 0.12);
}
}
&.question {
background: rgba(0, 150, 136, 0.1);
background: rgba(0, 150, 136, 0.08);
color: #009688;
border: 1px solid rgba(0, 150, 136, 0.2);
&:hover {
background: rgba(0, 150, 136, 0.15);
background: rgba(0, 150, 136, 0.12);
}
}
}
@keyframes spin {
@@ -986,7 +985,7 @@ const handleUploadFinishedEvent = (event: Event) => {
}
.card-time {
color: #00000066;
color: #999;
font-family: "PingFang SC";
font-size: 12px;
font-weight: 400;
+174 -255
View File
@@ -4,6 +4,10 @@
<div class="section-header">
<h2>{{ $t('settings.conversationStrategy') }}</h2>
<p class="section-description">{{ $t('conversationSettings.description') }}</p>
<div class="global-config-notice">
<t-icon name="info-circle" />
<span>这些是全局默认配置,新建智能体时会继承这些设置。您也可以在智能体列表中单独配置每个智能体。</span>
</div>
</div>
<t-tabs v-model="activeTab" class="conversation-tabs">
@@ -146,17 +150,7 @@
</div>
<div class="setting-control full-width" style="position: relative;">
<div class="prompt-header">
<div class="prompt-toggle">
<span class="prompt-toggle-label">{{ $t('agentSettings.systemPrompt.custom') }}</span>
<t-switch
v-model="localUseCustomSystemPrompt"
:label="[$t('common.off'), $t('common.on')]"
size="large"
@change="handleUseCustomPromptToggle"
/>
</div>
<t-button
v-if="localUseCustomSystemPrompt"
theme="default"
variant="outline"
size="small"
@@ -167,54 +161,32 @@
</t-button>
</div>
<p class="prompt-tab-hint">
{{ $t('agentSettings.systemPrompt.tabHint') }}
{{ $t('agentSettings.systemPrompt.tabHint') }}(留空则使用系统默认,使用 {{web_search_status}} 占位符动态控制网络搜索行为)
</p>
<p v-if="!localUseCustomSystemPrompt" class="prompt-disabled-hint">
{{ $t('agentSettings.systemPrompt.disabledHint') }}
</p>
<div v-if="localUseCustomSystemPrompt" class="system-prompt-tabs">
<t-tabs
v-model="activeSystemPromptTab"
class="system-prompt-variant-tabs"
>
<t-tab-panel value="web-enabled" :label="$t('agentSettings.systemPrompt.tabWebOn')">
<div v-if="activeSystemPromptTab === 'web-enabled'" class="prompt-textarea-wrapper">
<t-textarea
ref="promptTextareaRef"
v-model="localSystemPromptWebEnabled"
:autosize="{ minRows: 15, maxRows: 30 }"
:placeholder="$t('agentSettings.systemPrompt.placeholder')"
@blur="handleSystemPromptChange('web-enabled', $event)"
@input="handlePromptInput"
@keydown="handlePromptKeydown"
:readonly="!localUseCustomSystemPrompt"
:class="{ 'prompt-textarea-readonly': !localUseCustomSystemPrompt }"
style="width: 100%; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 13px;"
/>
</div>
</t-tab-panel>
<t-tab-panel value="web-disabled" :label="$t('agentSettings.systemPrompt.tabWebOff')">
<div v-if="activeSystemPromptTab === 'web-disabled'" class="prompt-textarea-wrapper">
<t-textarea
ref="promptTextareaRef"
v-model="localSystemPromptWebDisabled"
:autosize="{ minRows: 15, maxRows: 30 }"
:placeholder="$t('agentSettings.systemPrompt.placeholder')"
@blur="handleSystemPromptChange('web-disabled', $event)"
@input="handlePromptInput"
@keydown="handlePromptKeydown"
:readonly="!localUseCustomSystemPrompt"
:class="{ 'prompt-textarea-readonly': !localUseCustomSystemPrompt }"
style="width: 100%; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 13px;"
/>
</div>
</t-tab-panel>
</t-tabs>
<div class="system-prompt-tabs">
<div class="prompt-textarea-wrapper textarea-with-template">
<t-textarea
ref="promptTextareaRef"
v-model="localSystemPrompt"
:autosize="{ minRows: 15, maxRows: 30 }"
:placeholder="$t('agentSettings.systemPrompt.placeholder')"
@blur="handleSystemPromptChange"
@input="handlePromptInput"
@keydown="handlePromptKeydown"
style="width: 100%; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 13px;"
/>
<PromptTemplateSelector
type="systemPrompt"
position="corner"
:hasKnowledgeBase="true"
@select="handleAgentSystemPromptTemplateSelect"
/>
</div>
</div>
<!-- 占位符提示下拉框 -->
<teleport to="body">
<div
v-if="localUseCustomSystemPrompt && showPlaceholderPopup && filteredPlaceholders.length > 0"
v-if="showPlaceholderPopup && filteredPlaceholders.length > 0"
class="placeholder-popup-wrapper"
:style="popupStyle"
>
@@ -249,24 +221,10 @@
<div class="setting-row vertical">
<div class="setting-info">
<label>{{ $t('conversationSettings.systemPrompt.label') }}</label>
<p class="desc">{{ $t('conversationSettings.systemPrompt.desc') }}</p>
<p class="desc">{{ $t('conversationSettings.systemPrompt.desc') }}(留空则使用系统默认)</p>
</div>
<div class="setting-control full-width">
<div class="prompt-header">
<div class="prompt-toggle">
<span class="prompt-toggle-label">{{ $t('conversationSettings.systemPrompt.custom') }}</span>
<t-switch
v-model="localUseCustomSystemPromptNormal"
:label="[$t('common.off'), $t('common.on')]"
size="large"
@change="handleUseCustomSystemPromptNormalToggle"
/>
</div>
</div>
<p v-if="!localUseCustomSystemPromptNormal" class="prompt-disabled-hint">
{{ $t('conversationSettings.systemPrompt.disabledHint') }}
</p>
<div v-if="localUseCustomSystemPromptNormal" class="prompt-textarea-wrapper">
<div class="prompt-textarea-wrapper textarea-with-template">
<t-textarea
v-model="localSystemPromptNormal"
:autosize="{ minRows: 10, maxRows: 20 }"
@@ -274,32 +232,24 @@
@blur="handleSystemPromptNormalChange"
style="width: 100%; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 13px;"
/>
<PromptTemplateSelector
type="systemPrompt"
position="corner"
:hasKnowledgeBase="true"
@select="handleNormalSystemPromptTemplateSelect"
/>
</div>
</div>
</div>
<!-- Context Template(普通模式,自定义开关) -->
<!-- Context Template(普通模式) -->
<div class="setting-row vertical">
<div class="setting-info">
<label>{{ $t('conversationSettings.contextTemplate.label') }}</label>
<p class="desc">{{ $t('conversationSettings.contextTemplate.desc') }}</p>
<p class="desc">{{ $t('conversationSettings.contextTemplate.desc') }}(留空则使用系统默认)</p>
</div>
<div class="setting-control full-width">
<div class="prompt-header">
<div class="prompt-toggle">
<span class="prompt-toggle-label">{{ $t('conversationSettings.contextTemplate.custom') }}</span>
<t-switch
v-model="localUseCustomContextTemplate"
:label="[$t('common.off'), $t('common.on')]"
size="large"
@change="handleUseCustomContextTemplateToggle"
/>
</div>
</div>
<p v-if="!localUseCustomContextTemplate" class="prompt-disabled-hint">
{{ $t('conversationSettings.contextTemplate.disabledHint') }}
</p>
<div v-if="localUseCustomContextTemplate" class="prompt-textarea-wrapper">
<div class="prompt-textarea-wrapper textarea-with-template">
<t-textarea
v-model="localContextTemplate"
:autosize="{ minRows: 15, maxRows: 30 }"
@@ -307,6 +257,12 @@
@blur="handleContextTemplateChange"
style="width: 100%; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 13px;"
/>
<PromptTemplateSelector
type="contextTemplate"
position="corner"
:hasKnowledgeBase="true"
@select="handleContextTemplateTemplateSelect"
/>
</div>
</div>
</div>
@@ -540,11 +496,18 @@
<p class="desc">{{ $t('conversationSettings.rewritePrompt.desc') }}</p>
</div>
<div class="setting-control full-width">
<t-textarea
v-model="localRewritePromptSystem"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleRewritePromptSystemChange"
/>
<div class="textarea-with-template">
<t-textarea
v-model="localRewritePromptSystem"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleRewritePromptSystemChange"
/>
<PromptTemplateSelector
type="rewriteSystem"
position="corner"
@select="handleRewriteSystemTemplateSelect"
/>
</div>
</div>
</div>
@@ -554,11 +517,18 @@
<p class="desc">{{ $t('conversationSettings.rewritePrompt.userDesc') }}</p>
</div>
<div class="setting-control full-width">
<t-textarea
v-model="localRewritePromptUser"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleRewritePromptUserChange"
/>
<div class="textarea-with-template">
<t-textarea
v-model="localRewritePromptUser"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleRewritePromptUserChange"
/>
<PromptTemplateSelector
type="rewriteUser"
position="corner"
@select="handleRewriteUserTemplateSelect"
/>
</div>
</div>
</div>
@@ -583,26 +553,40 @@
<p class="desc">{{ $t('conversationSettings.fallbackResponse.desc') }}</p>
</div>
<div class="setting-control full-width">
<t-textarea
v-model="localFallbackResponse"
:autosize="{ minRows: 3, maxRows: 6 }"
@blur="handleFallbackResponseChange"
/>
<div class="textarea-with-template">
<t-textarea
v-model="localFallbackResponse"
:autosize="{ minRows: 3, maxRows: 6 }"
@blur="handleFallbackResponseChange"
/>
<PromptTemplateSelector
type="fallback"
position="corner"
@select="handleFallbackResponseTemplateSelect"
/>
</div>
</div>
</div>
<!-- 兜底 Prompt:仅在选择“交给模型继续生成”时展示 -->
<!-- 兜底 Prompt:仅在选择"交给模型继续生成"时展示 -->
<div v-else-if="localFallbackStrategy === 'model'" class="setting-row vertical">
<div class="setting-info">
<label>{{ $t('conversationSettings.fallbackPrompt.label') }}</label>
<p class="desc">{{ $t('conversationSettings.fallbackPrompt.desc') }}</p>
</div>
<div class="setting-control full-width">
<t-textarea
v-model="localFallbackPrompt"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleFallbackPromptChange"
/>
<div class="textarea-with-template">
<t-textarea
v-model="localFallbackPrompt"
:autosize="{ minRows: 8, maxRows: 16 }"
@blur="handleFallbackPromptChange"
/>
<PromptTemplateSelector
type="fallback"
position="corner"
@select="handleFallbackPromptTemplateSelect"
/>
</div>
</div>
</div>
@@ -659,6 +643,7 @@ import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
import { listModels, type ModelConfig } from '@/api/model'
import { getAgentConfig, updateAgentConfig, getConversationConfig, updateConversationConfig, type AgentConfig, type ConversationConfig, type ToolDefinition, type PlaceholderDefinition } from '@/api/system'
import PromptTemplateSelector from '@/components/PromptTemplateSelector.vue'
const props = defineProps<{
// 来自外部设置弹窗的子菜单 key: 'modes' | 'models' | 'thresholds' | 'advanced'
@@ -680,8 +665,6 @@ const getDefaultConversationConfig = (): ConversationConfig => ({
context_template: '',
temperature: 0.3,
max_completion_tokens: 2048,
use_custom_system_prompt: true,
use_custom_context_template: true,
max_rounds: 5,
embedding_top_k: 10,
keyword_threshold: 0.3,
@@ -713,21 +696,9 @@ const localMaxIterations = ref(5)
const localTemperature = ref(0.7)
const localAllowedTools = ref<string[]>([])
type SystemPromptTab = 'web-enabled' | 'web-disabled'
const activeSystemPromptTab = ref<SystemPromptTab>('web-enabled')
const localSystemPromptWebEnabled = ref('')
const localSystemPromptWebDisabled = ref('')
const systemPromptRefs: Record<SystemPromptTab, Ref<string>> = {
'web-enabled': localSystemPromptWebEnabled,
'web-disabled': localSystemPromptWebDisabled,
}
const savedSystemPromptMap: Record<SystemPromptTab, string> = {
'web-enabled': '',
'web-disabled': '',
}
const getPromptRefByTab = (tab: SystemPromptTab) => systemPromptRefs[tab]
const getActivePromptRef = () => getPromptRefByTab(activeSystemPromptTab.value)
const localUseCustomSystemPrompt = ref(false)
// 统一系统提示词
const localSystemPrompt = ref('')
let savedSystemPrompt = ''
// 普通模式本地状态
const localContextTemplate = ref('')
@@ -755,10 +726,6 @@ const localRewritePromptUser = ref('')
const localSummaryModelId = ref('')
const localConversationRerankModelId = ref('')
// 普通模式 Prompt 是否自定义(关闭时使用系统默认)
const localUseCustomSystemPromptNormal = ref(true)
const localUseCustomContextTemplate = ref(true)
const syncConversationLocals = () => {
const cfg = conversationConfig.value
localContextTemplate.value = cfg.context_template ?? ''
@@ -785,8 +752,6 @@ const syncConversationLocals = () => {
localRewritePromptUser.value = cfg.rewrite_prompt_user ?? ''
localSummaryModelId.value = cfg.summary_model_id ?? ''
localConversationRerankModelId.value = cfg.rerank_model_id ?? ''
localUseCustomSystemPromptNormal.value = cfg.use_custom_system_prompt ?? true
localUseCustomContextTemplate.value = cfg.use_custom_context_template ?? true
settingsStore.updateConversationModels({
summaryModelId: localSummaryModelId.value || '',
@@ -835,9 +800,7 @@ const buildAgentConfigPayload = (overrides: Partial<AgentConfig> = {}): AgentCon
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
temperature: localTemperature.value,
system_prompt_web_enabled: localSystemPromptWebEnabled.value,
system_prompt_web_disabled: localSystemPromptWebDisabled.value,
use_custom_system_prompt: localUseCustomSystemPrompt.value,
system_prompt: localSystemPrompt.value,
...overrides,
})
@@ -916,9 +879,6 @@ const loadingConfig = ref(false)
const configLoaded = ref(false) // 防止重复加载
const isInitializing = ref(true) // 标记是否正在初始化,防止初始化时触发保存
// 保存的 Prompt 值,用于比较是否变化
let savedUseCustomSystemPrompt = false
// 恢复默认 Prompt 的加载状态
const isResettingPrompt = ref(false)
@@ -930,12 +890,6 @@ let placeholderPopupTimer: any = null
const placeholderPrefix = ref('') // 当前输入的前缀,用于过滤
const popupStyle = ref({ top: '0px', left: '0px' }) // 提示框位置
watch(activeSystemPromptTab, () => {
showPlaceholderPopup.value = false
placeholderPrefix.value = ''
selectedPlaceholderIndex.value = 0
})
// 设置 textarea 原生事件监听器
const setupTextareaEventListeners = () => {
nextTick(() => {
@@ -1049,15 +1003,9 @@ onMounted(async () => {
lastSavedValue = config.max_iterations // 初始化时记录已保存的值
localTemperature.value = config.temperature
localAllowedTools.value = config.allowed_tools || []
const promptWebEnabled = config.system_prompt_web_enabled || ''
const promptWebDisabled = config.system_prompt_web_disabled || ''
localSystemPromptWebEnabled.value = promptWebEnabled
localSystemPromptWebDisabled.value = promptWebDisabled
savedSystemPromptMap['web-enabled'] = promptWebEnabled
savedSystemPromptMap['web-disabled'] = promptWebDisabled
const useCustomPrompt = config.use_custom_system_prompt ?? false
localUseCustomSystemPrompt.value = useCustomPrompt
savedUseCustomSystemPrompt = useCustomPrompt
const systemPrompt = config.system_prompt || ''
localSystemPrompt.value = systemPrompt
savedSystemPrompt = systemPrompt
availableTools.value = config.available_tools || []
availablePlaceholders.value = config.available_placeholders || []
@@ -1074,9 +1022,7 @@ onMounted(async () => {
maxIterations: config.max_iterations,
temperature: config.temperature,
allowedTools: config.allowed_tools || [],
system_prompt_web_enabled: promptWebEnabled,
system_prompt_web_disabled: promptWebDisabled,
use_custom_system_prompt: useCustomPrompt
system_prompt: systemPrompt,
})
// 加载普通模式配置
@@ -1232,25 +1178,6 @@ const handleTemperatureChange = async (value: number) => {
}
}
// 切换是否启用自定义 Prompt
const handleUseCustomPromptToggle = async (value: boolean) => {
if (isInitializing.value) return
if (value === savedUseCustomSystemPrompt) return
try {
const config = buildAgentConfigPayload({ use_custom_system_prompt: value })
await updateAgentConfig(config)
savedUseCustomSystemPrompt = value
MessagePlugin.success(value ? t('agentSettings.toasts.customPromptEnabled') : t('agentSettings.toasts.defaultPromptEnabled'))
} catch (error) {
console.error('切换自定义 Prompt 失败:', error)
MessagePlugin.error(getErrorMessage(error))
// 回滚开关状态
localUseCustomSystemPrompt.value = savedUseCustomSystemPrompt
}
}
// 处理系统 Prompt 键盘事件(作为备用,主要逻辑在原生事件监听器中)
const handlePromptKeydown = (e: KeyboardEvent) => {
// 如果正在显示占位符提示,且输入的是字母、数字或下划线,实时更新过滤
@@ -1456,29 +1383,21 @@ const handleResetToDefault = async () => {
try {
isResettingPrompt.value = true
// 通过设置 system_prompt_web_* 为空字符串来获取默认值
// 通过设置 system_prompt 为空字符串来获取默认值
// 后端在字段为空时会返回默认值
const tempConfig = buildAgentConfigPayload({
system_prompt_web_enabled: '',
system_prompt_web_disabled: '',
use_custom_system_prompt: false,
system_prompt: '',
})
await updateAgentConfig(tempConfig)
// 重新加载配置以获取默认 Prompt 的完整内容
const res = await getAgentConfig()
const defaultPromptWebEnabled = res.data.system_prompt_web_enabled || ''
const defaultPromptWebDisabled = res.data.system_prompt_web_disabled || ''
const useCustom = res.data.use_custom_system_prompt ?? false
const defaultPrompt = res.data.system_prompt || ''
// 设置为默认 Prompt 的内容
localSystemPromptWebEnabled.value = defaultPromptWebEnabled
localSystemPromptWebDisabled.value = defaultPromptWebDisabled
savedSystemPromptMap['web-enabled'] = defaultPromptWebEnabled
savedSystemPromptMap['web-disabled'] = defaultPromptWebDisabled
localUseCustomSystemPrompt.value = useCustom
savedUseCustomSystemPrompt = useCustom
localSystemPrompt.value = defaultPrompt
savedSystemPrompt = defaultPrompt
MessagePlugin.success(t('agentSettings.toasts.resetToDefault'))
confirmDialog.hide()
@@ -1493,7 +1412,7 @@ const handleResetToDefault = async () => {
}
// 处理系统 Prompt 变化
const handleSystemPromptChange = async (tab: SystemPromptTab, e?: FocusEvent) => {
const handleSystemPromptChange = async (e?: FocusEvent) => {
// 如果点击的是占位符提示框,不触发保存
if (e?.relatedTarget) {
const target = e.relatedTarget as HTMLElement
@@ -1515,19 +1434,16 @@ const handleSystemPromptChange = async (tab: SystemPromptTab, e?: FocusEvent) =>
// 如果正在初始化,不触发保存
if (isInitializing.value) return
const promptRef = getPromptRefByTab(tab)
const savedValue = savedSystemPromptMap[tab]
// 检查内容是否变化
if (promptRef.value === savedValue) {
if (localSystemPrompt.value === savedSystemPrompt) {
return // 内容没变,不调用接口
}
try {
const config = buildAgentConfigPayload()
await updateAgentConfig(config)
savedSystemPromptMap[tab] = promptRef.value // 更新已保存的值
savedSystemPrompt = localSystemPrompt.value // 更新已保存的值
MessagePlugin.success(t('agentSettings.toasts.systemPromptSaved'))
} catch (error) {
console.error('保存系统 Prompt 失败:', error)
@@ -1559,7 +1475,6 @@ const handleContextTemplateChange = async () => {
await saveConversationConfig(
{
context_template: localContextTemplate.value,
use_custom_context_template: localUseCustomContextTemplate.value,
},
t('conversationSettings.toasts.contextTemplateSaved')
)
@@ -1576,66 +1491,6 @@ const reloadConversationConfig = async () => {
syncConversationLocals()
}
const handleUseCustomSystemPromptNormalToggle = async (value: boolean) => {
if (!conversationConfigLoaded.value) return
try {
if (!value) {
await saveConversationConfig(
{
prompt: '',
use_custom_system_prompt: false,
},
t('conversationSettings.toasts.defaultPromptEnabled')
)
await reloadConversationConfig()
} else {
await saveConversationConfig(
{
prompt: localSystemPromptNormal.value,
use_custom_system_prompt: true,
},
t('conversationSettings.toasts.customPromptEnabled')
)
savedSystemPromptNormal = localSystemPromptNormal.value
}
} catch (error) {
console.error('切换普通模式 System Prompt 自定义失败:', error)
MessagePlugin.error(getErrorMessage(error))
localUseCustomSystemPromptNormal.value = !value
}
}
const handleUseCustomContextTemplateToggle = async (value: boolean) => {
if (!conversationConfigLoaded.value) return
try {
if (!value) {
await saveConversationConfig(
{
context_template: '',
use_custom_context_template: false,
},
t('conversationSettings.toasts.defaultContextTemplateEnabled')
)
await reloadConversationConfig()
} else {
await saveConversationConfig(
{
context_template: localContextTemplate.value,
use_custom_context_template: true,
},
t('conversationSettings.toasts.customContextTemplateEnabled')
)
savedContextTemplate = localContextTemplate.value
}
} catch (error) {
console.error('切换普通模式 Context Template 自定义失败:', error)
MessagePlugin.error(getErrorMessage(error))
localUseCustomContextTemplate.value = !value
}
}
const handleSystemPromptNormalChange = async () => {
if (!conversationConfigLoaded.value) return
@@ -1647,7 +1502,6 @@ const handleSystemPromptNormalChange = async () => {
await saveConversationConfig(
{
prompt: localSystemPromptNormal.value,
use_custom_system_prompt: localUseCustomSystemPromptNormal.value,
},
t('conversationSettings.toasts.systemPromptSaved')
)
@@ -1813,6 +1667,35 @@ const handleFallbackPromptChange = async () => {
}
}
// 模板选择处理函数
const handleAgentSystemPromptTemplateSelect = (template: string) => {
localSystemPrompt.value = template
}
const handleNormalSystemPromptTemplateSelect = (template: string) => {
localSystemPromptNormal.value = template
}
const handleContextTemplateTemplateSelect = (template: string) => {
localContextTemplate.value = template
}
const handleRewriteSystemTemplateSelect = (template: string) => {
localRewritePromptSystem.value = template
}
const handleRewriteUserTemplateSelect = (template: string) => {
localRewritePromptUser.value = template
}
const handleFallbackResponseTemplateSelect = (template: string) => {
localFallbackResponse.value = template
}
const handleFallbackPromptTemplateSelect = (template: string) => {
localFallbackPrompt.value = template
}
const navigateToModelSettings = (subsection: 'chat' | 'rerank') => {
router.push('/platform/settings')
@@ -1881,9 +1764,29 @@ const handleConversationRerankModelChange = async (value: string) => {
.section-description {
font-size: 14px;
color: #666666;
margin: 0 0 20px 0;
margin: 0 0 12px 0;
line-height: 1.5;
}
.global-config-notice {
display: flex;
align-items: flex-start;
gap: 8px;
padding: 12px 16px;
background: #f0f9ff;
border: 1px solid #bae0ff;
border-radius: 8px;
margin-bottom: 20px;
color: #0958d9;
font-size: 13px;
line-height: 1.5;
.t-icon {
font-size: 16px;
flex-shrink: 0;
margin-top: 2px;
}
}
}
.agent-status-row {
@@ -2056,6 +1959,17 @@ const handleConversationRerankModelChange = async (value: string) => {
word-break: keep-all;
white-space: normal;
.setting-info-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 4px;
label {
margin-bottom: 0;
}
}
label {
font-size: 15px;
font-weight: 500;
@@ -2263,6 +2177,11 @@ const handleConversationRerankModelChange = async (value: string) => {
width: 100%;
}
.textarea-with-template {
position: relative;
width: 100%;
}
.setting-control.full-width {
display: flex;
flex-direction: column;
-17
View File
@@ -89,11 +89,6 @@
<OllamaSettings />
</div>
<!-- Agent 配置 -->
<div v-if="currentSection === 'agent'" class="section">
<AgentSettings :active-sub-section="currentSubSection || 'modes'" />
</div>
<!-- 网络搜索配置 -->
<div v-if="currentSection === 'websearch'" class="section">
<WebSearchSettings />
@@ -132,7 +127,6 @@ import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useUIStore } from '@/stores/ui'
import { useI18n } from 'vue-i18n'
import AgentSettings from './AgentSettings.vue'
import SystemInfo from './SystemInfo.vue'
import TenantInfo from './TenantInfo.vue'
import ApiInfo from './ApiInfo.vue'
@@ -165,17 +159,6 @@ const navItems = computed(() => [
]
},
{ key: 'ollama', icon: 'server', label: 'Ollama' },
{
key: 'agent',
icon: 'chat',
label: t('settings.conversationStrategy'),
children: [
{ key: 'modes', label: t('conversationSettings.menus.modes') },
{ key: 'models', label: t('conversationSettings.menus.models') },
{ key: 'thresholds', label: t('conversationSettings.menus.thresholds') },
{ key: 'advanced', label: t('conversationSettings.menus.advanced') },
]
},
{ key: 'websearch', icon: 'search', label: t('settings.webSearchConfig') },
{ key: 'mcp', icon: 'tools', label: t('settings.mcpService') },
{ key: 'system', icon: 'info-circle', label: t('settings.systemSettings') },