fix: restore LLM model values in reapply_all_settings fallback (#1587)#1850
fix: restore LLM model values in reapply_all_settings fallback (#1587)#1850hunterxtang wants to merge 3 commits into
Conversation
…low-ai#1587) The fallback branch of _update_langflow_model_values() only refreshed embedding providers, so LLM selections reverted to stale/default models after a flow reset. Add an LLM provider loop mirroring the embedding logic: current provider gets config.agent.llm_model, others get None (first available), all with force_llm_update=True. Guards config.agent.llm_provider against None before .lower().
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR fixes bug ChangesLLM Provider Fallback for Bug
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/api/settings/langflow_sync.py (1)
154-157:⚠️ Potential issue | 🟠 MajorGuard LLM provider normalization when
config.agent.llm_providercan beNone(explicit update path).
src/api/settings/langflow_sync.pylines 155-156 call.lower()onconfig.agent.llm_providerwithout a None-guard; ifllm_modelis provided while the stored provider isNone, this branch can throwAttributeErrorinstead of using the null-safe fallback logic.Suggested fix
if llm_model or llm_provider: - effective_llm_provider = (llm_provider or config.agent.llm_provider).lower() - if llm_provider and llm_provider.lower() != config.agent.llm_provider.lower(): + configured_llm_provider = (config.agent.llm_provider or "").lower() + effective_llm_provider = (llm_provider or configured_llm_provider).lower() + if not effective_llm_provider: + raise ValueError("LLM provider is required when updating LLM model values") + if llm_provider and llm_provider.lower() != configured_llm_provider: effective_llm_model = llm_model # do not fall back; force caller to specify else: effective_llm_model = llm_model or config.agent.llm_model🤖 Prompt for 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. In `@src/api/settings/langflow_sync.py` around lines 154 - 157, The branch that computes effective_llm_provider and compares llm_provider to config.agent.llm_provider can raise AttributeError because config.agent.llm_provider may be None; update the logic in the block that uses llm_model/llm_provider to null-guard config.agent.llm_provider before calling .lower() (for example use a None-safe expression or explicit None check) so both the assignment to effective_llm_provider and the comparison llm_provider.lower() != config.agent.llm_provider.lower() handle a None stored provider, and keep the existing behavior where effective_llm_model is forced when the caller supplies a differing llm_provider.
🤖 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.
Outside diff comments:
In `@src/api/settings/langflow_sync.py`:
- Around line 154-157: The branch that computes effective_llm_provider and
compares llm_provider to config.agent.llm_provider can raise AttributeError
because config.agent.llm_provider may be None; update the logic in the block
that uses llm_model/llm_provider to null-guard config.agent.llm_provider before
calling .lower() (for example use a None-safe expression or explicit None check)
so both the assignment to effective_llm_provider and the comparison
llm_provider.lower() != config.agent.llm_provider.lower() handle a None stored
provider, and keep the existing behavior where effective_llm_model is forced
when the caller supplies a differing llm_provider.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dbd0555e-6821-4bdc-806d-d175a89061c1
📒 Files selected for processing (4)
src/api/settings/langflow_sync.pytests/unit/api/test_langflow_sync_bug_1587.pytests/unit/api/test_langflow_sync_edge_cases.pytests/unit/api/test_none_crash.py
Vchen7629
left a comment
There was a problem hiding this comment.
Added some comments for some light code changes.
Fixes #1587. The fallback branch of _update_langflow_model_values() only refreshed embedding providers, so LLM selections reverted to stale/default models after a flow reset. Add an LLM provider loop mirroring the embedding logic: current provider gets config.agent.llm_model, others get None (first available), all with force_llm_update=True. Guards config.agent.llm_provider against None before .lower().
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Tests