feat: support OpenRouter embedding dimensions#811
Conversation
|
@lukeaus is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesOpenRouter Configurable Embedding Dimensions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
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 unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
|
Linked issue: #809 |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds configurable embedding dimensions support for the OpenRouter embedding provider, with tests and documentation updates.
Changes:
- Add
OPENROUTER_EMBEDDING_DIMENSIONSparsing/validation and wire it into OpenRouter requests. - Add Vitest coverage for default, explicit, and invalid OpenRouter dimensions behavior.
- Document new OpenRouter embedding env vars in README and
.env.example.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/embedding-provider.test.ts | Adds unit tests validating OpenRouter dimensions defaulting, request payload, and env var validation. |
| src/providers/embedding/openrouter.ts | Implements env-driven dimensions resolution and includes it in the embeddings request body. |
| README.md | Documents OpenRouter embedding model/dimensions environment variables. |
| .env.example | Adds example OPENROUTER_EMBEDDING_DIMENSIONS configuration entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Luke Scott <luke.scott@investflo.ai>
4dabbaf to
534b2ff
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/providers/embedding/openrouter.ts`:
- Around line 71-74: resolveDimensions currently throws when the env value is
whitespace-only; change its logic so that whitespace-only values are treated as
unset and return the default 1536 (same behavior as when raw is undefined).
Specifically, in the resolveDimensions function trim the input and if trimmed
=== "" return 1536; only validate and throw an error when trimmed is non-empty
and not all digits (use the existing /^\d+$/ check), so numeric strings parse to
a number, empty/whitespace returns default, and invalid non-numeric values still
throw.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c5d4fe15-37b5-499d-81cf-9427c38a3f74
📒 Files selected for processing (4)
.env.exampleREADME.mdsrc/providers/embedding/openrouter.tstest/embedding-provider.test.ts
✅ Files skipped from review due to trivial changes (1)
- .env.example
|
Status update after review pass:
|
|
Reviewed the latest CodeRabbit comments. There are no outstanding actionable CodeRabbit review threads on this PR. The prior actionable whitespace-only |
Summary
Allows OpenRouter embedding models to declare and request non-1536 vector dimensions.
Fixes #809.
Changes
OPENROUTER_EMBEDDING_DIMENSIONSsupport with positive-integer validation.dimensionsin OpenRouter embedding requests.Verification
HOME=$(mktemp -d) npx vitest run test/embedding-provider.test.tsnpm run buildSummary by CodeRabbit
New Features
Documentation
Tests