[Fix] fallback from unavailable conversation models#862
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
Walkthrough该PR通过在模型解析过程中添加平台侧可用性校验,解决已有会话使用不可用旧模型时直接报错的问题。当模型不存在时,系统现在会跳过该模型并自动回退到配置的默认模型,而非中断流程。 Changes模型可用性校验与智能回退
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust model resolution mechanism by adding hasModel and pickModel utilities to verify model availability against the platform registry. The ConversationService now uses these utilities to determine the effectiveModel by prioritizing fixed models, conversation-specific models, and defaults. Feedback suggests refactoring the duplicated resolution logic into a private helper method and addressing a minor redundancy where the global default model may be checked multiple times.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/services/conversation.ts`:
- Around line 121-147: hasModel is a single-use helper used only by pickModel,
so inline its logic into pickModel: remove the standalone hasModel function and
update pickModel to iterate over the input models array, for each model perform
the same null/empty/placeholder checks (model == null, model.trim().length < 1,
model === '无' or 'empty'), call parseRawModelName(model) and skip if platform or
name is null, fetch available models via
ctx.chatluna.platform.listPlatformModels(platform, ModelType.llm).value and
return the first model string whose name matches an entry in that list (or
return null if none match); keep references to Context, parseRawModelName, and
ModelType.llm as in the original code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1e5932ba-262d-4d04-9cb5-14f07f0c581b
📒 Files selected for processing (4)
packages/core/src/middlewares/model/resolve_model.tspackages/core/src/services/conversation.tspackages/core/tests/conversation-service.spec.tspackages/core/tests/helpers.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8021fd82e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This pr fixes conversation model resolution so existing conversations with unavailable saved models fall back to a valid configured model instead of failing every request.
Fixes #861
New Features
None
Bug fixes
resolve_modelfrom reusing the stale saved conversation model aftereffectiveModelhas already been resolved.Other Changes
ConversationServiceso fallback behavior is bound to service state.ConversationService.pickModel()for middleware and trigger paths that need the same fallback decision.