Source code for langchain_community.vectorstores.surrealdb
import asyncio
from typing import (
    Any,
    Iterable,
    List,
    Optional,
    Tuple,
)
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.vectorstores import VectorStore
[docs]class SurrealDBStore(VectorStore):
    """
    SurrealDB as Vector Store.
    To use, you should have the ``surrealdb`` python package installed.
    Args:
        embedding_function: Embedding function to use.
        dburl: SurrealDB connection url
        ns: surrealdb namespace for the vector store. (default: "langchain")
        db: surrealdb database for the vector store. (default: "database")
        collection: surrealdb collection for the vector store.
            (default: "documents")
        (optional) db_user and db_pass: surrealdb credentials
    Example:
        .. code-block:: python
            from langchain.vectorstores.surrealdb import SurrealDBStore
            from langchain.embeddings import HuggingFaceEmbeddings
            embedding_function = HuggingFaceEmbeddings()
            dburl = "ws://localhost:8000/rpc"
            ns = "langchain"
            db = "docstore"
            collection = "documents"
            db_user = "root"
            db_pass = "root"
            sdb = SurrealDBStore.from_texts(
                    texts=texts,
                    embedding=embedding_function,
                    dburl,
                    ns, db, collection,
                    db_user=db_user, db_pass=db_pass)
    """
[docs]    def __init__(
        self,
        embedding_function: Embeddings,
        **kwargs: Any,