fix(providers): support OpenRouter virtual model IDs#344
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRegistry, router, and pricing resolution now accept raw slash-containing model selectors (e.g., ChangesProvider-Owned Raw Model Selector Matching
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Greptile SummaryThis PR extends model resolution for OpenRouter virtual model IDs that contain raw slashes. It changes:
Confidence Score: 3/5This is close, but the pricing fallback should be fixed before merging.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(providers): skip empty metadata cand..." | Re-trigger Greptile |
| func providerModelInfo(providerModels map[string]*ModelInfo, modelID, rawModel string) (*ModelInfo, bool) { | ||
| modelID = strings.TrimSpace(modelID) | ||
| rawModel = strings.TrimSpace(rawModel) | ||
| if info, exists := providerModels[modelID]; exists { | ||
| return info, true | ||
| } | ||
| if rawModel != "" && rawModel != modelID { | ||
| if info, exists := providerModels[rawModel]; exists { | ||
| return info, true | ||
| } | ||
| } | ||
| return nil, false |
There was a problem hiding this comment.
Metadata lookup still strips raw IDs
This PR teaches the main registry lookup to find provider-owned raw slash IDs by trying the full raw model after the split model ID. The pricing and metadata path in registry_metadata.go still uses the old split-only lookup. When OpenRouter is configured as provider name openrouter and the model is openrouter/free, ResolvePricing("openrouter/free", "openrouter") looks for model free under provider openrouter, then returns nil because openrouter is a configured provider name. The chat request routes successfully, but usage logging cannot find the attached pricing/metadata for the actual registered model key openrouter/free.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| if info == nil || info.Model.Metadata == nil { | ||
| continue | ||
| } | ||
| return info.Model.Metadata |
There was a problem hiding this comment.
This helper now skips models with nil metadata, but ResolvePricing still accepts the first non-nil metadata even when it has no pricing. If OpenRouter exposes both free with metadata but no Pricing and openrouter/free with pricing, ResolvePricing("openrouter/free", "openrouter") returns the stripped free metadata here, drops it because Pricing is nil, and later metadataModelID keeps resolving the selector back to free. The raw virtual model pricing is never tried, so usage for openrouter/free remains unpriced even though the raw model has pricing metadata.
Summary
openrouter/freeandopenrouter/auto.Tests
go test ./...make test-race,go mod tidy, dashboard JS check, hot-path performance guard,make lintFixes #342
Summary by CodeRabbit