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 an end-to-end cloud-native database designed for modern applications, including web, mobile, serverless, Jamstack, backend, and traditional applications. With SurrealDB, you can simplify your database and API infrastructure, reduce development time, and build secure, performant apps quickly and cost-effectively.
Key features of SurrealDB include:
- Reduces development time: SurrealDB simplifies your database and API stack by removing the need for most server-side components, allowing you to build secure, performant apps faster and cheaper.
- Real-time collaborative API backend service: SurrealDB functions as both a database and an API backend service, enabling real-time collaboration.
- Support for multiple querying languages: SurrealDB supports SQL querying from client devices, GraphQL, ACID transactions, WebSocket connections, structured and unstructured data, graph querying, full-text indexing, and geospatial querying.
- Granular access control: SurrealDB provides row-level permissions-based access control, giving you the ability to manage data access with precision.
View the features, the latest releases, and documentation.
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 jupyther 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.0.tar.gz.
File metadata
- Download URL: langchain_surrealdb-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d169c795590b37f31f4a290f0173f839e3f2b9695a016fb0b11b4893bd1597ff
|
|
| MD5 |
35355176323f4ba23a94b92827d28d97
|
|
| BLAKE2b-256 |
7f7386256caeb4d274266b3429f968ffad5938d1525461b172ffce2c33840ea5
|
Provenance
The following attestation bundles were made for langchain_surrealdb-0.1.0.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.0.tar.gz -
Subject digest:
d169c795590b37f31f4a290f0173f839e3f2b9695a016fb0b11b4893bd1597ff - Sigstore transparency entry: 225587001
- Sigstore integration time:
-
Permalink:
surrealdb/langchain-surrealdb@47aaf14a9b0e8c4a26439f4fce202285497bf970 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/surrealdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47aaf14a9b0e8c4a26439f4fce202285497bf970 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_surrealdb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_surrealdb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 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 |
3cf7e45d3111f0211d47aafc3c09c090f89d0a8419cd497c91f361d3e51c601d
|
|
| MD5 |
f2f3ab6e2fe8859a3f239e7aaebe6f40
|
|
| BLAKE2b-256 |
c7a0de30ae978a846afd27294195fe04ccd3de8d6b979c74a8aca343a1fdb160
|
Provenance
The following attestation bundles were made for langchain_surrealdb-0.1.0-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.0-py3-none-any.whl -
Subject digest:
3cf7e45d3111f0211d47aafc3c09c090f89d0a8419cd497c91f361d3e51c601d - Sigstore transparency entry: 225587010
- Sigstore integration time:
-
Permalink:
surrealdb/langchain-surrealdb@47aaf14a9b0e8c4a26439f4fce202285497bf970 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/surrealdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47aaf14a9b0e8c4a26439f4fce202285497bf970 -
Trigger Event:
push
-
Statement type: