fix(wechat): fallback manage LLM providers when chat balance is exhausted
Memind CI / Test, build, and release guards (push) Failing after 4m34s
Memind CI / Test, build, and release guards (push) Failing after 4m34s
When DeepSeek returns 402, try other chat providers before giving up, and cancel the sole active task only during LLM outages so user 123 can cancel without Goose. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -83,3 +83,32 @@ test('resolveScheduledTaskCancelWithLlm returns clarify when ambiguous', async (
|
||||
assert.equal(reply.action, 'clarify');
|
||||
assert.match(reply.message, /新闻早报/u);
|
||||
});
|
||||
|
||||
test('resolveScheduledTaskCancelWithLlm falls back to another provider when primary is unavailable', async () => {
|
||||
const calls = [];
|
||||
const reply = await resolveScheduledTaskCancelWithLlm({
|
||||
text: '取消定时推送苏州天气任务',
|
||||
tasks: [tasks[0]],
|
||||
modelProviderKeyId: 'deepseek-key',
|
||||
llmProviderService: {
|
||||
async listKeys() {
|
||||
return [
|
||||
{ id: 'deepseek-key', name: 'DeepSeek', status: 'active', defaultModel: 'deepseek-chat', models: ['deepseek-chat'] },
|
||||
{ id: 'kimi-key', name: 'kimi', status: 'active', defaultModel: 'kimi-k2.6', models: ['kimi-k2.6'] },
|
||||
];
|
||||
},
|
||||
async createChatCompletion(payload) {
|
||||
calls.push(payload.providerKeyId ?? 'default');
|
||||
if ((payload.providerKeyId ?? 'default') !== 'kimi-key') {
|
||||
return { ok: false, status: 402, message: '{"error":{"message":"Insufficient Balance"}}' };
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
reply: JSON.stringify({ action: 'cancel', taskId: 'task-suzhou' }),
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
assert.deepEqual(reply, { action: 'cancel', taskId: 'task-suzhou' });
|
||||
assert.deepEqual(calls, ['deepseek-key', 'default', 'kimi-key']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user