🧹 Refactor _get_model_or_400 into common helper function - #85
Conversation
Extract duplicated model validation and retrieval logic into get_model_or_400 helper function in src/app/models.py and reuse it in embedding service, rerank service, and main routing layer. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Extract duplicated model validation and retrieval logic into get_model_or_400 helper function in src/app/models.py and reuse it in embedding service, rerank service, and main routing layer. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
🎯 What:
Extracted duplicated model lookup and 400 error handling logic into a unified
get_model_or_400helper function insrc/app/models.py, and updatedsrc/app/services/embedding.py,src/app/services/rerank.py, andsrc/app/main.pyto use it.💡 Why:
Previously,
_get_model_or_400was duplicated acrossembedding.py,rerank.py, andmain.py. Consolidating this logic into a single helper reduces code duplication, improves maintainability, and ensures consistent error handling and formatting across services.✅ Verification:
Ran full linting (
uv run ruff check .), formatting (uv run ruff format .), and test suite (uv run pytest). All 149 tests passed without regression.✨ Result:
Cleaned up duplicate code across services while maintaining 100% backward compatibility and test coverage.
PR created automatically by Jules for task 23163263657246516 started by @chottokun