Skip to main content

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 via add_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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_ladybug-0.3.1.tar.gz (237.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_ladybug-0.3.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_ladybug-0.3.1.tar.gz.

File metadata

  • Download URL: langchain_ladybug-0.3.1.tar.gz
  • Upload date:
  • Size: 237.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for langchain_ladybug-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f0889fc360241ecd3dbd17478f867853df3faeda68023c24226b3a8973ce4e6d
MD5 c10d977f71dd9fa7bd0f8530d450722b
BLAKE2b-256 f8ddd6b9904a4f71454e6851134ed246da24f562210dd00521ac27ea740b29c9

See more details on using hashes here.

File details

Details for the file langchain_ladybug-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_ladybug-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cab20fae1dc9306d6b5a5422e4491744677bf4d0c497cc7cea474f92f14507c3
MD5 583a4845d68543261e8c419939f3804a
BLAKE2b-256 5c814f91e563c03e707da057a9451e66e1816d79b877cf853c8a22ab6d06dade

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

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