fix: configure OpenRouter embedding dimensions
Summary
- add OPENROUTER_EMBEDDING_DIMENSIONS support with a 1536 default
- validate OpenRouter embedding dimensions as a positive integer
- send dimensions in the OpenRouter embeddings request body
- document the new env var and add provider regression tests
Fixes #809
Testing
- npx vitest run test/embedding-provider.test.ts
Summary by CodeRabbit
- New Features
- Added configurable embedding dimensions for OpenRouter models. Use the
OPENROUTER_EMBEDDING_DIMENSIONSenvironment variable to override the default 1536 dimensions, enabling support for custom embedding model configurations.
- Added configurable embedding dimensions for OpenRouter models. Use the
@Sushanth012 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 configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f969eb86-3090-49d4-8566-bb44e9e15f56
📥 Commits
Reviewing files that changed from the base of the PR and between 749c2806e0ec21ce6d553f376f6cf976ee251b1d and fc8dc69c0bf9531157096f7b876d954424c78af2.
📒 Files selected for processing (3)
.env.examplesrc/providers/embedding/openrouter.tstest/embedding-provider.test.ts
📝 Walkthrough
Walkthrough
OpenRouterEmbeddingProvider is updated to accept configurable embedding dimensions via the OPENROUTER_EMBEDDING_DIMENSIONS environment variable, defaulting to 1536 for backward compatibility. The configuration includes validation, error handling, API integration, and comprehensive test coverage.
Changes
OpenRouter Configurable Embedding Dimensions
| Layer / File(s) | Summary |
|---|---|
Configuration parsing and validation src/providers/embedding/openrouter.ts, .env.example |
DEFAULT_DIMENSIONS constant and resolveDimensions() helper parse and validate the optional dimension override as a positive integer; OpenRouterEmbeddingProvider initializes dimensions from the resolver at construction; .env.example documents the option. |
API integration and test coverage src/providers/embedding/openrouter.ts, test/embedding-provider.test.ts |
OpenRouter embeddings request body now includes dimensions; test suite imports the provider, cleans up OPENROUTER_EMBEDDING_DIMENSIONS env var, and validates default behavior, environment overrides, error handling for invalid values, and request payload shape. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Suggested reviewers
- rohitg00
Poem
🐰 A rabbit's rhyme for configurable embeddings:
Dimensions dance at OpenRouter's gate, No more hardcoded at one thousand eight, With validation and tests standing tall, Flexible vectors—for models, one and all! ✨
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly describes the main change: configuring OpenRouter embedding dimensions via environment variable, which is the primary objective of this PR. |
| Linked Issues check | ✅ Passed | The PR successfully implements all coding requirements from issue #809: environment variable support with 1536 default, positive integer validation, dimensions in request body, and comprehensive test coverage. |
| Out of Scope Changes check | ✅ Passed | All changes are directly scoped to the linked issue: .env.example documentation, OpenRouterEmbeddingProvider implementation, and embedding provider test suite coverage. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
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 @coderabbitai help to get the list of available commands and usage tips.