Skip to content

Commit aeb7b7d

Browse files
committed
优化温度测试模型提示和版本号模型提示
1 parent 92baffc commit aeb7b7d

File tree

1 file changed

+63
-24
lines changed

1 file changed

+63
-24
lines changed

index.html

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
843843
function displayResults(results) {
844844
const resultsDiv = document.getElementById('results');
845845
let content = '<h2>测试结果</h2>' +
846+
'<h3>(结果仅供参考,防君子不防小人)</h3>' +
846847
'<div class="copy-buttons">' +
847848
'<div className="submit-container">' +
848849
'<button class="check-quota copy-btn" onclick="copyConsistentModels()">复制一致模型</button>' +
@@ -902,6 +903,10 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
902903
` : ''}
903904
`;
904905
}
906+
let highlightedReturnModel = r.returnedModel;
907+
if (r.returnedModel.startsWith(`${r.model}-`)){
908+
highlightedReturnModel = `<span style="color: green; font-weight: bold;">${r.model}</span>${r.returnedModel.slice(r.model.length)}<br>可能是带版本号模型映射`;
909+
}
905910
content += `
906911
<tr>
907912
<td class="td1 td1-no" >模型不一致/映射,tnnd掺假?</td>
@@ -912,7 +917,7 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
912917
<td class="td4">
913918
${verifyButtons}
914919
<br>
915-
${r.returnedModel ? '返回模型: ' + r.returnedModel : '该接口未返回模型名称'}
920+
${r.returnedModel ? '返回模型: ' + highlightedReturnModel : '该接口未返回模型名称'}
916921
</td>
917922
</tr>
918923
`;
@@ -946,6 +951,22 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
946951
});
947952
});
948953
}
954+
function findMostFrequent(arr) {
955+
const frequency = {};
956+
let maxCount = 0;
957+
let mostFrequentElement = null;
958+
959+
for (const item of arr) {
960+
frequency[item] = (frequency[item] || 0) + 1;
961+
962+
if (frequency[item] > maxCount) {
963+
maxCount = frequency[item];
964+
mostFrequentElement = item;
965+
}
966+
}
967+
968+
return { element: mostFrequentElement, count: maxCount };
969+
}
949970
async function verifyTemperature(model) {
950971
layui.use("layer", function () {
951972
const layer = layui.layer;
@@ -957,19 +978,19 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
957978
[1, 2, 3, 4].map(() => sendTemperatureVerificationRequest(model))
958979
);
959980
const responses = results.map((result) =>
960-
result.choices[0].message.content.trim()
981+
result.choices
982+
? result?.choices?.[0]?.message?.content?.trim()
983+
: "该次调用响应异常"
961984
);
962-
let referenceValue;
963-
if (model.startsWith("gpt-4o-mini")) {
964-
referenceValue = 32;
965-
} else if (model.startsWith("gpt-4o")) {
966-
referenceValue = 59;
967-
} else if (model.startsWith("claude-3-5") || model.startsWith("claude-3.5")) {
968-
referenceValue = 51;
969-
}
970-
else{
971-
referenceValue = null;
972-
}
985+
const referenceMap = {
986+
"gpt-4o-mini": 32,
987+
"gpt-4o": 59,
988+
"claude-3-5": 51,
989+
"claude-3.5": 51
990+
};
991+
const matchedKey = Object.keys(referenceMap).find(key => model.startsWith(key));
992+
let referenceValue = matchedKey ? referenceMap[matchedKey] : null;
993+
973994
layui.use("layer", function () {
974995
const layer = layui.layer;
975996
layer.closeAll("loading");
@@ -978,10 +999,19 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
978999
message +=
9791000
'<table style="width:100%; border-collapse: collapse; margin-bottom: 20px;">' +
9801001
'<tr><th style="border: 1px solid #ddd; padding: 4px;">测试</th><th style="border: 1px solid #ddd; padding: 4px;">响应</th></tr>';
981-
1002+
let hitReferenceCount = 0;
1003+
let color;
9821004
for (let i = 0; i < 4; i++) {
983-
984-
let color = responses[i] == referenceValue ? "green" : "black";
1005+
if (responses[i] == referenceValue) {
1006+
hitReferenceCount++;
1007+
color = "green";
1008+
}
1009+
else if (responses[i] == "该次调用响应失败"){
1010+
color = "red"
1011+
}
1012+
else{
1013+
color = "black";
1014+
}
9851015
message +=
9861016
"<tr>" +
9871017
'<td style="border: 1px solid #ddd; padding: 4px;">测试 ' +
@@ -993,17 +1023,26 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
9931023
"</tr>";
9941024
}
9951025

996-
message += "</table>";
1026+
message += "</table><strong>结论:</strong>";
9971027

998-
const allSame = responses.every((val) => val === responses[0]);
999-
message +=
1000-
"<strong>结论:</strong> " +
1001-
(allSame
1002-
? "所有响应相同,可能是官方API"
1003-
: "响应不同,可能不是官方API");
1028+
frequencyCheckResult = findMostFrequent(responses);
1029+
const diffentCount = frequencyCheckResult.count;
1030+
1031+
if (diffentCount === responses.length) {
1032+
message += "所有响应相同,可能是官方API";
1033+
} else {
1034+
message += `响应结果重复度:${diffentCount}/${responses.length}`;
1035+
// 检查模型前缀是否符合条件
1036+
if (/^(gpt-4o|claude-3-5|claude-3.5)/.test(model)) {
1037+
message += `,参考值命中率:${hitReferenceCount}/${responses.length}`;
1038+
}
1039+
message += ",可能不是官方API";
1040+
}
1041+
1042+
message += "<br>";
10041043

10051044
layer.alert(message, {
1006-
title: "温度验证结果",
1045+
title: "温度验证结果(<strong>无参考值模型请自行根据结果重复度判断</strong>)",
10071046
area: ["600px", "400px"],
10081047
});
10091048
});

0 commit comments

Comments
 (0)