langchain-ai / langchain-google

MIT License
119 stars 150 forks source link

community: Add support for order_by and canonical_filter fields in VertexAISearchRetriever #529

Closed lgesuellip closed 1 month ago

lgesuellip commented 1 month ago

PR Description

This PR introduces two new optional fields, order_by and canonical_filter, to the VertexAISearchRetriever class. These fields enhance the flexibility and control over search queries when using Google Vertex AI Search.

Type

🆕 New Feature ✅ Test

Issue

https://github.com/langchain-ai/langchain-google/issues/530

Testing

I added the corresponding unit test for creating a search request to verify that the VertexAISearchRetriever correctly creates a SearchRequest object with the expected auto-populated fields, including the newly added order_by and canonical_filter fields.

Also, I tested it using my data in GCP, checking different configurations and verifying that the parameters are correctly applied and produce the expected results.

vertex = VertexAISearchRetriever(
    project_id=project_id,
    data_store_id=data_store_id,
    max_documents=2,
    max_extractive_segment_count=1,
    num_previous_segments=3,
    num_next_segments=3,
    return_extractive_segment_score=True,
    order_by="title desc",  # Add order_by parameter
    canonical_filter="true"  # Add canonical_filter parameter
)

Thank you again Team!

lgesuellip commented 1 month ago

Hi @lkuligin , I would appreciate your review and feedback. Thanks,