Skip to main content

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

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

langchain_ladybug-0.3.0.tar.gz (10.3 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.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

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

Hashes for langchain_ladybug-0.3.0.tar.gz
Algorithm Hash digest
SHA256 09d93173e46fae0709442a87c705503e298c590474d4d607481228f82737c851
MD5 c2fc97a627ba50bea6dcd9cc044f4cda
BLAKE2b-256 e2a3b0459a893dc2c27c42258ce6a7758a547daac96d7e9fc450e3d855dd1013

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_ladybug-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa649b91d0b41ac9d300d1d0080eb8354b6a44771959bce5ac26212d6cd98583
MD5 0a82229eb23c18fe2882b4d8344c4dcc
BLAKE2b-256 04f868a13ee750043defcbfcf23f946982a1ac9a0df53a0744090835885cbb57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page