Construct a Couchbase vector store from a list of texts.
from_texts(
cls: Type[CouchbaseVectorStore],
texts: List[str],
embedding: Embeddings,
metadatas: Optional[List[Dict[Any, Any]]] = None,
**kwargs: Any = {}
) -> CouchbaseVectorStoreExample:
.. code-block:: python
from langchain_community.vectorstores import CouchbaseVectorStore from langchain_openai import OpenAIEmbeddings
from couchbase.cluster import Cluster from couchbase.auth import PasswordAuthenticator from couchbase.options import ClusterOptions from datetime import timedelta
auth = PasswordAuthenticator(username, password) options = ClusterOptions(auth) connect_string = "couchbases://localhost" cluster = Cluster(connect_string, options)
cluster.wait_until_ready(timedelta(seconds=5))
embeddings = OpenAIEmbeddings()
texts = ["hello", "world"]
vectorstore = CouchbaseVectorStore.from_texts( texts, embedding=embeddings, cluster=cluster, bucket_name="", scope_name="", collection_name="", index_name="vector-index", )
| Name | Type | Description |
|---|---|---|
texts* | List[str] | list of texts to add to the vector store. |
embedding* | Embeddings | embedding function to use. |
metadatas | optional[List[Dict] | Default: Nonelist of metadatas to add to documents. |
**kwargs | Any | Default: {}Keyword arguments used to initialize the vector store with and/or
passed to |