Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Speed up VectorDBQA.validate_search_type() by 7% in libs/langchain/langchain/chains/retrieval_qa/base.py #49

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions libs/langchain/langchain/chains/retrieval_qa/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Chain for question-answering against a vector database."""

from __future__ import annotations

import inspect
Expand Down Expand Up @@ -262,10 +263,11 @@ def raise_deprecation(cls, values: Dict) -> Dict:
@root_validator()
def validate_search_type(cls, values: Dict) -> Dict:
"""Validate search type."""
if "search_type" in values:
search_type = values["search_type"]
if search_type not in ("similarity", "mmr"):
raise ValueError(f"search_type of {search_type} not allowed.")
if "search_type" in values and values["search_type"] not in (
"similarity",
"mmr",
):
raise ValueError(f"search_type of {values['search_type']} not allowed.")
return values

def _get_docs(
Expand Down
Loading