Create a SingleStoreDB vectorstore from raw documents. This is a user-friendly interface that: 1. Embeds documents. 2. Creates a new table for the embeddings in SingleStoreDB. 3. Adds the documents to the newly created table. This is intended to be a quick way to get started. Args: texts (List[str]): List of texts to add to the vectorstore. embedding (Embeddings): A text embedding model. metadatas (Optional[List[dict]], optional): Optional list of metadatas. Defaults to None. distance_strategy (DistanceStrategy, optional): Determines the strategy employed for calculating the distance between vectors in the embedding space. Defaults to DOT_PRODUCT. Available options are: - DOT_PRODUCT: Computes the scalar product of two vectors. This is the default behavior - EUCLIDEAN_DISTANCE: Computes the Euclidean distance between two vectors. This metric considers the geometric distance in the vector space, and might be more suitable for embeddings that rely on spatial relationships. This metric is not compatible with the WEIGHTED_SUM search strategy. table_name (str, optional): Specifies the name of the table in use. Defaults to "embeddings". content_field (str, optional): Specifies the field to store the content. Defaults to "content". metadata_field (str, optional): Specifies the field to store metadata. Defaults to "metadata". vector_field (str, optional): Specifies the field to store the vector. Defaults to "vector". id_field (str, optional): Specifies the field to store the id. Defaults to "id". use_vector_index (bool, optional): Toggles the use of a vector index. Works only with SingleStoreDB 8.5 or later. Defaults to False. If set to True, vector_size parameter is required to be set to a proper value. vector_index_name (str, optional): Specifies the name of the vector index. Defaults to empty. Will be ignored if use_vector_index is set to False. vector_index_options (dict, optional): Specifies the options for the vector index. Defaults to {}. Will be ignored if use_vector_index is set to False. The options are: index_type (str, optional): Specifies the type of the index. Defaults to IVF_PQFS. For more options, please refer to the SingleStoreDB documentation: https://docs.singlestore.com/cloud/reference/sql-reference/vector-functions/vector-indexing/ vector_size (int, optional): Specifies the size of the vector. Defaults to 1536. Required if use_vector_index is set to True. Should be set to the same value as the size of the vectors stored in the vector_field. use_full_text_search (bool, optional): Toggles the use a full-text index on the document content. Defaults to False. If set to True, the table will be created with a full-text index on the content field, and the simularity_search method will all using TEXT_ONLY, FILTER_BY_TEXT, FILTER_BY_VECTOR, and WIGHTED_SUM search strategies. If set to False, the simularity_search method will only allow VECTOR_ONLY search strategy.
pool_size (int, optional): Determines the number of active connections in
the pool. Defaults to 5.
max_overflow (int, optional): Determines the maximum number of connections
allowed beyond the pool_size. Defaults to 10.
timeout (float, optional): Specifies the maximum wait time in seconds for
establishing a connection. Defaults to 30.
Additional optional arguments provide further customization over the
database connection:
pure_python (bool, optional): Toggles the connector mode. If True,
operates in pure Python mode.
local_infile (bool, optional): Allows local file uploads.
charset (str, optional): Specifies the character set for string values.
ssl_key (str, optional): Specifies the path of the file containing the SSL
key.
ssl_cert (str, optional): Specifies the path of the file containing the SSL
certificate.
ssl_ca (str, optional): Specifies the path of the file containing the SSL
certificate authority.
ssl_cipher (str, optional): Sets the SSL cipher list.
ssl_disabled (bool, optional): Disables SSL usage.
ssl_verify_cert (bool, optional): Verifies the server's certificate.
Automatically enabled if ``ssl_ca`` is specified.
ssl_verify_identity (bool, optional): Verifies the server's identity.
conv (dict[int, Callable], optional): A dictionary of data conversion
functions.
credential_type (str, optional): Specifies the type of authentication to
use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO.
autocommit (bool, optional): Enables autocommits.
results_type (str, optional): Determines the structure of the query results:
tuples, namedtuples, dicts.
results_format (str, optional): Deprecated. This option has been renamed to
results_type.
from_texts(
cls: Type[SingleStoreDB],
texts: List[str],
embedding: Embeddings,
metadatas: Optional[List[dict]] = None,
distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
table_name: str = 'embeddings',
content_field: str = 'content',
metadata_field: str = 'metadata',
vector_field: str = 'vector',
id_field: str = 'id',
use_vector_index: bool = False,
vector_index_name: str = '',
vector_index_options: Optional[dict] = None,
vector_size: int = 1536,
use_full_text_search: bool = False,
pool_size: int = 5,
max_overflow: int = 10,
timeout: float = 30,
**kwargs: Any = {}
) -> SingleStoreDBExample:
.. code-block:: python
from langchain_community.vectorstores import SingleStoreDB from langchain_openai import OpenAIEmbeddings
s2 = SingleStoreDB.from_texts( texts, OpenAIEmbeddings(), host="username:password@localhost:3306/database" )