VectorStoreIndexWrapper#
- class langchain.indexes.vectorstore.VectorStoreIndexWrapper[source]#
Bases:
BaseModel
Wrapper around a vectorstore for easy access.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param vectorstore: VectorStore [Required]#
- async aquery(question: str, llm: BaseLanguageModel | None = None, retriever_kwargs: Dict[str, Any] | None = None, **kwargs: Any) str [source]#
Asynchronously query the vectorstore using the provided LLM.
- Parameters:
question (str) – The question or prompt to query.
llm (BaseLanguageModel | None) – The language model to use. Must not be None.
retriever_kwargs (Dict[str, Any] | None) – Optional keyword arguments for the retriever.
**kwargs (Any) – Additional keyword arguments forwarded to the chain.
- Returns:
The asynchronous result string from the RetrievalQA chain.
- Return type:
str
- async aquery_with_sources(question: str, llm: BaseLanguageModel | None = None, retriever_kwargs: Dict[str, Any] | None = None, **kwargs: Any) dict [source]#
Asynchronously query the vectorstore and retrieve the answer and sources.
- Parameters:
question (str) – The question or prompt to query.
llm (BaseLanguageModel | None) – The language model to use. Must not be None.
retriever_kwargs (Dict[str, Any] | None) – Optional keyword arguments for the retriever.
**kwargs (Any) – Additional keyword arguments forwarded to the chain.
- Returns:
A dictionary containing the answer and source documents.
- Return type:
dict
- query(question: str, llm: BaseLanguageModel | None = None, retriever_kwargs: Dict[str, Any] | None = None, **kwargs: Any) str [source]#
Query the vectorstore using the provided LLM.
- Parameters:
question (str) – The question or prompt to query.
llm (BaseLanguageModel | None) – The language model to use. Must not be None.
retriever_kwargs (Dict[str, Any] | None) – Optional keyword arguments for the retriever.
**kwargs (Any) – Additional keyword arguments forwarded to the chain.
- Returns:
The result string from the RetrievalQA chain.
- Return type:
str
- query_with_sources(question: str, llm: BaseLanguageModel | None = None, retriever_kwargs: Dict[str, Any] | None = None, **kwargs: Any) dict [source]#
Query the vectorstore and retrieve the answer along with sources.
- Parameters:
question (str) – The question or prompt to query.
llm (BaseLanguageModel | None) – The language model to use. Must not be None.
retriever_kwargs (Dict[str, Any] | None) – Optional keyword arguments for the retriever.
**kwargs (Any) – Additional keyword arguments forwarded to the chain.
- Returns:
A dictionary containing the answer and source documents.
- Return type:
dict