Skip to content

🧹 Refactor _get_model_or_400 into common helper function - #85

Merged
chottokun merged 2 commits into
mainfrom
refactor/extract-get-model-or-400-23163263657246516
Sep 12, 2026
Merged

chottokun merged 2 commits into
mainfrom
refactor/extract-get-model-or-400-23163263657246516

Conversation

@chottokun

Copy link
Copy Markdown
Owner

🎯 What:
Extracted duplicated model lookup and 400 error handling logic into a unified get_model_or_400 helper function in src/app/models.py, and updated src/app/services/embedding.py, src/app/services/rerank.py, and src/app/main.py to use it.

💡 Why:
Previously, _get_model_or_400 was duplicated across embedding.py, rerank.py, and main.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

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chottokun

Copy link
Copy Markdown
Owner Author

本PRのリファクタリング内容(_get_model_or_400 の共通化)は、PR #88 にてプレフィックス重複排除やDocstring拡充とともに包括的に統合・ブラッシュアップを進めています。PR #88 のマージ完了後に本PRをクローズ予定です。

@google-labs-jules

Copy link
Copy Markdown
Contributor

本PRのリファクタリング内容(_get_model_or_400 の共通化)は、PR #88 にてプレフィックス重複排除やDocstring拡充とともに包括的に統合・ブラッシュアップを進めています。PR #88 のマージ完了後に本PRをクローズ予定です。

承知いたしました。ご共有ありがとうございます。PR #88 での統合・クローズ処理について理解いたしました。

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>
@chottokun
chottokun merged commit a67d682 into main Sep 12, 2026
1 check passed
@chottokun
chottokun deleted the refactor/extract-get-model-or-400-23163263657246516 branch September 12, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant