fix: address code review - remove duplicate model, fix null refs, improve email masking
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
6487a8b2f0
commit
1999a55091
|
|
@ -261,7 +261,9 @@ jobs:
|
||||||
const email = '${{ steps.parse.outputs.email }}';
|
const email = '${{ steps.parse.outputs.email }}';
|
||||||
|
|
||||||
const typeLabel = type === 'syslog' ? 'SYSLOG 闭环处理' : '问题解答';
|
const typeLabel = type === 'syslog' ? 'SYSLOG 闭环处理' : '问题解答';
|
||||||
const maskedEmail = email.replace(/(.{2})(.*)(@.*)/, '$1***$3');
|
const maskedEmail = email.length > 4
|
||||||
|
? email.replace(/(.{2})(.*)(@.*)/, '$1***$3')
|
||||||
|
: '***';
|
||||||
|
|
||||||
const body = [
|
const body = [
|
||||||
'✅ **已处理** · ' + typeLabel,
|
'✅ **已处理** · ' + typeLabel,
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,10 @@ const AUTHOR = process.env.AUTHOR || 'unknown';
|
||||||
// Claude 模型优先级队列(从高到低)
|
// Claude 模型优先级队列(从高到低)
|
||||||
const PREFERRED_MODELS = [
|
const PREFERRED_MODELS = [
|
||||||
'claude-sonnet-4',
|
'claude-sonnet-4',
|
||||||
'claude-3.5-sonnet',
|
|
||||||
'claude-3-5-sonnet-20241022',
|
'claude-3-5-sonnet-20241022',
|
||||||
|
'claude-3.5-sonnet',
|
||||||
'claude-3-5-sonnet',
|
'claude-3-5-sonnet',
|
||||||
'anthropic/claude-3.5-sonnet',
|
'anthropic/claude-3.5-sonnet',
|
||||||
'anthropic/claude-3-5-sonnet',
|
|
||||||
'claude-3-sonnet',
|
'claude-3-sonnet',
|
||||||
'claude-3-haiku',
|
'claude-3-haiku',
|
||||||
];
|
];
|
||||||
|
|
@ -132,18 +131,22 @@ function selectBestModel(models) {
|
||||||
for (const preferred of PREFERRED_MODELS) {
|
for (const preferred of PREFERRED_MODELS) {
|
||||||
const match = available.find(function (id) { return id.includes(preferred); });
|
const match = available.find(function (id) { return id.includes(preferred); });
|
||||||
if (match) {
|
if (match) {
|
||||||
const originalId = models.find(function (m) { return m.id.toLowerCase() === match; }).id;
|
const found = models.find(function (m) { return m.id.toLowerCase() === match; });
|
||||||
console.log('[LLM] 📌 选择模型: ' + originalId + ' (匹配规则: ' + preferred + ')');
|
if (found) {
|
||||||
return originalId;
|
console.log('[LLM] 📌 选择模型: ' + found.id + ' (匹配规则: ' + preferred + ')');
|
||||||
|
return found.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兜底:任何含 'claude' 的模型
|
// 兜底:任何含 'claude' 的模型
|
||||||
const anyClaude = available.find(function (id) { return id.includes('claude'); });
|
const anyClaude = available.find(function (id) { return id.includes('claude'); });
|
||||||
if (anyClaude) {
|
if (anyClaude) {
|
||||||
const originalId = models.find(function (m) { return m.id.toLowerCase() === anyClaude; }).id;
|
const found = models.find(function (m) { return m.id.toLowerCase() === anyClaude; });
|
||||||
console.log('[LLM] 📌 兜底选择 Claude 模型: ' + originalId);
|
if (found) {
|
||||||
return originalId;
|
console.log('[LLM] 📌 兜底选择 Claude 模型: ' + found.id);
|
||||||
|
return found.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最终兜底:平台第一个可用模型
|
// 最终兜底:平台第一个可用模型
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue