agentsociety.vectorstore.vectorstore¶
Module Contents¶
Classes¶
A class for handling similarity searches and document management using Qdrant and FastEmbed. |
Data¶
API¶
- agentsociety.vectorstore.vectorstore.__all__¶
[‘VectorStore’]
- class agentsociety.vectorstore.vectorstore.VectorStore(embedding: fastembed.SparseTextEmbedding)¶
A class for handling similarity searches and document management using Qdrant and FastEmbed.
Description:
This class provides functionalities to manage embeddings and perform similarity searches over a set of documents.
It uses FastEmbed for generating embeddings and Qdrant for vector storage and retrieval.
The class initializes with an optional embedding model and Qdrant client settings.
Initialization
Initialize the VectorStore instance.
Parameters:
embedding(SparseTextEmbedding): The embedding model to use.
- property embeddings¶
- async add_documents(documents: list[str], extra_tags: Optional[dict] = None) list[str]¶
Add documents to the vector store with metadata.
Description:
Asynchronously adds one or more documents to the vector store, associating them with an agent ID and optional extra tags.
Each document is converted into a vector using FastEmbed before being added to Qdrant.
Args:
documents(list[str]): A list of document strings to add.extra_tags(Optional[dict], optional): Additional metadata tags to associate with the documents. Defaults to None.
Returns:
list[str]: List of document IDs (UUIDs) that were added to the vector store.
- async delete_documents(to_delete_ids: list[str])¶
Delete documents from the vector store by IDs.
Description:
Asynchronously deletes documents from the vector store based on provided document IDs.
Args:
to_delete_ids(list[str]): List of document IDs (UUIDs) to delete from the vector store.
- async similarity_search(query: str, k: int = 4, filter: Optional[dict] = None) list[tuple[str, float, dict]]¶
Perform a similarity search for documents related to the given query.
Description:
Conducts an asynchronous search for the top-k documents most similar to the query text.
Uses FastEmbed to generate query embedding and Qdrant for vector search.
Args:
query(str): The text to look up documents similar to.k(int, optional): The number of top similar contents to return. Defaults to 4.fetch_k(int, optional): The number of documents to fetch before applying any filters. Defaults to 20.filter(Optional[dict], optional): The filter dict for metadata.
Returns:
list[tuple[str, float, dict]]: List of tuples containing content, score, and metadata.