Skip to content

Commit bd59148

Browse files
committed
feature: temperatureVerification v1.3.3
1 parent e1e9960 commit bd59148

File tree

1 file changed

+152
-13
lines changed

1 file changed

+152
-13
lines changed

index.html

Lines changed: 152 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html>
33
<head>
44
<meta charset="UTF-8">
55
<title>API CHECKER</title>
@@ -228,12 +228,26 @@
228228
color: white;
229229
}
230230

231-
.verify-btn {
232-
background-color: #ffc107;
231+
.verify-btn.blue {
232+
background-color: #3498db;
233+
color: white;
233234
}
234-
235-
.verify-btn {
236-
background-color: #28a745;
235+
.verify-btn.blue:hover {
236+
background-color: #2980b9;
237+
}
238+
.verify-btn.green {
239+
background-color: #28a745;
240+
color: white;
241+
}
242+
.verify-btn.green:hover {
243+
background-color: #218838;
244+
}
245+
.verify-btn.yellow {
246+
background-color: #ffc107;
247+
color: white;
248+
}
249+
.verify-btn.yellow:hover {
250+
background-color: #e0a800;
237251
}
238252

239253
.model-filter-container {
@@ -403,7 +417,9 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
403417
<br>贡献者:<a href="https://linux.do/u/rick" target="_blank"><img
404418
src="https://linux.do/user_avatar/linux.do/rick/288/137821_2.png" alt="rick">rick </a><a
405419
href="https://linux.do/u/zhong_little" target="_blank"><img
406-
src="https://linux.do/user_avatar/linux.do/zhong_little/288/104887_2.png" alt="Megasoft">Megasoft</a></p>
420+
src="https://linux.do/user_avatar/linux.do/zhong_little/288/104887_2.png" alt="Megasoft">Megasoft</a><a
421+
href="https://linux.do/u/fangyuan99" target="_blank"><img
422+
src="https://linux.do/letter_avatar_proxy/v4/letter/f/b3f665/144.png" alt="fangyuan99">fangyuan99</a></p>
407423
</div>
408424
<div id="results" class="response-container"></div>
409425

@@ -423,14 +439,16 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
423439
<div>🖱️ 测试全在本地进行</div>
424440
<div>🎉 等待结果并查看详细报告</div>
425441
<div>🕵️ 使用“官转验证”功能确认API的真实性</div>
442+
<div>🕵️‍♀️ 使用“温度验证”功能确认API的真实性</div>
426443
</ul>
427444
<br>
428445
<p><strong>版本历史:</strong></p>
429446
<div><a href="https://linux.do/t/topic/191420" target="_blank" style="color: #1e88e5">v1.3版本介绍</a></div>
430447
<div><a href="https://linux.do/t/topic/190955" target="_blank" style="color: #1e88e5">v1.2版本介绍</a></div>
431448
<br>
432449
<p><strong>Tips:</strong></p>
433-
<div>GPT系列,才有官转验证,系统判断仅供参考,原理请看 <a href="https://linux.do/t/topic/191420" target="_blank" style="color: #1e88e5">v1.3版本介绍</a></div>
450+
<div>🌱GPT系列,才有官转验证,系统判断仅供参考,原理请看 <a href="https://linux.do/t/topic/191420" target="_blank" style="color: #1e88e5">v1.3版本介绍</a></div>
451+
<div>🌡️ 温度验证:低温度参数下,大模型回复的稳定性。测试结果仅供参考,原理请看 <a href="https://linux.do/t/topic/195972" target="_blank" style="color: #1e88e5">温度验证</a></div>
434452
</div>
435453
`;
436454
const toast = document.createElement('div');
@@ -808,12 +826,21 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
808826
'<td class="td2"><span class="copy-btn2"" onclick="copyText(\'' + r.model + '\')">' + r.model + '</span></td>' +
809827
'<td class="td3">' + r.responseTime.toFixed(2) + '</td>'
810828

811-
let verifyButton = '';
812-
if (r.model.startsWith('gpt-')) {
813-
let buttonClass = results.awaitOfficialVerification.some(item => item.model === r.model) ? 'green' : 'yellow';
814-
verifyButton = '<button class="verify-btn ' + buttonClass + '" onclick="verifyOfficial(\'' + r.model + '\')">官转验证</button>';
829+
let verifyButtons = '';
830+
if (r.model.startsWith('gpt-') || r.model.startsWith('claude-')) {
831+
let officialButtonClass = results.awaitOfficialVerification.some(item => item.model === r.model) ? "green" : "yellow";
832+
verifyButtons =
833+
'<button class="verify-btn blue" onclick="verifyTemperature(\'' +
834+
r.model +
835+
"')\">温度验证</button>" +
836+
(r.model.startsWith('gpt-') ?
837+
'<button class="verify-btn ' +
838+
officialButtonClass +
839+
'" onclick="verifyOfficial(\'' +
840+
r.model +
841+
"')\">官转验证</button>" : '');
815842
}
816-
content += '<td class="td4">' + verifyButton + '</td>'
843+
content += '<td class="td4">' + verifyButtons + '</td>'
817844
});
818845

819846
results.inconsistent.forEach(function (r) {
@@ -854,6 +881,118 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
854881
});
855882
});
856883
}
884+
async function verifyTemperature(model) {
885+
layui.use("layer", function () {
886+
const layer = layui.layer;
887+
layer.load();
888+
});
889+
890+
try {
891+
const results = await Promise.all(
892+
[1, 2, 3, 4].map(() => sendTemperatureVerificationRequest(model))
893+
);
894+
const responses = results.map((result) =>
895+
result.choices[0].message.content.trim()
896+
);
897+
let referenceValue;
898+
if (model.startsWith("gpt-4o-mini")) {
899+
referenceValue = 32;
900+
} else if (model.startsWith("gpt-4o")) {
901+
referenceValue = 59;
902+
} else if (model.startsWith("claude-3-5") || model.startsWith("claude-3.5")) {
903+
referenceValue = 51;
904+
}
905+
else{
906+
referenceValue = null;
907+
}
908+
layui.use("layer", function () {
909+
const layer = layui.layer;
910+
layer.closeAll("loading");
911+
912+
let message = `<strong>当前待验证模型:${model}</strong><p>参考值:c3.5 = 51(gcp测试),gpt-4o = 59,gpt-4o-mini = 32(azure测试)</p><br><br>`;
913+
message +=
914+
'<table style="width:100%; border-collapse: collapse; margin-bottom: 20px;">' +
915+
'<tr><th style="border: 1px solid #ddd; padding: 8px;">测试</th><th style="border: 1px solid #ddd; padding: 8px;">响应</th></tr>';
916+
917+
for (let i = 0; i < 4; i++) {
918+
919+
let color = responses[i] == referenceValue ? "green" : "black";
920+
message +=
921+
"<tr>" +
922+
'<td style="border: 1px solid #ddd; padding: 8px;">测试 ' +
923+
(i + 1) +
924+
"</td>" +
925+
`<td style="border: 1px solid #ddd; padding: 8px; color: ${color};">` +
926+
responses[i] +
927+
"</td>" +
928+
"</tr>";
929+
}
930+
931+
message += "</table>";
932+
933+
const allSame = responses.every((val) => val === responses[0]);
934+
message +=
935+
"<strong>结论:</strong> " +
936+
(allSame
937+
? "所有响应相同,可能是官方API"
938+
: "响应不同,可能不是官方API");
939+
940+
layer.alert(message, {
941+
title: "温度验证结果",
942+
area: ["600px", "400px"],
943+
});
944+
});
945+
} catch (error) {
946+
console.error("Error in verifyTemperature:", error);
947+
layui.use("layer", function () {
948+
const layer = layui.layer;
949+
layer.closeAll("loading");
950+
layer.alert("验证过程中发生错误: " + error.message, {
951+
title: "错误",
952+
});
953+
});
954+
}
955+
}
956+
957+
async function sendTemperatureVerificationRequest(model) {
958+
const apiUrl = document
959+
.getElementById("api_url")
960+
.value.replace(/\/+$/, "");
961+
const apiKey = document.getElementById("api_key").value;
962+
try {
963+
const response = await fetch(`${apiUrl}/v1/chat/completions`, {
964+
method: "POST",
965+
headers: {
966+
Authorization: `Bearer ${apiKey}`,
967+
"Content-Type": "application/json",
968+
},
969+
body: JSON.stringify({
970+
messages: [
971+
{
972+
role: "system",
973+
content:
974+
"You're an associative thinker. The user gives you a sequence of 6 numbers. Your task is to figure out and provide the 7th number directly, without explaining how you got there.",
975+
},
976+
{
977+
role: "user",
978+
content: "5, 15, 77, 19, 53, 54,",
979+
},
980+
],
981+
temperature: 0.01,
982+
model: model,
983+
}),
984+
});
985+
986+
if (!response.ok) {
987+
throw new Error(`HTTP error! status: ${response.status}`);
988+
}
989+
990+
return await response.json();
991+
} catch (error) {
992+
console.error("Error in sendTemperatureVerificationRequest:", error);
993+
return { error: error.message };
994+
}
995+
}
857996

858997
async function performOfficialVerification(model, seed) {
859998
layui.use('layer', function () {

0 commit comments

Comments
 (0)