@@ -64,6 +64,36 @@
< / div >
< / div >
<!-- 智能体类型 ( 仅智能推理模式下显示 ) -- >
< div v-if = "isAgentMode && agentTypePresets.length > 0" class="setting-row setting-row--emphasize" >
< div class = "setting-info" >
< label > { { $t ( 'agentEditor.agentType.label' ) } } < / label >
< p class = "desc" > { { $t ( 'agentEditor.agentType.desc' ) } } < / p >
< p
v - if = "activeAgentTypePreset"
class = "desc agent-type-preset-desc"
> { { agentTypePresetDescription ( activeAgentTypePreset ) } } < / p >
< / div >
< div class = "setting-control" >
< t-select
: value = "agentType"
@ change = "onAgentTypeChange"
: disabled = "isBuiltinAgent"
: placeholder = "$t('agentEditor.agentType.label')"
: options = "agentTypeSelectOptions"
: popup - props = "{ overlayClassName: 'agent-type-popup' }"
class = "agent-type-select"
>
< template # option = "{ option }" >
< div class = "agent-type-option" >
< span class = "agent-type-option-label" > { { option . label } } < / span >
< span v-if = "option.desc" class="agent-type-option-desc" > {{ option.desc }} < / span >
< / div >
< / template >
< / t-select >
< / div >
< / div >
<!-- 名称 -- >
< div class = "setting-row" >
< div class = "setting-info" >
@@ -142,7 +172,7 @@
position = "corner"
: hasKnowledgeBase = "hasKnowledgeBase"
@ select = "handleSystemPromptTemplateSelect"
@ reset - default = "handleSystemPromptTemplateSelec t"
@ reset - default = "handleAgent SystemPromptResetDefaul t"
/ >
< / div >
<!-- 普通模式 : 单个提示词 -- >
@@ -627,23 +657,6 @@
< span > { { $t ( 'agentEditor.tools.statusInactive' , { count : inactiveToolCount } ) } } < / span >
< / div >
< / div >
< div class = "tools-overview-row tools-overview-row--preset" >
< div class = "tools-preset-label" >
< span class = "tools-preset-title" > { { $t ( 'agentEditor.tools.presetLabel' ) } } < / span >
< span class = "tools-preset-hint" > { { $t ( 'agentEditor.tools.presetDesc' ) } } < / span >
< / div >
< t-radio-group
: value = "formData.config.retrieval_preference"
@ change = "onRetrievalPresetChange"
size = "small"
variant = "default-filled"
>
< t-radio-button value = "auto" > { { $t ( 'agent.editor.retrievalPreferenceAuto' ) } } < / t-radio-button >
< t-radio-button value = "vector_only" > { { $t ( 'agent.editor.retrievalPreferenceVectorOnly' ) } } < / t-radio-button >
< t-radio-button value = "wiki_only" > { { $t ( 'agent.editor.retrievalPreferenceWikiOnly' ) } } < / t-radio-button >
< t-radio-button value = "hybrid" > { { $t ( 'agent.editor.retrievalPreferenceHybrid' ) } } < / t-radio-button >
< / t-radio-group >
< / div >
< / div >
< div class = "settings-group" >
@@ -876,14 +889,15 @@
filterable
: min - collapsed - num = "3"
>
< t-option-group v-if = "m yKbOptions.length" :label="$t('agent.editor.myKnowledgeBases')" >
< t-option-group v-if = "filteredM yKbOptions.length" :label="$t('agent.editor.myKnowledgeBases')" >
< t-option
v - for = "kb in m yKbOptions"
v - for = "kb in filteredM yKbOptions"
: key = "kb.value"
: value = "kb.value"
: label = "kb.label"
: disabled = "kb.disabled"
>
< div class = "kb-option-item" >
< div class = "kb-option-item" : title = "kb.disabled ? kb.disabledReason : ''" >
< span class = "kb-option-icon" : class = "kb.type === 'faq' ? 'faq-icon' : 'doc-icon'" >
< t-icon : name = "kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" / >
< / span >
@@ -891,17 +905,19 @@
< span v-if = "kb.ragEnabled" class="kb-option-tag tag-rag" > RAG < / span >
< span v-if = "kb.wikiEnabled" class="kb-option-tag tag-wiki" > Wiki < / span >
< span class = "kb-option-count" > { { kb . count || 0 } } < / span >
< span v-if = "kb.disabled" class="kb-option-disabled-hint" > {{ kb.disabledReason }} < / span >
< / div >
< / t-option >
< / t-option-group >
< t-option-group v-if = "s haredKbOptions.length" :label="$t('agent.editor.sharedKnowledgeBases')" >
< t-option-group v-if = "filteredS haredKbOptions.length" :label="$t('agent.editor.sharedKnowledgeBases')" >
< t-option
v - for = "kb in s haredKbOptions"
v - for = "kb in filteredS haredKbOptions"
: key = "kb.value"
: value = "kb.value"
: label = "kb.label"
: disabled = "kb.disabled"
>
< div class = "kb-option-item" >
< div class = "kb-option-item" : title = "kb.disabled ? kb.disabledReason : ''" >
< span class = "kb-option-icon" : class = "kb.type === 'faq' ? 'faq-icon' : 'doc-icon'" >
< t-icon : name = "kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" / >
< / span >
@@ -910,6 +926,7 @@
< span v-if = "kb.wikiEnabled" class="kb-option-tag tag-wiki" > Wiki < / span >
< span v-if = "kb.orgName" class="kb-option-org" > {{ kb.orgName }} < / span >
< span class = "kb-option-count" > { { kb . count || 0 } } < / span >
< span v-if = "kb.disabled" class="kb-option-disabled-hint" > {{ kb.disabledReason }} < / span >
< / div >
< / t-option >
< / t-option-group >
@@ -1116,25 +1133,6 @@
< / div >
< div class = "settings-group" >
<!-- 检索偏好 -- >
< div class = "setting-row" >
< div class = "setting-info" >
< label > { { $t ( 'agent.editor.retrievalPreference' ) } } < / label >
< p class = "desc" > { { $t ( 'agent.editor.retrievalPreferenceDesc' ) } } < / p >
< / div >
< div class = "setting-control" >
< t-select
v - model = "formData.config.retrieval_preference"
style = "width: 200px"
>
< t-option value = "auto" > { { $t ( 'agent.editor.retrievalPreferenceAuto' ) } } < / t-option >
< t-option value = "vector_only" > { { $t ( 'agent.editor.retrievalPreferenceVectorOnly' ) } } < / t-option >
< t-option value = "wiki_only" > { { $t ( 'agent.editor.retrievalPreferenceWikiOnly' ) } } < / t-option >
< t-option value = "hybrid" > { { $t ( 'agent.editor.retrievalPreferenceHybrid' ) } } < / t-option >
< / t-select >
< / div >
< / div >
<!-- 查询扩展 ( 仅普通模式 ) -- >
< div v-if = "!isAgentMode" class="setting-row" >
< div class = "setting-info" >
@@ -1356,13 +1354,23 @@
import { ref , computed , watch , nextTick } from 'vue' ;
import { useI18n } from 'vue-i18n' ;
import { MessagePlugin } from 'tdesign-vue-next' ;
import { createAgent , updateAgent , getPlaceholders , type CustomAgent , type PlaceholderDefinition } from '@/api/agent' ;
import {
createAgent ,
updateAgent ,
getPlaceholders ,
getAgentTypePresets ,
type CustomAgent ,
type PlaceholderDefinition ,
type AgentTypePreset ,
type AgentType ,
type KBCapabilities ,
} from '@/api/agent' ;
import { listModels , type ModelConfig } from '@/api/model' ;
import { listKnowledgeBases } from '@/api/knowledge-base' ;
import { listMCPServices , type MCPService } from '@/api/mcp-service' ;
import { listSkills , type SkillInfo } from '@/api/skill' ;
import { listWebSearchProviders , type WebSearchProviderEntity } from '@/api/web-search-provider' ;
import { getAgentConfig , getConversationConfig , getStorageEngineStatus , type StorageEngineStatusItem , type PromptTemplate } from '@/api/system' ;
import { getAgentConfig , getConversationConfig , getStorageEngineStatus , getPromptTemplates , type StorageEngineStatusItem , type PromptTemplate } from '@/api/system' ;
import { useUIStore } from '@/stores/ui' ;
import { useAuthStore } from '@/stores/auth' ;
import { useOrganizationStore } from '@/stores/organization' ;
@@ -1376,7 +1384,7 @@ const uiStore = useUIStore();
const authStore = useAuthStore ( ) ;
const orgStore = useOrganizationStore ( ) ;
const { t } = useI18n ( ) ;
const { t , locale : i18nLocale } = useI18n ( ) ;
const props = defineProps < {
visible : boolean ;
@@ -1393,7 +1401,12 @@ const emit = defineEmits<{
const currentSection = ref ( props . initialSection || 'basic' ) ;
const saving = ref ( false ) ;
const allModels = ref < ModelConfig [ ] > ( [ ] ) ;
const kbOptions = ref < { label : string ; value : string ; type ? : 'document' | 'faq' ; count ? : number ; shared ? : boolean ; orgName ? : string ; ragEnabled ? : boolean ; wikiEnabled ? : boolean } [ ] > ( [ ] ) ;
const kbOptions = ref < { label : string ; value : string ; type ? : 'document' | 'faq' ; count ? : number ; shared ? : boolean ; orgName ? : string ; ragEnabled ? : boolean ; wikiEnabled ? : boolean ; capabilities ? : KBCapabilities } [ ] > ( [ ] ) ;
/ / 智 能 体 类 型 预 设 ( 仅 s m a r t - r e a s o n i n g 模 式 下 展 示 )
const agentTypePresets = ref < AgentTypePreset [ ] > ( [ ] ) ;
/ / A g e n t 系 统 提 示 词 模 板 缓 存 ( 用 于 切 换 智 能 体 类 型 时 根 据 s y s t e m _ p r o m p t _ i d 解 析 出 实 际 文 本 填 入 )
const agentSystemPromptTemplates = ref < PromptTemplate [ ] > ( [ ] ) ;
const mcpOptions = ref < { label : string ; value : string } [ ] > ( [ ] ) ;
const webSearchProviderList = ref < WebSearchProviderEntity [ ] > ( [ ] ) ;
const skillOptions = ref < { name : string ; description : string } [ ] > ( [ ] ) ;
@@ -1748,7 +1761,7 @@ const defaultFormData = {
is _builtin : false ,
config : {
/ / 基 础 设 置
agent _mode : 'quick-answer ' as 'quick-answer' | 'smart-reasoning' ,
agent _mode : 'smart-reasoning ' as 'quick-answer' | 'smart-reasoning' ,
system _prompt : '' ,
context _template : '{{query}}' ,
/ / 模 型 设 置
@@ -1771,7 +1784,10 @@ const defaultFormData = {
kb _selection _mode : 'none' as 'all' | 'selected' | 'none' ,
knowledge _bases : [ ] as string [ ] ,
retrieve _kb _only _when _mentioned : false ,
retrieval _preference : 'auto' as 'auto' | 'vector_only' | 'wiki_only' | 'hybrid' ,
/ / 智 能 推 理 下 的 类 型 预 设 : 新 建 a g e n t 时 默 认 给 R A G 问 答 ( 最 常 用 场 景 ) 。
/ / 编 辑 既 有 a g e n t 时 会 被 a g e n t 自 己 保 存 的 a g e n t _ t y p e 覆 盖 。
agent _type : 'rag-qa' as AgentType ,
system _prompt _id : '' as string ,
/ / 图 片 上 传 / 多 模 态 设 置
image _upload _enabled : false ,
vlm _model _id : '' ,
@@ -1816,6 +1832,209 @@ const agentMode = computed({
const isAgentMode = computed ( ( ) => agentMode . value === 'smart-reasoning' ) ;
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/ / 智 能 体 类 型 预 设 ( 仅 s m a r t - r e a s o n i n g 模 式 下 可 见 )
/ / 选 择 类 型 后 自 动 填 充 s y s t e m _ p r o m p t _ i d / a l l o w e d _ t o o l s 等 ;
/ / 选 择 " c u s t o m " 或 没 有 匹 配 预 设 时 不 做 任 何 覆 盖 。
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
const agentType = computed ( {
get : ( ) => ( formData . value . config . agent _type as AgentType ) || 'custom' ,
set : ( val : AgentType ) => { formData . value . config . agent _type = val ; } ,
} ) ;
/ / 当 前 激 活 的 预 设 对 象 ( 用 于 K B 过 滤 / U I 徽 章 )
const activeAgentTypePreset = computed < AgentTypePreset | null > ( ( ) => {
if ( ! isAgentMode . value ) return null ;
const id = agentType . value ;
if ( ! id || id === 'custom' ) return null ;
return agentTypePresets . value . find ( p => p . id === id ) || null ;
} ) ;
/ / 根 据 当 前 l o c a l e 挑 选 i 1 8 n 标 签
const agentTypePresetLabel = ( p : AgentTypePreset ) : string => {
const locale = i18nLocale . value || 'default' ;
return p . i18n ? . [ locale ] ? . label || p . i18n ? . default ? . label || p . id ;
} ;
const agentTypePresetDescription = ( p : AgentTypePreset ) : string => {
const locale = i18nLocale . value || 'default' ;
return p . i18n ? . [ locale ] ? . description || p . i18n ? . default ? . description || '' ;
} ;
/ / t - s e l e c t 的 o p t i o n s 数 据 : l a b e l 给 T D e s i g n 自 己 ( 用 于 选 中 态 显 示 ) , d e s c 走 自 定 义 o p t i o n s l o t
const agentTypeSelectOptions = computed ( ( ) => {
return agentTypePresets . value . map ( p => ( {
value : p . id ,
label : agentTypePresetLabel ( p ) ,
desc : agentTypePresetDescription ( p ) ,
} ) ) ;
} ) ;
/ / 为 每 个 预 设 生 成 " 我 的 < l a b e l > " 的 默 认 名 称 , 让 用 户 可 以 一 键 保 存
/ / c u s t o m 类 型 默 认 名 为 空 ( 让 用 户 自 己 想 )
const getPresetDefaultName = ( preset : AgentTypePreset | null ) : string => {
if ( ! preset || preset . id === 'custom' ) return '' ;
return t ( 'agentEditor.agentType.defaultNamePattern' , { label : agentTypePresetLabel ( preset ) } ) ;
} ;
const getPresetDefaultDescription = ( preset : AgentTypePreset | null ) : string => {
if ( ! preset ) return '' ;
return agentTypePresetDescription ( preset ) ;
} ;
/ / 判 断 当 前 名 称 / 描 述 是 否 由 系 统 自 动 填 入 ( 任 一 预 设 的 默 认 值 或 空 )
/ / 用 于 在 切 换 类 型 时 只 覆 盖 " 未 被 用 户 手 动 编 辑 " 的 值 , 避 免 覆 盖 用 户 输 入
const isNameSystemGenerated = ( name : string ) : boolean => {
if ( ! name ) return true ;
return agentTypePresets . value . some ( p => getPresetDefaultName ( p ) === name ) ;
} ;
const isDescriptionSystemGenerated = ( desc : string ) : boolean => {
if ( ! desc ) return true ;
return agentTypePresets . value . some ( p => getPresetDefaultDescription ( p ) === desc ) ;
} ;
/ / 按 预 设 i d 返 回 面 向 用 户 的 不 兼 容 原 因 文 案 。
/ / 不 要 直 接 把 " v e c t o r / k e y w o r d / w i k i " 这 些 底 层 c a p a b i l i t y 名 回 传 给 用 户 —
/ / 用 户 不 关 心 技 术 实 现 , 只 想 知 道 " 为 什 么 我 这 个 知 识 库 不 能 用 " 。
const presetKbMismatchKeyMap : Record < string , string > = {
'rag-qa' : 'ragQa' ,
'wiki-qa' : 'wikiQa' ,
'hybrid-rag-wiki' : 'hybridRagWiki' ,
'data-analysis' : 'dataAnalysis' ,
} ;
const presetKbMismatchReason = ( preset : AgentTypePreset ) : string => {
const subKey = presetKbMismatchKeyMap [ preset . id ] ;
if ( subKey ) return t ( ` agentEditor.agentType.kbMismatch. ${ subKey } ` ) ;
return t ( 'agentEditor.agentType.kbMismatch.generic' ) ;
} ;
/ / 评 估 单 个 K B 是 否 满 足 给 定 预 设 的 k b _ f i l t e r
const kbSatisfiesPresetFilter = ( kb : { capabilities ? : KBCapabilities ; ragEnabled ? : boolean ; wikiEnabled ? : boolean ; type ? : string } , preset : AgentTypePreset | null ) : { ok : boolean ; reason : string } => {
if ( ! preset || ! preset . kb _filter ) return { ok : true , reason : '' } ;
const caps = kb . capabilities || {
vector : ! ! kb . ragEnabled ,
keyword : ! ! kb . ragEnabled ,
wiki : ! ! kb . wikiEnabled ,
graph : false ,
faq : kb . type === 'faq' ,
} ;
const has = ( name : string ) : boolean => {
switch ( name ) {
case 'vector' : return ! ! caps . vector ;
case 'keyword' : return ! ! caps . keyword ;
case 'wiki' : return ! ! caps . wiki ;
case 'graph' : return ! ! caps . graph ;
case 'faq' : return ! ! caps . faq ;
default : return false ;
}
} ;
const f = preset . kb _filter ;
const reason = presetKbMismatchReason ( preset ) ;
if ( f . all _of && f . all _of . length > 0 ) {
for ( const n of f . all _of ) {
if ( ! has ( n ) ) return { ok : false , reason } ;
}
}
if ( f . any _of && f . any _of . length > 0 ) {
if ( ! f . any _of . some ( n => has ( n ) ) ) {
return { ok : false , reason } ;
}
}
if ( f . none _of && f . none _of . length > 0 ) {
for ( const n of f . none _of ) {
if ( has ( n ) ) return { ok : false , reason } ;
}
}
return { ok : true , reason : '' } ;
} ;
/ / K B 过 滤 后 的 选 项 ( 用 于 " 指 定 知 识 库 " 下 拉 ) — 不 满 足 的 仍 保 留 但 标 记 d i s a b l e d + t o o l t i p
const filteredKbOptionsForPreset = computed ( ( ) => {
const preset = activeAgentTypePreset . value ;
return kbOptions . value . map ( kb => {
const { ok , reason } = kbSatisfiesPresetFilter ( kb , preset ) ;
return { ... kb , disabled : ! ok , disabledReason : reason } ;
} ) ;
} ) ;
const filteredMyKbOptions = computed ( ( ) => filteredKbOptionsForPreset . value . filter ( kb => ! kb . shared ) ) ;
const filteredSharedKbOptions = computed ( ( ) => filteredKbOptionsForPreset . value . filter ( kb => kb . shared ) ) ;
/ / 当 前 选 中 的 K B 中 , 有 多 少 个 在 新 预 设 下 会 被 禁 用 ( 用 于 保 存 前 提 示 )
const incompatibleSelectedKbCount = computed ( ( ) => {
const preset = activeAgentTypePreset . value ;
if ( ! preset || kbSelectionMode . value !== 'selected' ) return 0 ;
const selected = new Set ( formData . value . config . knowledge _bases || [ ] ) ;
return filteredKbOptionsForPreset . value . filter ( kb => selected . has ( kb . value ) && kb . disabled ) . length ;
} ) ;
/ / 应 用 一 个 预 设 的 c o n f i g 到 f o r m D a t a . c o n f i g ( 仅 覆 盖 预 设 里 明 确 设 置 的 字 段 , 其 他 不 动 )
const applyAgentTypePreset = ( preset : AgentTypePreset | null ) => {
if ( ! preset || ! preset . config ) return ;
const c = preset . config ;
const target = formData . value . config ;
if ( c . system _prompt _id !== undefined ) {
target . system _prompt _id = c . system _prompt _id ;
/ / 根 据 s y s t e m _ p r o m p t _ i d 从 已 加 载 的 模 板 列 表 里 查 出 正 文 并 回 填 到 用 户 可 见 的 t e x t a r e a
const tmpl = agentSystemPromptTemplates . value . find ( t => t . id === c . system _prompt _id ) ;
if ( tmpl && typeof tmpl . content === 'string' ) {
target . system _prompt = tmpl . content ;
} else {
/ / 模 板 列 表 还 没 加 载 完 / 或 预 设 引 用 了 不 存 在 的 i d : 清 空 让 用 户 感 知 到 变 化
target . system _prompt = '' ;
if ( c . system _prompt _id ) {
console . warn ( ` [AgentType] system_prompt_id " ${ c . system _prompt _id } " not found in agent_system_prompt templates ` ) ;
}
}
}
if ( typeof c . temperature === 'number' ) target . temperature = c . temperature ;
if ( typeof c . max _iterations === 'number' ) target . max _iterations = c . max _iterations ;
if ( Array . isArray ( c . allowed _tools ) ) target . allowed _tools = [ ... c . allowed _tools ] ;
if ( typeof c . retain _retrieval _history === 'boolean' ) target . retain _retrieval _history = c . retain _retrieval _history ;
if ( typeof c . faq _priority _enabled === 'boolean' ) target . faq _priority _enabled = c . faq _priority _enabled ;
if ( typeof c . web _search _enabled === 'boolean' ) target . web _search _enabled = c . web _search _enabled ;
/ / s u p p o r t e d _ f i l e _ t y p e s 采 用 " 强 同 步 " 语 义 : 只 有 d a t a - a n a l y s i s 需 要 限 定 c s v / x l s x ,
/ / 其 余 类 型 切 过 来 时 必 须 清 空 , 否 则 会 从 上 一 个 类 型 带 过 来 残 留 。
if ( Array . isArray ( c . supported _file _types ) ) {
target . supported _file _types = [ ... c . supported _file _types ] ;
} else {
target . supported _file _types = [ ] ;
}
/ / k b _ s e l e c t i o n _ m o d e 同 步 到 f o r m D a t a 以 及 U I 状 态 ( 两 处 都 要 改 , 否 则 单 选 按 钮 不 更 新 )
if ( c . kb _selection _mode ) {
target . kb _selection _mode = c . kb _selection _mode ;
kbSelectionMode . value = c . kb _selection _mode ;
}
} ;
/ / 用 户 手 动 切 换 类 型 → 应 用 预 设
const onAgentTypeChange = ( val : AgentType ) => {
/ / 切 换 前 捕 获 " 名 称 / 描 述 是 否 可 安 全 覆 盖 "
/ / 已 编 辑 过 的 用 户 输 入 ( 不 等 于 任 何 预 设 默 认 值 ) 绝 不 覆 盖
const canOverrideName = isNameSystemGenerated ( formData . value . name ) ;
const canOverrideDesc = isDescriptionSystemGenerated ( formData . value . description ) ;
agentType . value = val ;
const preset = agentTypePresets . value . find ( p => p . id === val ) || null ;
if ( val !== 'custom' ) {
applyAgentTypePreset ( preset ) ;
}
/ / 用 新 预 设 的 默 认 名 / 描 述 刷 新 自 动 填 充 字 段
if ( canOverrideName ) {
formData . value . name = getPresetDefaultName ( preset ) ;
}
if ( canOverrideDesc ) {
formData . value . description = getPresetDefaultDescription ( preset ) ;
}
/ / 如 果 新 预 设 与 当 前 已 选 K B 冲 突 , 软 提 示 ( 不 强 制 移 除 )
if ( incompatibleSelectedKbCount . value > 0 ) {
MessagePlugin . warning (
t ( 'agentEditor.agentType.kbIncompatibleWarn' , { count : incompatibleSelectedKbCount . value } ) ,
4000 ,
) ;
}
} ;
/ / 思 考 模 式 计 算 属 性 ( 直 接 绑 定 b o o l e a n )
const thinkingEnabled = computed ( {
get : ( ) => formData . value . config . thinking === true ,
@@ -1943,6 +2162,25 @@ watch(() => props.visible, async (val) => {
kbSelectionMode . value = 'none' ;
mcpSelectionMode . value = 'none' ;
skillsSelectionMode . value = 'none' ;
/ / 新 建 智 能 推 理 a g e n t 时 , 立 即 应 用 默 认 的 a g e n t _ t y p e 预 设
/ / ( 补 齐 s y s t e m _ p r o m p t / a l l o w e d _ t o o l s / k b _ s e l e c t i o n _ m o d e 等 ) ,
/ / 否 则 用 户 在 m o d a l 打 开 瞬 间 看 到 的 " 默 认 表 单 " 和 类 型 下 拉 显 示 的 类 型 不 一 致 。
if ( newFormData . config . agent _mode === 'smart-reasoning' ) {
const defaultTypeId = newFormData . config . agent _type as AgentType ;
const preset = agentTypePresets . value . find ( p => p . id === defaultTypeId ) || null ;
if ( defaultTypeId && defaultTypeId !== 'custom' ) {
applyAgentTypePreset ( preset ) ;
}
/ / 给 新 建 表 单 补 上 " 我 的 X X X " 默 认 名 + 预 设 描 述 , 让 用 户 可 直 接 保 存 ;
/ / 用 户 输 入 过 的 值 不 会 被 覆 盖 ( 此 处 是 新 建 场 景 , 字 段 必 定 为 空 ) 。
if ( ! formData . value . name ) {
formData . value . name = getPresetDefaultName ( preset ) ;
}
if ( ! formData . value . description ) {
formData . value . description = getPresetDefaultDescription ( preset ) ;
}
}
}
}
} ) ;
@@ -2063,9 +2301,11 @@ watch(skillsSelectionMode, (mode) => {
/ / 监 听 模 式 变 化 , 自 动 调 整 配 置
watch ( agentMode , ( val , _oldVal ) => {
if ( val === 'smart-reasoning' ) {
/ / 切 换 到 A g e n t 模 式 , 根 据 知 识 库 配 置 启 用 工 具
/ / 切 换 到 A g e n t 模 式 , 根 据 知 识 库 配 置 启 用 工 具 。
/ / 注 意 : 默 认 不 注 入 t h i n k i n g / t o d o _ w r i t e — — 它 们 用 于 显 式 反 思 或 多 步 计 划 ,
/ / 会 显 著 增 加 t o k e n 消 耗 , 用 户 按 需 手 动 勾 选 。
if ( formData . value . config . allowed _tools . length === 0 ) {
const tools = [ 'thinking' , 'todo_write' ] ;
const tools : string [ ] = [ ] ;
if ( hasRagKnowledgeBase . value ) {
tools . push (
'knowledge_search' ,
@@ -2154,43 +2394,6 @@ watch(hasWikiKnowledgeBase, (hasWiki, oldHasWiki) => {
}
} ) ;
/ / 检 索 策 略 预 设 : 一 键 改 写 a l l o w e d _ t o o l s
/ / a u t o - > 按 作 用 域 内 知 识 库 能 力 自 动 补 齐 ( R A G 库 → R A G 工 具 ; W i k i 库 → W i k i 读 取 工 具 )
/ / v e c t o r _ o n l y - > 只 保 留 R A G 工 具 , 移 除 W i k i 工 具
/ / w i k i _ o n l y - > 只 保 留 W i k i 读 取 工 具 , 移 除 R A G 工 具
/ / h y b r i d - > 两 者 都 补 齐
const onRetrievalPresetChange = ( val : string ) => {
formData . value . config . retrieval _preference = val as 'auto' | 'vector_only' | 'wiki_only' | 'hybrid' ;
if ( ! isAgentMode . value ) return ;
const current = new Set ( formData . value . config . allowed _tools || [ ] ) ;
const addAll = ( list : string [ ] ) => list . forEach ( t => current . add ( t ) ) ;
const removeAll = ( list : string [ ] ) => list . forEach ( t => current . delete ( t ) ) ;
switch ( val ) {
case 'vector_only' :
if ( hasRagKnowledgeBase . value ) addAll ( knowledgeBaseTools ) ;
removeAll ( allWikiTools ) ;
break ;
case 'wiki_only' :
removeAll ( knowledgeBaseTools ) ;
if ( hasWikiKnowledgeBase . value ) addAll ( wikiReadTools ) ;
break ;
case 'hybrid' :
if ( hasRagKnowledgeBase . value ) addAll ( knowledgeBaseTools ) ;
if ( hasWikiKnowledgeBase . value ) addAll ( wikiReadTools ) ;
break ;
case 'auto' :
default :
if ( hasRagKnowledgeBase . value ) addAll ( knowledgeBaseTools ) ;
if ( hasWikiKnowledgeBase . value ) addAll ( wikiReadTools ) ;
break ;
}
formData . value . config . allowed _tools = Array . from ( current ) ;
} ;
/ / 监 听 运 行 模 式 变 化 , 自 动 切 换 页 面
watch ( isAgentMode , ( isAgent ) => {
/ / 如 果 当 前 在 高 级 设 置 页 面 但 切 换 到 了 A g e n t 模 式 , 切 换 到 基 础 设 置
@@ -2239,14 +2442,16 @@ const loadDependencies = async () => {
if ( kbRes . data ) {
kbRes . data . forEach ( ( kb : any ) => {
const strategy = kb . indexing _strategy ;
const caps : KBCapabilities | undefined = kb . capabilities ;
myKbs . push ( {
label : kb . name ,
value : kb . id ,
type : kb . type || 'document' ,
count : kb . type === 'faq' ? ( kb . chunk _count || 0 ) : ( kb . knowledge _count || 0 ) ,
shared : false ,
ragEnabled : ! strategy || strategy . vector _enabled || strategy . keyword _enabled ,
wikiEnabled : strategy ? . wiki _enabled || false ,
ragEnabled : caps ? ( caps . vector || caps . keyword ) : ( ! strategy || strategy . vector _enabled || strategy . keyword _enabled ) ,
wikiEnabled : caps ? caps . wiki : ( strategy ? . wiki _enabled || false ) ,
capabilities : caps ,
} ) ;
} ) ;
}
@@ -2260,6 +2465,7 @@ const loadDependencies = async () => {
sharedList . forEach ( ( shared : any ) => {
const kb = shared . knowledge _base ;
if ( ! kb || myKbIds . has ( kb . id ) ) return ;
const caps : KBCapabilities | undefined = kb . capabilities ;
sharedKbs . push ( {
label : kb . name ,
value : kb . id ,
@@ -2267,8 +2473,9 @@ const loadDependencies = async () => {
count : kb . type === 'faq' ? ( kb . chunk _count || 0 ) : ( kb . knowledge _count || 0 ) ,
shared : true ,
orgName : shared . org _name ,
ragEnabled : ! kb . indexing _strategy || kb . indexing _strategy . vector _enabled || kb . indexing _strategy . keyword _enabled ,
wikiEnabled : kb . indexing _strategy ? . wiki _enabled || false ,
ragEnabled : caps ? ( caps . vector || caps . keyword ) : ( ! kb . indexing _strategy || kb . indexing _strategy . vector _enabled || kb . indexing _strategy . keyword _enabled ) ,
wikiEnabled : caps ? caps . wiki : ( kb . indexing _strategy ? . wiki _enabled || false ) ,
capabilities : caps ,
} ) ;
} ) ;
}
@@ -2302,6 +2509,27 @@ const loadDependencies = async () => {
skillsAvailable . value = false ;
}
/ / 加 载 智 能 体 类 型 预 设 ( s m a r t - r e a s o n i n g 模 式 下 的 " 类 型 " 下 拉 )
try {
const presetsRes : any = await getAgentTypePresets ( ) ;
if ( presetsRes ? . data && Array . isArray ( presetsRes . data ) ) {
agentTypePresets . value = presetsRes . data as AgentTypePreset [ ] ;
}
} catch ( e ) {
console . warn ( 'Failed to load agent type presets' , e ) ;
}
/ / 加 载 A g e n t 系 统 提 示 词 模 板 ( 供 a p p l y A g e n t T y p e P r e s e t 根 据 s y s t e m _ p r o m p t _ i d 回 填 正 文 )
try {
const tmplRes = await getPromptTemplates ( ) ;
const cfg = tmplRes ? . data ;
if ( cfg ? . agent _system _prompt && Array . isArray ( cfg . agent _system _prompt ) ) {
agentSystemPromptTemplates . value = cfg . agent _system _prompt ;
}
} catch ( e ) {
console . warn ( 'Failed to load prompt templates for agent type presets' , e ) ;
}
/ / 加 载 存 储 引 擎 可 用 状 态 ( 用 于 图 片 存 储 p r o v i d e r 选 择 )
try {
const statusRes = await getStorageEngineStatus ( ) ;
@@ -3116,6 +3344,30 @@ const handleSystemPromptTemplateSelect = (template: PromptTemplate) => {
formData . value . config . system _prompt = template . content ;
} ;
/ / A g e n t 系 统 提 示 词 的 " 恢 复 默 认 " :
/ / 当 前 选 中 了 非 c u s t o m 的 智 能 体 类 型 时 , " 默 认 " 应 当 是 该 类 型 预 设 绑 定 的 提 示 词
/ / ( 比 如 W i k i 问 答 → w i k i _ r e s e a r c h e r ) , 而 不 是 a g e n t _ s y s t e m _ p r o m p t 模 板 表 里
/ / 全 局 d e f a u l t : t r u e 的 那 一 条 。 只 有 当 类 型 为 c u s t o m 或 找 不 到 预 设 绑 定 的 模 板 时 ,
/ / 才 回 退 到 P r o m p t T e m p l a t e S e l e c t o r 传 来 的 全 局 默 认 模 板 。
const handleAgentSystemPromptResetDefault = ( fallback : PromptTemplate ) => {
const typeId = agentType . value ;
if ( typeId && typeId !== 'custom' ) {
const preset = agentTypePresets . value . find ( p => p . id === typeId ) ;
const presetPromptId = preset ? . config ? . system _prompt _id ;
if ( presetPromptId ) {
const tmpl = agentSystemPromptTemplates . value . find ( t => t . id === presetPromptId ) ;
if ( tmpl && typeof tmpl . content === 'string' ) {
formData . value . config . system _prompt = tmpl . content ;
formData . value . config . system _prompt _id = tmpl . id ;
return ;
}
}
}
/ / F a l l b a c k : 没 有 合 适 的 类 型 预 设 , 用 P r o m p t T e m p l a t e S e l e c t o r 找 到 的 全 局 默 认
formData . value . config . system _prompt = fallback . content ;
formData . value . config . system _prompt _id = fallback . id ;
} ;
const handleContextTemplateSelect = ( template : PromptTemplate ) => {
formData . value . config . context _template = template . content ;
} ;
@@ -3445,6 +3697,28 @@ const handleSave = async () => {
padding - right : 0 ;
}
}
/ / 强 调 行 : 用 于 " 智 能 体 类 型 " 这 类 对 用 户 影 响 最 大 、 需 要 突 出 的 关 键 配 置 。
/ / 视 觉 上 只 做 极 轻 度 强 调 — — 左 侧 3 p x 品 牌 色 竖 条 + l a b e l 加 粗 。
& . setting - row -- emphasize {
position : relative ;
padding - left : 14 px ;
& : : before {
content : '' ;
position : absolute ;
left : 0 ;
top : 22 px ;
bottom : 22 px ;
width : 3 px ;
border - radius : 2 px ;
background : var ( -- td - brand - color , # 0052 d9 ) ;
}
. setting - info label {
font - weight : 600 ;
}
}
}
. setting - info {
@@ -3727,24 +4001,6 @@ const handleSave = async () => {
}
}
. tools - preset - label {
display : flex ;
flex - direction : column ;
min - width : 0 ;
gap : 2 px ;
. tools - preset - title {
font - size : 13 px ;
font - weight : 600 ;
color : var ( -- td - text - color - primary ) ;
}
. tools - preset - hint {
font - size : 12 px ;
color : var ( -- td - text - color - secondary ) ;
}
}
/ / = = = = = 按 组 的 卡 片 网 格 = = = = =
. tool - groups {
display : flex ;
@@ -4404,6 +4660,32 @@ const handleSave = async () => {
white - space : nowrap ;
}
. kb - option - disabled - hint {
flex - shrink : 0 ;
font - size : 11 px ;
color : var ( -- td - warning - color - 6 , # d46b08 ) ;
background : var ( -- td - warning - color - 1 , # fff7e6 ) ;
padding : 1 px 6 px ;
border - radius : 4 px ;
max - width : 240 px ;
overflow : hidden ;
text - overflow : ellipsis ;
white - space : nowrap ;
}
. agent - type - preset - desc {
margin - top : 4 px ;
color : var ( -- td - text - color - secondary ) ;
font - size : 12 px ;
line - height : 1.5 ;
}
. agent - type - select {
width : 100 % ;
min - width : 240 px ;
max - width : 360 px ;
}
. kb - option - count {
flex - shrink : 0 ;
font - size : 11 px ;
@@ -4475,3 +4757,41 @@ const handleSave = async () => {
}
}
< / style >
<!-- Non - scoped styles : TDesign teleports the popup outside this component , so
scoped selectors can ' t reach . agent - type - popup . t - select - option . -- >
< style lang = "less" >
. agent - type - popup {
. t - select - option {
/ / 默 认 o p t i o n 是 3 2 p x 单 行 ; 我 们 要 双 行 显 示 , 取 消 固 定 高 度 并 放 宽 p a d d i n g
height : auto ! important ;
min - height : 48 px ;
line - height : 1.4 ;
padding : 8 px 12 px ;
white - space : normal ;
}
}
. agent - type - option {
display : flex ;
flex - direction : column ;
gap : 2 px ;
min - width : 0 ;
width : 100 % ;
}
. agent - type - option - label {
font - size : 13 px ;
font - weight : 500 ;
color : var ( -- td - text - color - primary ) ;
line - height : 1.4 ;
}
. agent - type - option - desc {
font - size : 12 px ;
color : var ( -- td - text - color - secondary ) ;
line - height : 1.4 ;
white - space : normal ;
overflow - wrap : break - word ;
}
< / style >