mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 19:23:42 +08:00
Replaces the hardcoded single-DashScope fallback with a DB-driven ordered chain. Same-provider primary deployments (e.g., DashScope qwen-max) finally get a real fallback; if any provider in the chain returns an empty body or transient failure, the next is tried. Schema — DB-driven chain - mate_model_provider gains `fallback_priority INT DEFAULT 0`. Positive values define try-order; 0 = not in chain. Migration V21 (h2 + mysql) seeds DashScope as priority 1 to preserve existing behavior. - ModelProviderService.listFallbackChain() returns providers ordered by priority ascending. - ModelProviderEntity gains the new field. Runtime — chain walk + empty-response trigger - AgentGraphBuilder.buildFallbackChain(primaryConfig) returns a List<ChatModel>, identity-filtering the primary by (providerId, modelName) — fixes the bug where same-provider-primary deployments got null fallback. Providers whose API key is missing are silently skipped with WARN. Old buildFallbackModel(ChatModel) kept as @Deprecated wrapper. - NodeStreamingChatHelper accepts List<ChatModel>; the post-retry fallback block now walks the chain in priority order, single-shot per entry. Old single-fallback constructors retained as @Deprecated one-element-list wrappers so legacy callers keep working. - New ErrorType.EMPTY_RESPONSE: when the LLM returns no content, no thinking, AND no tool calls, mark the result as a soft failure and break the same-model retry loop, handing off directly to the fallback chain. - Broadcast updated to "切换到备选模型 (N/M)..." so SSE consumers see chain progress. Tests - NodeStreamingChatHelperFallbackChainTest covers constructor variants, chain immutability, deprecated-overload back-compat, and the EMPTY_RESPONSE enum exists as a compile-time contract. - 159 tests pass (was 153 + 6 new). |
||
|---|---|---|
| .. | ||
| mate | ||