validate_search_type() — langchain Function Reference
Architecture documentation for the validate_search_type() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dfc9ef83_03e3_3e8a_6fa2_d84152fb28c6["validate_search_type()"] 0ab16606_6f12_fe39_c02a_5f20541c161f["VectorStoreRetriever"] dfc9ef83_03e3_3e8a_6fa2_d84152fb28c6 -->|defined in| 0ab16606_6f12_fe39_c02a_5f20541c161f style dfc9ef83_03e3_3e8a_6fa2_d84152fb28c6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/vectorstores/base.py lines 988–1016
def validate_search_type(cls, values: dict) -> Any:
"""Validate search type.
Args:
values: Values to validate.
Returns:
Validated values.
Raises:
ValueError: If `search_type` is not one of the allowed search types.
ValueError: If `score_threshold` is not specified with a float value(`0~1`)
"""
search_type = values.get("search_type", "similarity")
if search_type not in cls.allowed_search_types:
msg = (
f"search_type of {search_type} not allowed. Valid values are: "
f"{cls.allowed_search_types}"
)
raise ValueError(msg)
if search_type == "similarity_score_threshold":
score_threshold = values.get("search_kwargs", {}).get("score_threshold")
if (score_threshold is None) or (not isinstance(score_threshold, float)):
msg = (
"`score_threshold` is not specified with a float value(0~1) "
"in `search_kwargs`."
)
raise ValueError(msg)
return values
Domain
Subdomains
Source
Frequently Asked Questions
What does validate_search_type() do?
validate_search_type() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/base.py.
Where is validate_search_type() defined?
validate_search_type() is defined in libs/core/langchain_core/vectorstores/base.py at line 988.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free