向量存储检索器

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

Vector store index types.

class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])

Exact match metadata filter for vector stores.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])

Metadata filters for vector stores.

Currently only supports exact match filters. TODO: support more advanced expressions.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)

Information about a metadata filter supported by a vector store.

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.NodeWithEmbedding(node: Node, embedding: List[float])

Node with embedding.

参数
  • node (Node) -- Node

  • embedding (List[float]) -- Embedding

class llama_index.vector_stores.types.VectorStore(*args, **kwargs)

Abstract vector store protocol.

add(embedding_results: List[NodeWithEmbedding]) List[str]

Add embedding results to vector store.

property client: Any

Get client.

delete(ref_doc_id: str, **delete_kwargs: Any) None

Delete nodes using with ref_doc_id.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult

Query vector store.

class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)

Information about a vector store (content and supported metadata filters).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

class llama_index.vector_stores.types.VectorStoreQuery(query_embedding: Optional[List[float]] = None, similarity_top_k: int = 1, doc_ids: Optional[List[str]] = None, query_str: Optional[str] = None, mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, alpha: Optional[float] = None, filters: Optional[MetadataFilters] = None)

Vector store query.

class llama_index.vector_stores.types.VectorStoreQueryMode(value)

Vector store query mode.

class llama_index.vector_stores.types.VectorStoreQueryResult(nodes: Optional[List[Node]] = None, similarities: Optional[List[float]] = None, ids: Optional[List[str]] = None)

Vector store query result.

class llama_index.vector_stores.types.VectorStoreQuerySpec(*, query: str, filters: List[ExactMatchFilter], top_k: Optional[int] = None)

Schema for a structured request for vector store (i.e. to be converted to a VectorStoreQuery).

Currently only used by VectorIndexAutoRetriever.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

参数
  • include -- fields to include in new model

  • exclude -- fields to exclude from new model, as with values this takes precedence over include

  • update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep -- set to True to make a deep copy of the model

返回

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

翻译: 向量存储检索器 =======================

Base vector store index query.

class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: GPTVectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)

Vector index retriever.

参数
  • index (GPTVectorStoreIndex) -- vector store index.

  • similarity_top_k (int) -- number of top k results to return.

  • vector_store_query_mode (str) -- vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.

  • filters (Optional[MetadataFilters]) -- metadata filters, defaults to None

  • alpha (float) -- weight for sparse/dense retrieval, only used for hybrid query mode.

  • doc_ids (Optional[List[str]]) -- list of documents to constrain search.

  • vector_store_kwargs (dict) -- Additional vector store specific kwargs to pass through to the vector store at query time.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.

class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: GPTVectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)

Vector store auto retriever.

A retriever for vector store index that uses an LLM to automatically set vector store query parameters.

参数
  • index (GPTVectorStoreIndex) -- vector store index

  • vector_store_info (VectorStoreInfo) -- additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.

  • prompt_template_str -- custom prompt template string for LLM. Uses default template string if None.

  • service_context -- service context containing reference to LLMPredictor. Uses service context from index be default if None.

  • max_top_k -- the maximum top_k allowed. The top_k set by LLM will be clamped to this value.

retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore]

Retrieve nodes given query.

参数

str_or_query_bundle (QueryType) -- Either a query string or a QueryBundle object.