Skip to content

Commit de4bbce

Browse files
committed
feat: 添加成功提示样式并优化工具调用反馈信息
- 在 OpenAI Tools、Gemini Search 和 Gemini URL Context 场景中,当成功触发工具调用时显示绿色提示,提醒用户回答中仍可能含有事实性错误 - 修正测试场景选择器的查询逻辑,使用 `testTypeWrap` 作为查询范围
1 parent 697eb74 commit de4bbce

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

assets/css/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ body { margin: 0; font-family: system-ui, sans-serif; background: linear-gradien
9696
.error-inline { background: #fff1f2; border: 1px solid #fecdd3; color: #b91c1c; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
9797
.error-inline pre { font-family: ui-monospace, monospace; font-size: 13px; }
9898
.info-inline { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
99+
.success-inline { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
99100
.success-message { color: #059669; margin-top: 8px; display: none; }
100101

101102
/* 对话时间轴消息样式 */

assets/js/script.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@
174174
return el;
175175
}
176176

177+
// Success inline block (green tip)
178+
function addInlineSuccess(text){
179+
const el = document.createElement('div');
180+
el.className = 'success-inline';
181+
el.textContent = String(text || '成功');
182+
messageTimeline.appendChild(el);
183+
scrollLatestIntoView();
184+
return el;
185+
}
186+
177187
// Error inline block under latest message
178188
function addInlineError(text, raw){
179189
const el = document.createElement('div');
@@ -701,7 +711,7 @@
701711
// 发起新请求前自动清空历史记录
702712
clearResults();
703713

704-
const scenario = document.querySelector('.seg-btn.active')?.dataset.scenario || 'openai_tools';
714+
const scenario = testTypeWrap.querySelector('.seg-btn.active')?.dataset.scenario || 'openai_tools';
705715
const endpoint = buildEndpoint(apiUrl);
706716
const geminiEndpoint = buildGeminiEndpoint(apiUrl, model, apiKey);
707717
const anthropicEndpoint = buildAnthropicEndpoint(apiUrl);
@@ -1028,6 +1038,8 @@
10281038
// 未触发搜索工具调用的提示放在响应下面
10291039
if(!hasWebSearchCall){
10301040
addInlineInfo('未触发搜索工具调用:模型可能未理解指令,或 API 异常。');
1041+
} else {
1042+
addInlineSuccess('模型成功进行了搜索工具调用,但回答中仍可能含有事实性错误');
10311043
}
10321044
}
10331045
else if(scenario === 'gemini_search'){
@@ -1049,6 +1061,8 @@
10491061
const hasGroundingMetadata = cand && cand.groundingMetadata;
10501062
if(!hasGroundingMetadata){
10511063
addInlineInfo('未触发搜索工具调用:模型可能未理解指令,或 API 异常。');
1064+
} else {
1065+
addInlineSuccess('模型成功进行了搜索工具调用,但回答中仍可能含有事实性错误');
10521066
}
10531067
}
10541068
else if(scenario === 'gemini_url_context'){
@@ -1070,6 +1084,8 @@
10701084
const hasGroundingMetadata = cand && cand.groundingMetadata;
10711085
if(!hasGroundingMetadata){
10721086
addInlineInfo('未触发 URL 上下文工具调用:模型可能未理解指令,或 API 异常。');
1087+
} else {
1088+
addInlineSuccess('模型成功进行了搜索工具调用,但回答中仍可能含有事实性错误');
10731089
}
10741090
}
10751091

0 commit comments

Comments
 (0)