An integration package connecting SurrealDB and LangChain
Project description
The official SurrealDB components for LangChain
langchain-surrealdb
This package contains the LangChain integration with SurrealDB
SurrealDB is a unified, multi-model database purpose-built for AI systems. It combines structured and unstructured data (including vector search, graph traversal, relational queries, full-text search, document storage, and time-series data) into a single ACID-compliant engine, scaling from a 3 MB edge binary to petabyte-scale clusters in the cloud. By eliminating the need for multiple specialized stores, SurrealDB simplifies architectures, reduces latency, and ensures consistency for AI workloads.
Why SurrealDB Matters for GenAI Systems
- One engine for storage and memory: Combine durable storage and fast, agent-friendly memory in a single system, providing all the data your agent needs and removing the need to sync multiple systems.
- One-hop memory for agents: Run vector search, graph traversal, semantic joins, and transactional writes in a single query, giving LLM agents fast, consistent memory access without stitching relational, graph and vector databases together.
- In-place inference and real-time updates: SurrealDB enables agents to run inference next to data and receive millisecond-fresh updates, critical for real-time reasoning and collaboration.
- Versioned, durable context: SurrealDB supports time-travel queries and versioned records, letting agents audit or “replay” past states for consistent, explainable reasoning.
- Plug-and-play agent memory: Expose AI memory as a native concept, making it easy to use SurrealDB as a drop-in backend for AI frameworks.
Installation
# -- Using pip
pip install -U langchain-surrealdb surrealdb
# -- Using poetry
poetry add langchain-surrealdb surrealdb
# -- Using uv
uv add --upgrade langchain-surrealdb surrealdb
Requirements
You can run SurrealDB locally or start with a free SurrealDB cloud account.
For local, two options:
- Install SurrealDB and run SurrealDB. Run in-memory with:
surreal start -u root -p root
docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start
Simple example
from langchain_core.documents import Document
from langchain_surrealdb.vectorstores import SurrealDBVectorStore
from langchain_ollama import OllamaEmbeddings
from surrealdb import Surreal
conn = Surreal("ws://localhost:8000/rpc")
conn.signin({"username": "root", "password": "root"})
conn.use("langchain", "demo")
vector_store = SurrealDBVectorStore(OllamaEmbeddings(model="llama3.2"), conn)
doc_1 = Document(page_content="foo", metadata={"source": "https://surrealdb.com"})
doc_2 = Document(page_content="SurrealDB", metadata={"source": "https://surrealdb.com"})
vector_store.add_documents(documents=[doc_1, doc_2], ids=["1", "2"])
results = vector_store.similarity_search_with_score(
query="surreal", k=1, custom_filter={"source": "https://surrealdb.com"}
)
for doc, score in results:
print(f"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]")
Next steps
- look at the basic example. Use the Dockerfile to try it out!
- look at the graph example
- try the jupyter notebook
- Awesome SurrealDB, A curated list of SurrealDB resources, tools, utilities, and applications
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_surrealdb-0.1.3.tar.gz.
File metadata
- Download URL: langchain_surrealdb-0.1.3.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddc38d601dccc3123366bfd42f98de66a838d85c1ffc40a6a5178998cf6dac07
|
|
| MD5 |
7e296fece138b3f94a65c39a8573a465
|
|
| BLAKE2b-256 |
3a69ea5d8ce874ff3216841a8f4db3c194ca0df36963424d09789040a9f9cf59
|
Provenance
The following attestation bundles were made for langchain_surrealdb-0.1.3.tar.gz:
Publisher:
release.yml on surrealdb/langchain-surrealdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_surrealdb-0.1.3.tar.gz -
Subject digest:
ddc38d601dccc3123366bfd42f98de66a838d85c1ffc40a6a5178998cf6dac07 - Sigstore transparency entry: 261824088
- Sigstore integration time:
-
Permalink:
surrealdb/langchain-surrealdb@a6b3813814d7daff7b2e023fcd75dcc6955899ad -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/surrealdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6b3813814d7daff7b2e023fcd75dcc6955899ad -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_surrealdb-0.1.3-py3-none-any.whl.
File metadata
- Download URL: langchain_surrealdb-0.1.3-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d5593ff1ad13db56f3391fd7ace82ab45ad0b41f1291cb3cc19d5b773dfe591
|
|
| MD5 |
0ec39f5da4f0764f42d77fce9920425d
|
|
| BLAKE2b-256 |
da6a41ed1775c4c6534bcb921b2da8898ae1b06fc05f6a3d679e666b234c0c8a
|
Provenance
The following attestation bundles were made for langchain_surrealdb-0.1.3-py3-none-any.whl:
Publisher:
release.yml on surrealdb/langchain-surrealdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_surrealdb-0.1.3-py3-none-any.whl -
Subject digest:
9d5593ff1ad13db56f3391fd7ace82ab45ad0b41f1291cb3cc19d5b773dfe591 - Sigstore transparency entry: 261824096
- Sigstore integration time:
-
Permalink:
surrealdb/langchain-surrealdb@a6b3813814d7daff7b2e023fcd75dcc6955899ad -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/surrealdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6b3813814d7daff7b2e023fcd75dcc6955899ad -
Trigger Event:
push
-
Statement type: