-
Notifications
You must be signed in to change notification settings - Fork 180
added EMBEDDING_DIM if available or undefined to fallback to default … #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added EMBEDDING_DIM if available or undefined to fallback to default … #487
Conversation
|
WalkthroughThe changes modify the Changes
Assessment against linked issues
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
templates/components/vectordbs/typescript/pg/index.ts (2)
17-19
: Document EMBEDDING_DIM configuration.Add JSDoc comments to document the expected format and purpose of the EMBEDDING_DIM environment variable.
Consider adding this documentation above the function:
/** * @description Creates a vector store data source with configurable dimensions * @param params Optional parameters for data source configuration * @returns Promise<VectorStoreIndex> * * Environment Variables: * - EMBEDDING_DIM: (Optional) Positive integer specifying the embedding dimensions. * If not provided, defaults to the model's native dimensions. */
17-19
: Consider adding type safety for dimensions parameter.The current implementation could benefit from stronger type checking.
Consider defining an interface for the PGVectorStore configuration:
interface PGVectorStoreConfig { clientConfig: { connectionString: string; }; schemaName: string; tableName: string; dimensions?: number; }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
templates/components/vectordbs/typescript/pg/index.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
templates/components/vectordbs/typescript/pg/index.ts (1)
Pattern templates/**
: For files under the templates
folder, do not report 'Missing Dependencies Detected' errors.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: typescript (20, 3.11, ubuntu-22.04, express, --example-file)
- GitHub Check: typescript (20, 3.11, ubuntu-22.04, express, --no-files)
- GitHub Check: typescript (18, 3.11, ubuntu-22.04, nextjs, --example-file)
dimensions: process.env.EMBEDDING_DIM | ||
? parseInt(process.env.EMBEDDING_DIM) | ||
: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add input validation for EMBEDDING_DIM parsing.
While the implementation handles the undefined case correctly, it should validate the parsed value to ensure it's a positive integer and within reasonable bounds.
Consider this safer implementation:
- dimensions: process.env.EMBEDDING_DIM
- ? parseInt(process.env.EMBEDDING_DIM)
- : undefined,
+ dimensions: process.env.EMBEDDING_DIM
+ ? (() => {
+ const dim = parseInt(process.env.EMBEDDING_DIM!);
+ if (isNaN(dim) || dim <= 0) {
+ throw new Error('EMBEDDING_DIM must be a positive integer');
+ }
+ return dim;
+ })()
+ : undefined,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
dimensions: process.env.EMBEDDING_DIM | |
? parseInt(process.env.EMBEDDING_DIM) | |
: undefined, | |
dimensions: process.env.EMBEDDING_DIM | |
? (() => { | |
const dim = parseInt(process.env.EMBEDDING_DIM!); | |
if (isNaN(dim) || dim <= 0) { | |
throw new Error('EMBEDDING_DIM must be a positive integer'); | |
} | |
return dim; | |
})() | |
: undefined, |
@ravvi-kumar thanks for the patch! |
fixes #486
Summary by CodeRabbit
New Features
Improvements