A class that wraps the FAISS (Facebook AI Similarity Search) vector database for efficient similarity search and clustering of dense vectors.

Hierarchy

Constructors

Properties

FilterType: string | object
_mapping: Record<number, string>
embeddings: Embeddings
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false
_index?: IndexFlatL2

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

Methods

  • Adds an array of Document objects to the store.

    Parameters

    • documents: Document<Record<string, any>>[]

      An array of Document objects.

    • Optional options: {
          ids?: string[];
      }
      • Optional ids?: string[]

    Returns Promise<string[]>

    A Promise that resolves when the documents have been added.

  • Adds an array of vectors and their corresponding Document objects to the store.

    Parameters

    • vectors: number[][]

      An array of vectors.

    • documents: Document<Record<string, any>>[]

      An array of Document objects corresponding to the vectors.

    • Optional options: {
          ids?: string[];
      }
      • Optional ids?: string[]

    Returns Promise<string[]>

    A Promise that resolves with an array of document IDs when the vectors and documents have been added.

  • Method to delete documents.

    Parameters

    • params: {
          ids: string[];
      }

      Object containing the IDs of the documents to delete.

      • ids: string[]

    Returns Promise<void>

    A promise that resolves when the deletion is complete.

  • Merges the current FaissStore with another FaissStore.

    Parameters

    • targetIndex: FaissStore

      The FaissStore to merge with.

    Returns Promise<string[]>

    A Promise that resolves with an array of document IDs when the merge is complete.

  • Saves the current state of the FaissStore to a specified directory.

    Parameters

    • directory: string

      The directory to save the state to.

    Returns Promise<void>

    A Promise that resolves when the state has been saved.

  • Performs a similarity search in the vector store using a query vector and returns the top k results along with their scores.

    Parameters

    • query: number[]

      A query vector.

    • k: number

      The number of top results to return.

    Returns Promise<[Document<Record<string, any>>, number][]>

    A Promise that resolves with an array of tuples, each containing a Document and its corresponding score.

  • Returns Promise<{
        NameRegistry: typeof NameRegistry;
        Parser: typeof Parser;
    }>

Generated using TypeDoc