Skip to content

Commit

Permalink
BUG: Fix search_kwargs in Vectara retriever (langchain-ai#13299)
Browse files Browse the repository at this point in the history
- **Description:** fix a bug that prevented as_retriever() in Vectara to
use the desired input arguments
  - **Issue:** as_retriever did not pass the arguments properly
  - **Tag maintainer:** @baskaryan
  - **Twitter handle:** @ofermend
  • Loading branch information
ofermend authored Nov 20, 2023
1 parent 1c08dbf commit 52e23e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion libs/langchain/langchain/schema/vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ def as_retriever(self, **kwargs: Any) -> VectorStoreRetriever:
"""
tags = kwargs.pop("tags", None) or []
tags.extend(self._get_retriever_tags())

return VectorStoreRetriever(vectorstore=self, **kwargs, tags=tags)


Expand Down
8 changes: 4 additions & 4 deletions libs/langchain/langchain/vectorstores/vectara.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
vectara_customer_id: Optional[str] = None,
vectara_corpus_id: Optional[str] = None,
vectara_api_key: Optional[str] = None,
vectara_api_timeout: int = 60,
vectara_api_timeout: int = 120,
source: str = "langchain",
):
"""Initialize with Vectara API."""
Expand Down Expand Up @@ -312,7 +312,6 @@ def similarity_search_with_score(
return []

result = response.json()

if score_threshold:
responses = [
r
Expand Down Expand Up @@ -441,7 +440,7 @@ def from_files(
def as_retriever(self, **kwargs: Any) -> VectaraRetriever:
tags = kwargs.pop("tags", None) or []
tags.extend(self._get_retriever_tags())
return VectaraRetriever(vectorstore=self, **kwargs, tags=tags)
return VectaraRetriever(vectorstore=self, search_kwargs=kwargs, tags=tags)


class VectaraRetriever(VectorStoreRetriever):
Expand All @@ -451,12 +450,13 @@ class VectaraRetriever(VectorStoreRetriever):
"""Vectara vectorstore."""
search_kwargs: dict = Field(
default_factory=lambda: {
"lambda_val": 0.025,
"lambda_val": 0.0,
"k": 5,
"filter": "",
"n_sentence_context": "2",
}
)

"""Search params.
k: Number of Documents to return. Defaults to 5.
lambda_val: lexical match parameter for hybrid search.
Expand Down

0 comments on commit 52e23e5

Please sign in to comment.