@@ -134,6 +134,23 @@
/* 工具调用记录显示 */
. tool-call-record { margin-top : 8 px ; padding : 8 px 12 px ; background : #e8f5e9 ; border-radius : 8 px ; font-size : 12 px ; color : #10a37f ; }
. tool-call-record i { margin-right : 4 px ; }
/* Agent信息侧边栏 */
. agent-info-sidebar { width : 200 px ; background : #f8f9fa ; border-right : 1 px solid #e0e0e0 ; padding : 16 px ; display : flex ; flex-direction : column ; }
. agent-info-header { display : flex ; align-items : center ; gap : 8 px ; margin-bottom : 12 px ; }
. agent-avatar { width : 48 px ; height : 48 px ; background : linear-gradient ( 135 deg , #667eea 0 % , #764ba2 100 % ) ; border-radius : 12 px ; display : flex ; align-items : center ; justify-content : center ; color : white ; font-size : 24 px ; }
. agent-name-area { flex : 1 ; }
. agent-name-area h3 { font-size : 16 px ; margin : 0 ; color : #333 ; }
. agent-name-area small { color : #999 ; font-size : 12 px ; }
. agent-info-section { margin-top : 16 px ; }
. agent-info-section h4 { font-size : 13 px ; color : #666 ; margin : 0 0 8 px 0 ; font-weight : 500 ; }
. agent-info-section p { font-size : 12 px ; color : #333 ; line-height : 1.5 ; margin : 0 ; }
. agent-capabilities { display : flex ; flex-wrap : wrap ; gap : 6 px ; margin-top : 8 px ; }
. capability-tag { padding : 4 px 8 px ; background : #e8f5e9 ; border-radius : 6 px ; font-size : 11 px ; color : #10a37f ; }
. capability-tag . disabled { background : #f5f5f5 ; color : #999 ; }
. agent-model-info { margin-top : 12 px ; padding : 8 px ; background : white ; border-radius : 8 px ; border : 1 px solid #e0e0e0 ; }
. agent-model-info label { font-size : 11 px ; color : #999 ; }
. agent-model-info span { font-size : 12 px ; color : #333 ; display : block ; margin-top : 2 px ; }
. add-phrase-btn { padding : 6 px 10 px ; background : #f0f0f0 ; border : 1 px solid #ddd ; border-radius : 6 px ; cursor : pointer ; font-size : 12 px ; color : #666 ; white-space : nowrap ; flex-shrink : 0 ; }
. add-phrase-btn : hover { background : #e8e8e8 ; }
. phrase-list-wrapper { flex : 1 ; overflow-x : auto ; overflow-y : hidden ; scrollbar-width : thin ; }
@@ -191,8 +208,37 @@
< / div >
< / div >
< div class = "messages-container" id = "messagesContainer" >
< div class = "welcome" > < h2 > 👋 开始对话< / h2 > < p > 选择Agent, 开始聊天< / p > < / div >
<!-- 对话区域: 左侧Agent信息 + 右侧消息 -- >
< div class = "chat-area" style = "display:flex;flex:1;overflow:hidden;" >
<!-- Agent信息侧边栏 -->
< div class = "agent-info-sidebar" id = "agentInfoSidebar" >
< div class = "agent-info-header" >
< div class = "agent-avatar" id = "agentAvatar" > 🤖< / div >
< div class = "agent-name-area" >
< h3 id = "agentDisplayName" > 加载中...< / h3 >
< small id = "agentName" > agent-name< / small >
< / div >
< / div >
< div class = "agent-info-section" >
< h4 > 简介< / h4 >
< p id = "agentDescription" > -< / p >
< / div >
< div class = "agent-info-section" >
< h4 > 能力< / h4 >
< div class = "agent-capabilities" id = "agentCapabilities" >
<!-- 动态渲染 -->
< / div >
< / div >
< div class = "agent-model-info" >
< label > 模型< / label >
< span id = "agentModelInfo" > -< / span >
< / div >
< / div >
<!-- 消息容器 -->
< div class = "messages-container" id = "messagesContainer" style = "flex:1;" >
< div class = "welcome" > < h2 > 👋 开始对话< / h2 > < p > 选择Agent, 开始聊天< / p > < / div >
< / div >
< / div >
< div class = "input-container" >
@@ -293,8 +339,8 @@
const res = await fetch ( '/api/v2/providers' ) ;
const data = await res . json ( ) ;
providers = data . providers || [ ] ;
// 加载后检查工具支持 ( 如果agents已加载)
if ( agents . length > 0 ) showToolWarning ( ) ;
// 加载后更新Agent信息侧边栏 ( 如果agents已加载)
if ( agents . length > 0 ) renderAgentInfoSidebar ( ) ;
} catch ( e ) { console . error ( '加载Provider失败:' , e ) ; }
}
@@ -323,9 +369,58 @@
const defaultAgent = agents . find ( a => a . is _default ) || agents [ 0 ] ;
if ( defaultAgent ) currentAgentId = defaultAgent . id ;
renderAgentSelect ( ) ;
renderAgentInfoSidebar ( ) ; // 渲染Agent信息侧边栏
} catch ( e ) { console . error ( '加载Agent失败:' , e ) ; }
}
// 渲染Agent信息侧边栏
function renderAgentInfoSidebar ( ) {
const agent = agents . find ( a => a . id === currentAgentId ) ;
if ( ! agent ) return ;
// 更新名称
document . getElementById ( 'agentDisplayName' ) . textContent = agent . display _name || agent . name ;
document . getElementById ( 'agentName' ) . textContent = agent . name ;
// 更新头像( 用emoji或首字母)
const avatar = document . getElementById ( 'agentAvatar' ) ;
avatar . textContent = agent . display _name ? . charAt ( 0 ) || agent . name ? . charAt ( 0 ) || '🤖' ;
// 更新描述
document . getElementById ( 'agentDescription' ) . textContent = agent . description || '暂无描述' ;
// 更新能力标签
const capabilitiesHtml = [ ] ;
// 检查思考能力
const provider = providers . find ( p => p . id === agent . llm _provider _id ) ;
if ( provider ) {
if ( provider . supports _thinking ) {
capabilitiesHtml . push ( '<span class="capability-tag"><i class="ri-lightbulb-line"></i> 思考</span>' ) ;
}
if ( provider . supports _vision ) {
capabilitiesHtml . push ( '<span class="capability-tag"><i class="ri-image-line"></i> 视觉</span>' ) ;
}
if ( provider . supports _function _calling ) {
capabilitiesHtml . push ( '<span class="capability-tag"><i class="ri-tools-line"></i> 工具调用</span>' ) ;
} else {
capabilitiesHtml . push ( '<span class="capability-tag disabled"><i class="ri-tools-line"></i> 工具(手动)</span>' ) ;
}
// 更新模型信息
const model = agent . model _override || provider . default _model || 'auto' ;
document . getElementById ( 'agentModelInfo' ) . textContent = model ;
}
// 检查工具配置
const agentTools = agent . tools || [ ] ;
if ( agentTools . includes ( 'search' ) ) {
capabilitiesHtml . push ( '<span class="capability-tag"><i class="ri-search-line"></i> 搜索</span>' ) ;
}
document . getElementById ( 'agentCapabilities' ) . innerHTML = capabilitiesHtml . join ( '' ) || '<span class="capability-tag disabled">基础对话</span>' ;
}
function renderAgentSelect ( ) {
const select = document . getElementById ( 'agentSelect' ) ;
select . innerHTML = agents . filter ( a => a . is _active ) . map ( a =>
@@ -345,6 +440,7 @@
if ( ws ? . readyState === WebSocket . OPEN ) ws . send ( JSON . stringify ( { action : 'switch_agent' , agent _id : currentAgentId } ) ) ;
await createNewConversation ( ) ;
showAgentSwitchNotice ( ) ;
renderAgentInfoSidebar ( ) ; // 更新侧边栏信息
}
}