Skip to main content

LangChain MatrixOne

This package contains the LangChain integration for MatrixOne.

Installation

You can install this package using pip or uv:

pip install langchain-matrixone
# or
uv pip install langchain-matrixone

Prerequisites

  • A running MatrixOne instance that you can reach over MySQL protocol.
  • Network credentials (host, port, user, password, database) with permission to create tables.
  • An embedding model supported by LangChain (e.g., OpenAIEmbeddings, HuggingFaceEmbeddings, or a custom Embeddings implementation).
  • The MatrixOne Python SDK (installed automatically with this package) must be able to connect with vector operations enabled.

Development

This project uses uv for dependency management.

# Install dependencies
uv sync

# Run tests
uv run pytest

Usage

from langchain_matrixone import MatrixOneVectorStore
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_core.documents import Document

connection_args = {
    "host": "127.0.0.1",
    "port": 6001,
    "user": "root",
    "password": "111",
    "database": "langchain_demo",
}

embedder = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
vector_store = MatrixOneVectorStore(
    embedding=embedder,
    connection_args=connection_args,
    table_name="langchain_vectors",
)

# Ensure you have a running MatrixOne deployment accessible via MySQL.
splitter = RecursiveCharacterTextSplitter(chunk_size=400, chunk_overlap=20)
docs = splitter.split_documents(
    [
        Document(page_content="MatrixOne is a scalable cloud-native database."),
        Document(page_content="LangChain provides common interfaces for LLM apps."),
    ]
)

vector_store.add_texts([doc.page_content for doc in docs], metadatas=[doc.metadata for doc in docs])

query = "What is LangChain?"
similar = vector_store.similarity_search(query, k=2)
for doc in similar:
    print(doc.page_content, doc.metadata)

Using an existing MatrixOne Client

If you already manage a matrixone.Client elsewhere in your application, pass it directly to the vector store to reuse pooled connections:

from matrixone import Client

client = Client()
client.connect(**connection_args)

vector_store = MatrixOneVectorStore(
    embedding=embedder,
    client=client,
    table_name="langchain_vectors",
)

Notes

  • The vector table schema is created automatically if it does not exist. Set drop_old=True during initialization to recreate it.
  • Any additional metadata stored alongside texts must be JSON serializable.
  • MatrixOne currently expects embeddings as VECF32. Ensure the embedding dimension stays constant for a given table.
  • Use MatrixOneVectorStore.from_texts when you want a single call that both creates the store and inserts documents.
  • For advanced vector indexing (IVF/HNSW) or additional capabilities review the MatrixOne vector operations guide.

Features

  • Vector Search with MatrixOne
  • Metadata filtering (if supported)
  • Add/Delete documents

Metadata

Release files for langchain-matrixone 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-matrixone 0.1.0
File Size Uploaded Provenance Actions
langchain_matrixone-0.1.0.tar.gz 4.8 kB Without provenance Details for langchain_matrixone-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-matrixone 0.1.0
File Interpreter ABI Platform Actions
langchain_matrixone-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_matrixone-0.1.0-py3-none-any.whl

Total release size: 9.6 kB

Release files / langchain_matrixone-0.1.0.tar.gz

Download URL langchain_matrixone-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
58477f37e8cba4f8497d6ca33e544cd4813b5688d453b947b8e622c47e9765b8
BLAKE2b-256 checksum
How to use checksums
952f93256ad46313add79403615bb4d588c3c9c149a648f2b61725016beebdd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / langchain_matrixone-0.1.0-py3-none-any.whl

Download URL langchain_matrixone-0.1.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d442e6c5ca0b019ed024a6e2a1a0125296e8196c453266faaa0796efd8b1dc27
BLAKE2b-256 checksum
How to use checksums
624296c176b2317488eea025c4d529432c28a78232473680532e48b767f17694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Security for langchain-matrixone 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page