Construct PGVector wrapper from raw documents and embeddings.
from_embeddings(
cls,
text_embeddings: List[Tuple[str, List[float]]],
embedding: Embeddings,
*,
metadatas: Optional[List[dict]] = None,
collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME,
distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
ids: Optional[List[str]] = None,
pre_delete_collection: bool = False,
**kwargs: Any = {}
) -> PGVectorExample:
.. code-block:: python
from langchain_postgres.vectorstores import PGVector from langchain_openai.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings() text_embeddings = embeddings.embed_documents(texts) text_embedding_pairs = list(zip(texts, text_embeddings)) vectorstore = PGVector.from_embeddings(text_embedding_pairs, embeddings)
| Name | Type | Description |
|---|---|---|
text_embeddings* | List[Tuple[str, List[float]]] | List of tuples of text and embeddings. |
embedding* | Embeddings | Embeddings object. |
metadatas | Optional[List[dict]] | Default: NoneOptional list of metadatas associated with the texts. |
collection_name | str | Default: _LANGCHAIN_DEFAULT_COLLECTION_NAMEName of the collection. |
distance_strategy | DistanceStrategy | Default: DEFAULT_DISTANCE_STRATEGYDistance strategy to use. |
ids | Optional[List[str]] | Default: NoneOptional list of ids for the documents. If not provided, will generate a new id for each document. |
pre_delete_collection | bool | Default: FalseIf True, will delete the collection if it exists. Attention: This will delete all the documents in the existing collection. |
kwargs | Any | Default: {}Additional arguments. |