fix: 隐藏错误消息中的环境变量名 + 清理定时器优雅退出
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/576c1b97-3ce4-4c28-99f1-9374e2320212 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
fdc2ac0035
commit
e8a6cb4f89
|
|
@ -147,7 +147,7 @@ function callDomesticLLM(modelConfig, messages) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const apiKey = process.env[modelConfig.envKey] || '';
|
const apiKey = process.env[modelConfig.envKey] || '';
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
return reject(new Error(`API密钥未配置: ${modelConfig.envKey}`));
|
return reject(new Error('模型API密钥未配置'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(modelConfig.endpoint);
|
const url = new URL(modelConfig.endpoint);
|
||||||
|
|
@ -250,7 +250,7 @@ function getContext(userId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定期清理过期会话
|
// 定期清理过期会话
|
||||||
setInterval(() => {
|
const _cleanupTimer = setInterval(() => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const [key, val] of contexts) {
|
for (const [key, val] of contexts) {
|
||||||
if (now - val.lastActive > CONTEXT_TTL_MS) {
|
if (now - val.lastActive > CONTEXT_TTL_MS) {
|
||||||
|
|
@ -258,6 +258,8 @@ setInterval(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 300000); // 每5分钟清理一次
|
}, 300000); // 每5分钟清理一次
|
||||||
|
// 允许进程优雅退出
|
||||||
|
if (_cleanupTimer.unref) _cleanupTimer.unref();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国内模型智能对话(带自动降级)
|
* 国内模型智能对话(带自动降级)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue