Code to help indexing data into a vectorstore.
This package contains helper logic to help deal with indexing data into
a VectorStore while avoiding duplicated content and over-writing content
if it's unchanged.
Import an attribute from a module located in a package.
This utility function is used in custom __getattr__ methods within __init__.py
files to dynamically import attributes.
Async index data from the loader into the vector store.
Indexing functionality uses a manager to keep track of which documents are in the vector store.
This allows us to keep track of which documents were updated, and which documents were deleted, which documents should be skipped.
For the time being, documents are indexed using their hashes, and users are not able to specify the uid of the document.
langchain-core 0.3.25Added scoped_full cleanup mode.
scoped_full mode is suitable if determining an appropriate batch size
is challenging or if your data loader cannot return the entire dataset at
once. This mode keeps track of source IDs in memory, which should be fine
for most use cases. If your dataset is large (10M+ docs), you will likely
need to parallelize the indexing process regardless.Index data from the loader into the vector store.
Indexing functionality uses a manager to keep track of which documents are in the vector store.
This allows us to keep track of which documents were updated, and which documents were deleted, which documents should be skipped.
For the time being, documents are indexed using their hashes, and users are not able to specify the uid of the document.
langchain-core 0.3.25Added scoped_full cleanup mode.
scoped_full mode is suitable if determining an appropriate batch size
is challenging or if your data loader cannot return the entire dataset at
once. This mode keeps track of source IDs in memory, which should be fine
for most use cases. If your dataset is large (10M+ docs), you will likely
need to parallelize the indexing process regardless.Return a detailed a breakdown of the result of the indexing operation.
A generic response for delete operation.
The fields in this response are optional and whether the VectorStore
returns them or not is up to the implementation.
A document retriever that supports indexing operations.
This indexing interface is designed to be a generic abstraction for storing and querying documents that has an ID and metadata associated with it.
The interface is designed to be agnostic to the underlying implementation of the indexing system.
The interface is designed to support the following operations:
An in-memory record manager for testing purposes.
Abstract base class representing the interface for a record manager.
The record manager abstraction is used by the langchain indexing API.
The record manager keeps track of which documents have been
written into a VectorStore and when they were written.
The indexing API computes hashes for each document and stores the hash together with the write time and the source id in the record manager.
On subsequent indexing runs, the indexing API can check the record manager to determine which documents have already been indexed and which have not.
This allows the indexing API to avoid re-indexing documents that have already been indexed, and to only index new documents.
The main benefit of this abstraction is that it works across many vectorstores.
To be supported, a VectorStore needs to only support the ability to add and
delete documents by ID. Using the record manager, the indexing API will
be able to delete outdated documents and avoid redundant indexing of documents
that have already been indexed.
The main constraints of this abstraction are:
VectorStore fails.A generic response for upsert operations.
The upsert response will be used by abstractions that implement an upsert operation for content that can be upserted by ID.
Upsert APIs that accept inputs with IDs and generate IDs internally will return a response that includes the IDs that succeeded and the IDs that failed.
If there are no failures, the failed list will be empty, and the order of the IDs in the succeeded list will match the order of the input documents.
If there are failures, the response becomes ill defined, and a user of the API cannot determine which generated ID corresponds to which input document.
It is recommended for users explicitly attach the IDs to the items being indexed to avoid this issue.