langchain-ai / langchain

šŸ¦œšŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
91.25k stars 14.51k forks source link

AzureSearchVectorStoreRetriever search_kwargs is empty #21473

Closed JetQin closed 1 week ago

JetQin commented 3 months ago

Checked other resources

Example Code

Missing __search_kwargs: dict = Field(defaultfactory=dict) fields in AzureSearchVectorStoreRetriever, we can't pass filter condition during query from vector db

Current code:


class AzureSearchVectorStoreRetriever(BaseRetriever):
    """Retriever that uses `Azure Cognitive Search`."""

    vectorstore: AzureSearch
    """Azure Search instance used to find similar documents."""
    search_type: str = "hybrid"
    """Type of search to perform. Options are "similarity", "hybrid",
    "semantic_hybrid", "similarity_score_threshold", "hybrid_score_threshold"."""
    k: int = 4
    """Number of documents to return."""
    allowed_search_types: ClassVar[Collection[str]] = (
    )

Previous Code:

class VectorStoreRetriever(BaseRetriever):
    """Base Retriever class for VectorStore."""

    vectorstore: VectorStore
    """VectorStore to use for retrieval."""
    search_type: str = "similarity"
    """Type of search to perform. Defaults to "similarity"."""
    _search_kwargs: dict = Field(default_factory=dict)
    """Keyword arguments to pass to the search function."""
    allowed_search_types: ClassVar[Collection[str]] = (
        "similarity",
        "similarity_score_threshold",
        "mmr",
    )

Error Message and Stack Trace (if applicable)

No response

Description

Can't pass filter expression to azure search

System Info

langchain-community==0.0.32 works well but in langchain-community==0.0.37 failed to get filter conditions

liugddx commented 3 months ago

Let me see.