Skip to content

Commit 8f2d5f2

Browse files
committed
fix o1 model test
1 parent 897112c commit 8f2d5f2

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

index.html

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
733733

734734
async function testModel(model) {
735735
const controller = new AbortController();
736-
const id = setTimeout(() => controller.abort(), timeout);
736+
const id = setTimeout(() => controller.abort(), model.startsWith('o1-') ? timeout * 6 : timeout);
737737
const startTime = Date.now();
738738

739739
let response_text;
@@ -742,7 +742,7 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
742742
model: model,
743743
messages: [{role: "user", content: "写一个10个字的冷笑话"}]
744744
};
745-
if (/^(gpt-|chatgpt-|o1-)/.test(model)) {
745+
if (/^(gpt-|chatgpt-)/.test(model)) {
746746
requestBody.seed = 331;
747747
}
748748
const response = await fetch(`${apiUrl}/v1/chat/completions`, {
@@ -757,13 +757,16 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
757757

758758
const endTime = Date.now();
759759
const responseTime = (endTime - startTime) / 1000; // 转换为秒
760-
760+
let has_o1_reason = false;
761761
if (response.ok) {
762762
const data = await response.json();
763763
const returnedModel = data.model || "no returned model by rick"; // 确保 returnedModel 有效
764+
if (returnedModel.startsWith("o1-") && data?.usage?.completion_tokens_details?.reasoning_tokens>0){
765+
has_o1_reason = true;
766+
}
764767
if (returnedModel === model) {
765-
results.valid.push({model, responseTime});
766-
if (/^(gpt-|chatgpt-|o1-)/.test(model)) {
768+
results.valid.push({model, responseTime, has_o1_reason});
769+
if (/^(gpt-|chatgpt-)/.test(model)) {
767770
if (data.system_fingerprint) {
768771
results.awaitOfficialVerification.push({
769772
model,
@@ -773,7 +776,7 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
773776
}
774777
console.log(`测试 API 节点:${apiUrl} 测试模型:${model} 模型一致,响应时间:${responseTime.toFixed(2)} 秒`);
775778
} else {
776-
results.inconsistent.push({model, returnedModel, responseTime});
779+
results.inconsistent.push({model, returnedModel, responseTime, has_o1_reason});
777780
console.log(`测试 API 节点:${apiUrl} 测试模型:${model} 模型不一致,期望:${model},实际:${returnedModel},响应时间:${responseTime.toFixed(2)} 秒`);
778781
}
779782
} else {
@@ -873,38 +876,48 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
873876
'<td class="td2"><span class="copy-btn2" onclick="copyText(\'' + r.model + '\')">' + r.model + '</span></td>' +
874877
'<td class="td3">' + r.responseTime.toFixed(2) + '</td>'
875878

876-
let verifyButtons = `
879+
let verifyButtons = r.model.startsWith('o1-') ? 'o1模型不支持函数、温度、种子功能' : `
877880
<button class="verify-btn cyan" data-tooltip="校验函数功能是否可用,将发起1次请求" onclick="verifyFunctionCalling('${r.model}')">
878881
函数验证
879882
</button>
880883
`;
881-
if (/^(gpt-|chatgpt-|o1-)/.test(r.model) || r.model.startsWith('claude-')) {
884+
if (/^(gpt-|chatgpt-)/.test(r.model) || r.model.startsWith('claude-')) {
882885
let officialButtonClass = results.awaitOfficialVerification.some(item => item.model === r.model) ? "green" : "yellow";
883886
verifyButtons += `
884887
<button class="verify-btn blue" data-tooltip="低温度参数下预测序列下一个值,将发起4次请求" onclick="verifyTemperature('${r.model}')">
885888
温度验证
886889
</button>
887-
${/^(gpt-|chatgpt-|o1-)/.test(r.model) ? `
890+
${/^(gpt-|chatgpt-)/.test(r.model) ? `
888891
<button class="verify-btn ${officialButtonClass}" data-tooltip="相同种子参数下校验回复相似性和系统指纹,将发起4次请求" onclick="verifyOfficial('${r.model}')">
889892
官转验证
890893
</button>
891894
` : ''}
892895
`;
893896
}
894-
content += `<td class="td4"><div class="verify-btn-group">${verifyButtons}</div></td>`;
897+
let o1_response = '';
898+
if (r.model.startsWith('o1-')) {
899+
if (r.has_o1_reason) {
900+
o1_response = `<span style="color: green; font-weight: bold;">返回响应中包含非空 reasoning_tokens,api 可靠</span>`;
901+
} else {
902+
o1_response = `<span style="color: red; font-weight: bold;">返回响应中不包含 reasoning_tokens 或为空,api 非官</span>`;
903+
}
904+
}
905+
content += `<td class="td4"><div class="verify-btn-group">${verifyButtons}</div><br><div class="o1-response">${o1_response}</div></td>`;
895906
});
896907

897908
results.inconsistent.forEach(function (r) {
898-
let verifyButtons = `<button class="verify-btn cyan" data-tooltip="校验函数功能是否可用,将发起1次请求" onclick="verifyFunctionCalling('${r.model}')">
899-
函数验证
900-
</button>`
901-
if (/^(gpt-|chatgpt-|o1-)/.test(r.model) || r.model.startsWith('claude-')) {
909+
let verifyButtons = r.model.startsWith('o1-') ? 'o1模型不支持函数、温度、种子功能' : `
910+
<button class="verify-btn cyan" data-tooltip="校验函数功能是否可用,将发起1次请求" onclick="verifyFunctionCalling('${r.model}')">
911+
函数验证
912+
</button>
913+
`
914+
if (/^(gpt-|chatgpt-)/.test(r.model) || r.model.startsWith('claude-')) {
902915
let officialButtonClass = results.awaitOfficialVerification.some(item => item.model === r.model) ? "green" : "yellow";
903916
verifyButtons += `
904917
<button class="verify-btn blue" data-tooltip="低温度参数下预测序列下一个值,将发起4次请求" onclick="verifyTemperature('${r.model}')">
905918
温度验证
906919
</button>
907-
${/^(gpt-|chatgpt-|o1-)/.test(r.model) ? `
920+
${/^(gpt-|chatgpt-)/.test(r.model) ? `
908921
<button class="verify-btn ${officialButtonClass}" data-tooltip="相同种子参数下校验回复相似性和系统指纹,将发起4次请求" onclick="verifyOfficial('${r.model}')">
909922
官转验证
910923
</button>
@@ -915,6 +928,15 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
915928
if (r.returnedModel.startsWith(`${r.model}-`)){
916929
highlightedReturnModel = `<span style="color: green; font-weight: bold;">${r.model}</span>${r.returnedModel.slice(r.model.length)}<br>可能是带版本号模型映射`;
917930
}
931+
932+
let o1_response = '';
933+
if (r.model.startsWith('o1-')) {
934+
if (r.has_o1_reason) {
935+
o1_response = `<span style="color: green; font-weight: bold;">返回响应中包含非空 reasoning_tokens,api 可靠</span>`;
936+
} else {
937+
o1_response = `<span style="color: red; font-weight: bold;">返回响应中不包含 reasoning_tokens 或为空,api 非官</span>`;
938+
}
939+
}
918940
content += `
919941
<tr>
920942
<td class="td1 td1-no" >模型不一致/映射,tnnd掺假?</td>
@@ -926,6 +948,8 @@ <h3>(适配 oneapi/newapi 等中转格式)</h3>
926948
${verifyButtons}
927949
<br>
928950
${r.returnedModel ? '返回模型: ' + highlightedReturnModel : '该接口未返回模型名称'}
951+
<br>
952+
<div class="o1-response">${o1_response}</div>
929953
</td>
930954
</tr>
931955
`;

0 commit comments

Comments
 (0)