Skip to content

Conversation

@steebchen
Copy link
Member

@steebchen steebchen commented Jan 30, 2026

Summary by CodeRabbit

  • Improvements
    • Enhanced error messaging when unsupported models or providers are requested, with suggested usage formats.
    • Improved reliability of model and provider routing, including better handling of deactivated providers during selection.
    • Support for multiple model input formats including auto, custom, provider-scoped, direct model IDs, and custom OpenAI-compatible providers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

This PR refactors model and provider resolution logic in the gateway's chat module by extracting inline parsing and validation into dedicated helper functions. Two new utilities—parseModelInput and resolveModelInfo—centralize model string parsing and provider deactivation filtering. The Model type dependency is removed where runtime strings suffice.

Changes

Cohort / File(s) Summary
New Model Resolution Utilities
apps/gateway/src/chat/tools/parse-model-input.ts, apps/gateway/src/chat/tools/resolve-model-info.ts
Introduces parseModelInput to parse user-provided model input strings into model, provider, and optional custom provider name; introduces resolveModelInfo to resolve model definitions, filter deactivated providers, and update provider selection accordingly.
Chat Logic Refactoring
apps/gateway/src/chat/chat.ts
Replaces ad-hoc model parsing and provider resolution with calls to new helper functions; removes Model type import; simplifies control flow by consolidating model/provider routing logic.
Type Simplification
apps/gateway/src/lib/costs.ts
Changes calculateCosts function signature to accept model as a string instead of Model type; removes Model type import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'refactor(gateway): extract some functions' is vague and uses non-descriptive language; 'extract some functions' does not convey what functionality is being refactored or why. Consider a more specific title like 'refactor(gateway): extract model parsing and resolution helpers' to better communicate the purpose of the refactoring.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steebchen/batch-api-phase2

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants