-
Notifications
You must be signed in to change notification settings - Fork 180
filter RAG search result based on score #57
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
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DataSourceLookup
participant VectorDatabase
User->>DataSourceLookup: Call process(input, config, agent)
DataSourceLookup->>VectorDatabase: Search with input
VectorDatabase-->>DataSourceLookup: Return results with scores
DataSourceLookup->>DataSourceLookup: Filter results by scoreThreshold
DataSourceLookup->>DataSourceLookup: Map results (include metadata/score as configured)
DataSourceLookup-->>User: Return processed results
Estimated code review effort2 (~15 minutes) Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
CodeRabbit Configuration File (
|
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: 2
🧹 Nitpick comments (2)
packages/core/src/Components/DataSourceLookup.class.ts (2)
79-83: Fix misleading comment.The comment on line 82 doesn't accurately describe what the code is doing. It's simply extracting the score from the search result.
- score: result.score, // use a very low score to return + score: result.score,
87-104: Consider consistent return type for better API design.The current logic returns either a string or an object depending on the flags, which creates inconsistent return types that could cause issues for API consumers.
Consider always returning objects for consistency:
// If neither metadata nor score is included, return just the content string - return includeMetadata || includeScore ? transformedResult : result.content; + return transformedResult;This would ensure consumers always receive objects with a
contentproperty, making the API more predictable and easier to work with.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/core/src/Components/DataSourceLookup.class.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.class.ts
📄 CodeRabbit Inference Engine (.cursor/rules/sre-ai-rules.mdc)
Use the
.class.tsfile extension for classes and connectors/managers
Files:
packages/core/src/Components/DataSourceLookup.class.ts
🔇 Additional comments (2)
packages/core/src/Components/DataSourceLookup.class.ts (2)
58-59: LGTM! Good backward compatibility consideration.The default values are appropriate, and the comment clearly explains the rationale for the low score threshold to maintain backward compatibility.
106-106: LGTM! Appropriate debug information.The debug output correctly shows the filtered result count, which is valuable information for users.
📝 Description
filter search result from RAG Search component based on score threshold set by user
return score value when Include score is enabled
🔗 Related Issues
🔧 Type of Change
✅ Checklist
Summary by CodeRabbit