Enhance metadata handling in GoogleVectorStore #11018
Merged
+61
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This update introduces several enhancements to the
GoogleVectorStore
class, focusing on improved handling and flexibility of metadata during document retrieval. The changes are designed to provide users with more control over which metadata to include in the query results, aligning with the requirements of various use cases.Type of Change
Changes:
Metadata Inclusion Control: Added the ability to specify whether to include custom metadata in query results through the
include_metadata
parameter. This boolean parameter allows users to decide if metadata should be part of the query response, enhancing the versatility of data retrieval.Selective Metadata Filtering: Introduced the
metadata_keys
parameter, enabling users to specify a list of metadata keys that should be included in the query results. This feature allows for the selective inclusion of metadata, ensuring that only relevant information is returned, which can be particularly useful for reducing payload sizes or focusing on specific data aspects.Constructor and Factory Method Updates: Modified the
from_corpus
factory method of theGoogleVectorStore
class to acceptinclude_metadata
andmetadata_keys
parameters. These updates allow the configuration of metadata handling preferences at the instance creation stage, providing a seamless and intuitive setup process.Query Method Enhancement: Updated the
query
method to leverage theinclude_metadata
andmetadata_keys
attributes for filtering metadata based on user preferences. The method now conditionally includes metadata in the query results, based on the instance configuration, and filters the included metadata according to the specified keys.Usage Example:
This enhancement improves the GoogleVectorStore's flexibility and usability, providing users with precise control over metadata handling in their applications. By allowing selective metadata inclusion and filtering, it caters to a wider range of use cases and data processing requirements.
How Has This Been Tested?