LangChain integration for the Ladybug graph database.
Project description
langchain-ladybug
LangChain integration for the Ladybug graph database.
This package provides:
LadybugGraph— a LangChain graph wrapper for Ladybug that supports schema introspection, Cypher queries, and document ingestion viaadd_graph_documents.LadybugQAChain— a question-answering chain that generates Ladybug-dialect Cypher queries from natural language and returns answers grounded in the graph.- Prompt templates (
LADYBUG_GENERATION_PROMPT,CYPHER_QA_PROMPT) tuned for the Ladybug Cypher dialect.
Installation
uv pip install langchain-ladybug
The ladybug Python package must also be installed:
uv pip install ladybug
Quick Start
import ladybug as lb
from langchain_ladybug import LadybugGraph, LadybugQAChain
from langchain_openai import ChatOpenAI
db = lb.Database("/path/to/my.db")
graph = LadybugGraph(db)
llm = ChatOpenAI(model="gpt-4o", temperature=0)
chain = LadybugQAChain.from_llm(
llm=llm,
graph=graph,
)
answer = chain.invoke({"query": "Who acted in The Godfather?"})
print(answer["result"])
Development
# Install dependencies
uv sync
# Run unit tests
make test
# Lint
make lint
# Format
make format
Acknowledgements
Started from the Kuzu → Ladybug LangChain support port by @adsharma (PR #438) — a proposed LadybugDB (formerly Kuzu) integration into the upstream langchain-community repo
Project Structure
langchain_ladybug/
├── graphs/
│ ├── graph_document.py # Node, Relationship, GraphDocument data classes
│ └── ladybug_graph.py # LadybugGraph wrapper
└── chains/
├── prompts.py # Ladybug-dialect Cypher prompt templates
└── ladybug_qa.py # LadybugQAChain
tests/
├── unit_tests/ # No network calls
└── integration_tests/ # Requires ladybug
Project details
Release history Release notifications | RSS feed
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_ladybug-0.3.0.tar.gz.
File metadata
- Download URL: langchain_ladybug-0.3.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d93173e46fae0709442a87c705503e298c590474d4d607481228f82737c851
|
|
| MD5 |
c2fc97a627ba50bea6dcd9cc044f4cda
|
|
| BLAKE2b-256 |
e2a3b0459a893dc2c27c42258ce6a7758a547daac96d7e9fc450e3d855dd1013
|
File details
Details for the file langchain_ladybug-0.3.0-py3-none-any.whl.
File metadata
- Download URL: langchain_ladybug-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa649b91d0b41ac9d300d1d0080eb8354b6a44771959bce5ac26212d6cd98583
|
|
| MD5 |
0a82229eb23c18fe2882b4d8344c4dcc
|
|
| BLAKE2b-256 |
04f868a13ee750043defcbfcf23f946982a1ac9a0df53a0744090835885cbb57
|