这是超时信息:
2026-01-13T03:03:04.886Z [CloudLLM] Calling deepseek-v3.2...
2026-01-13T03:03:04.886Z [CloudLLM] Initializing Auth & Model...
2026-01-13T03:03:05.670Z [CloudLLM] Sign in success
2026-01-13T03:03:50.696Z [CloudLLM] API Error: Error: LLM API Timeout (45s)
at Timeout._onTimeout (/var/user/utils/llm_client.js:77:37)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
这是代码:
try {
console.log('[CloudLLM] Initializing Auth & Model...');
await auth.signInAnonymously();
console.log('[CloudLLM] Sign in success');
const ai = app.ai();
const model = ai.createModel("deepseek");
_aiModel = model; // Set cache
return model;
} catch (authErr) {
console.warn('[CloudLLM] Auth Warning (proceeding):', authErr.message);
// Retry or proceed
const ai = app.ai();
_aiModel = ai.createModel("deepseek");
return _aiModel;
}
try {
console.log(`[CloudLLM] Calling ${model}...`);
const aiModel = await getAIModel();
// 4. Call Model with 45s Timeout Guard (Prevent 60s Function Kill)
const callPromise = _aiModel.generateText({
model: model,
messages: messages,
temperature: 0.8
});
const timeoutPromise = new Promise((_, reject) =>
setTimeout(() => reject(new Error("LLM API Timeout (45s)")), 45000)
);
const res = await Promise.race([callPromise, timeoutPromise]);
// Debug response structure
if (!res) throw new Error("Empty Response from CloudBase AI");
if (res.text) return res.text;
console.warn("[CloudLLM] Unexpected response structure:", JSON.stringify(res).substring(0, 200));
return JSON.stringify(res);
} catch (err) {
console.error('[CloudLLM] API Error:', err);
// Normalize error for caller
throw new Error(`LLM Call Failed: ${err.message || err.toString()} (Model: ${model})`);
}

generateText这个是非流式文本生成api,一次性返回结果,这样在云函数里面估计会经常超时吧。
建议是在小程序端用streamText进行流式输出
1.没有看到错误码。2. 完全45秒的超时出现过几次,但是经常是20-40秒才返回,这个现在非常多。看我后面的日志。3.我看到调用次数即将超额,是这个原因造成的吗?我不太清楚为什么调用次数会那么多,这个怎么分析?是否可以增加调用次数?
026-01-13T08:34:26.934Z [CloudLLM] Calling deepseek-v3.2...
2026-01-13T08:34:26.935Z [CloudLLM] Initializing Auth & Model...
2026-01-13T08:34:27.784Z [CloudLLM] Sign in success
2026-01-13T08:34:50.664Z [Distiller] ⏭️ Skipped Rule