Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TimeWeightedVectorStoreRetriever to retrievers (langchain-ai#911)
* feat: Introduce Time-Weighted Retrieval for Relevant Documents - Add new file `time_weighted.ts` with functions to retrieve, add, and get documents from a vector store - Define `TimeWeightedVectorStoreRetriever` class that inherits from `BaseRetriever` - Include functions to calculate scores and hours passed to help identify salient documents * test: Add tests for time weighted retrievers. - Add new test file for time weighted retrievers - Implement several tests for TimeWeightedVectorStoreRetriever's getRelevantDocuments method with different data and searchKwargs values * refactor: Refactor TimeWeightedVectorStoreRetriever for better organization. - Refactored code in TimeWeightedVectorStoreRetriever for better organization - Combined memoryDocsAndScores and salientDocsAndScores for easy retrieval - Changed method names for better descriptive naming consistency * refactor: Reorganize retrievers exports in langchain codebase - Reorganize exports in the `index.ts` file in the `retrievers` directory - Move `MetalRetriever` and `RemoteLangChainRetriever` exports to the top - Add `TimeWeightedVectorStoreRetriever` export at the bottom for improved organization * feat: Refactor TimeWeightedVectorStoreRetriever interface and add tests - Improve time-weighted retriever functionality - Add JSDoc comments for key retriever functions - Refactor tests for better isolation and add tests for new functionality - Expose new interface for retriever in index file * refactor: Refactor time-weighted retriever constructor and add JSDoc comments - Simplified the constructor arguments using optional chaining and default values. - Improved code clarity by adding JSDoc comments for private functions. - Renamed variable for better understanding of its purpose. - Removed unnecessary keyword in a method. * refactor: Refactor test file naming convention. - Rename `time_weighted3.js` to `time_weighted.js` in the `time_weighted.test.ts` file in `langchain/src/retrievers/tests`. - No significant changes to other files were made. * style: Improve code style in retrievers index file - Add missing comma to SupabaseHybridSearchParams - Reformat import statements in retrievers/index.ts - Improve code readability and maintainability in langchain/src/retrievers/ * style: Remove unused eslint-disable comments in test file - Remove unnecessary eslint-disable comments in the `time_weighted.test.ts` file - Improve code readability and maintainability - Enhance overall code quality and consistency * Lint * Unod changes to index * Add entrypoint * Adds thrown error when using TimeWeightedVectorStoreRetriever on unsupported vector stores, adds docs and test --------- Co-authored-by: Nuno Campos <[email protected]> Co-authored-by: Jacob Lee <[email protected]>
- Loading branch information