fix: Proper refresh of Groq models#12158
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe Groq model discovery process was enhanced to validate chat completion capability before testing tool-calling support, introducing a new validation method and refining error handling logic across both the implementation and corresponding test suite. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (10.41%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #12158 +/- ##
==========================================
+ Coverage 38.36% 38.38% +0.01%
==========================================
Files 1630 1630
Lines 80250 80289 +39
Branches 12114 12120 +6
==========================================
+ Hits 30791 30818 +27
- Misses 47723 47735 +12
Partials 1736 1736
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lfx/src/lfx/base/models/groq_model_discovery.py (1)
157-173: Consider whether "terms_required" should be treated differently from "does not support chat".Models that return
terms_requiredormodel_terms_requirederrors do support chat completions—they just require the user to accept terms first. Currently, these models get added tonon_llm_modelswithnot_supported=True, which is semantically incorrect.If this is intentional (treating unusable-for-this-user as unsupported), a brief comment clarifying the rationale would help. Otherwise, consider handling terms-required models differently—perhaps keeping them in
models_metadatabut with a separate flag likerequires_terms_acceptance=True.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lfx/src/lfx/base/models/groq_model_discovery.py` around lines 157 - 173, In the except block in groq_model_discovery (the Exception as e handler), stop treating "terms_required" and "model_terms_required" as equivalent to "does not support chat": remove those phrases from the unsupported list, and instead detect them explicitly and return True (chat supported) while recording that the model requires user terms acceptance—e.g., set a requires_terms_acceptance=True flag on the model metadata (models_metadata) or return a tuple/structured result so callers (and non_llm_models processing) can distinguish "supported but requires terms" from truly unsupported models; if the original behavior was intentional, add a short clarifying comment in that handler referencing non_llm_models and the rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lfx/src/lfx/base/models/groq_model_discovery.py`:
- Around line 157-173: In the except block in groq_model_discovery (the
Exception as e handler), stop treating "terms_required" and
"model_terms_required" as equivalent to "does not support chat": remove those
phrases from the unsupported list, and instead detect them explicitly and return
True (chat supported) while recording that the model requires user terms
acceptance—e.g., set a requires_terms_acceptance=True flag on the model metadata
(models_metadata) or return a tuple/structured result so callers (and
non_llm_models processing) can distinguish "supported but requires terms" from
truly unsupported models; if the original behavior was intentional, add a short
clarifying comment in that handler referencing non_llm_models and the rationale.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a5d8fbe6-3c90-4d15-970e-890701732eea
📒 Files selected for processing (2)
src/backend/tests/unit/groq/test_groq_model_discovery.pysrc/lfx/src/lfx/base/models/groq_model_discovery.py
There was a problem hiding this comment.
Pull request overview
This PR improves Groq model discovery by filtering out non-LLM models more accurately and validating model capabilities in a safer order (chat support before tool-calling support), with corresponding unit test updates.
Changes:
- Expanded
SKIP_PATTERNSto exclude additional non-LLM/speech model families. - Added an explicit chat-completions capability probe and updated discovery flow to run it before tool-calling checks.
- Refined error handling/logging in tool-calling capability detection and updated the mixed-support unit test to match the new call order.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/lfx/src/lfx/base/models/groq_model_discovery.py |
Updates filtering and capability detection; adds _test_chat_completion; adjusts error handling. |
src/backend/tests/unit/groq/test_groq_model_discovery.py |
Updates the mixed tool-calling support test to reflect the new capability-check sequence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
SummaryThis PR improves the Groq model discovery process by adding:
Results by Category
🔴 CRITICAL1. DRY - Duplicated error detection logicFile: The access/entitlement error detection block is identically duplicated in # Appears TWICE - identical
if any(
phrase in error_msg
for phrase in [
"terms acceptance",
"terms_required",
"model_terms_required",
"not available",
]
):Recommendation: Extract to a class constant or helper method: ACCESS_ERROR_PHRASES = ["terms acceptance", "terms_required", "model_terms_required", "not available"]
def _is_access_error(self, error_msg: str) -> bool:
return any(phrase in error_msg for phrase in self.ACCESS_ERROR_PHRASES)2. File Limit - Test file with 718 linesFile: The hard limit is ~500 lines (up to ~530 OK; 600+ is a red flag). 718 lines is a clear violation. Recommendation: Split the test file into smaller modules:
🟠 IMPORTANT3. Inconsistent
|
| Item | Score |
|---|---|
| Security & PII | ✅ 10/10 |
| DRY | |
| File Structure | |
| Architecture | ✅ 9/10 |
| Error Handling | |
| Tests | |
| TOTAL | ~75/100 |
This pull request enhances the Groq model discovery process by improving how models are filtered and tested for their capabilities. The main updates involve more accurate exclusion of non-LLM models, explicit testing for chat completion support, and clearer error handling when checking tool calling features.
Model filtering and capability detection improvements:
SKIP_PATTERNSlist inGroqModelDiscoveryto exclude additional non-LLM models such as speech-related models (orpheus,playai).get_modelsto first check whether each model supports chat completions before testing for tool calling, ensuring that models incapable of chat are filtered out early._test_chat_completionmethod to explicitly verify if a model supports basic chat completions, improving detection of non-chat models.Error handling enhancements:
_test_tool_callingto log specific issues, distinguish between missing Groq package and tool support errors, and conservatively handle other API errors.Test updates:
Summary by CodeRabbit