Construct Lantern wrapper from raw documents and pre- generated embeddings.
Postgres connection string is required
"Either pass it as connection_string parameter
or set the LANTERN_CONNECTION_STRING environment variable.
Order of elements for lists ids, text_embeddings, metadatas should match,
so each row will be associated with correct values.
connection_string is fully populated connection string for postgres databasetext_embeddings is array with tuples (text, embedding)
to insert into collection.embedding is :class:Embeddings that will be used for
embedding the text sent. If none is sent, then the
multilingual Tensorflow Universal Sentence Encoder will be used.metadatas row metadata to insert into collection.collection_name is the name of the collection to use. (default: langchain)
ids row ids to insert into collection.pre_delete_collection if True, will delete the collection if it exists.
(default: False)
distance_strategy is the distance strategy to use. (default: EUCLIDEAN)
EUCLIDEAN is the euclidean distance.COSINE is the cosine distance.HAMMING is the hamming distance.from_embeddings(
cls,
text_embeddings: List[Tuple[str, List[float]]],
embedding: Embeddings,
metadatas: Optional[List[dict]] = None,
collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME,
ids: Optional[List[str]] = None,
pre_delete_collection: bool = False,
distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
**kwargs: Any = {}
) -> Lantern