agentchat.contrib.vectordb.pgvectordb
Collection
class Collection()
A Collection object for PGVector.
Attributes:
client
- The PGVector client.collection_name
str - The name of the collection. Default is "documents".embedding_function
Callable - The embedding function used to generate the vector representation. Default is None. SentenceTransformer("all-MiniLM-L6-v2").encode will be used when None. Models can be chosen from: https://huggingface.co/models?library=sentence-transformersmetadata
Optional[dict] - The metadata of the collection.get_or_create
Optional - The flag indicating whether to get or create the collection.
__init__
def __init__(client=None,
collection_name: str = "autogen-docs",
embedding_function: Callable = None,
metadata=None,
get_or_create=None)
Initialize the Collection object.
Arguments:
client
- The PostgreSQL client.collection_name
- The name of the collection. Default is "documents".embedding_function
- The embedding function used to generate the vector representation.metadata
- The metadata of the collection.get_or_create
- The flag indicating whether to get or create the collection.
Returns:
None
add
def add(ids: List[ItemID],
documents: List,
embeddings: List = None,
metadatas: List = None) -> None
Add documents to the collection.
Arguments:
ids
List[ItemID] - A list of document IDs.embeddings
List - A list of document embeddings. Optionalmetadatas
List - A list of document metadatas. Optionaldocuments
List - A list of documents.
Returns:
None