Skip to main content

FalkorDB LangChain JS/TS integration

The @falkordb/langchain-ts package enables developers to use FalkorDB’s ultra-fast graph database alongside their LangChain applications. What this means in practice is that your application can now take natural language questions, automatically generate the corresponding Cypher queries, pull the relevant context from your graph database, and return responses in plain language. The entire translation layer gets handled for you. The package fits into existing LangChain workflows, so if you are already using that framework for other AI capabilities, this becomes another tool in your stack. FalkorDB’s low latency characteristics combine with LangChain’s language model integration to provide quick responses.

About FalkorDB

An ultra-fast, multi-tenant graph database powering Generative AI, Agent Memory, Cloud Security, and Fraud Detection. FalkorDB is the first queryable Property Graph Database to leverage sparse matrices for representing the adjacency matrix in graphs and linear algebra for querying.

Installation

npm2yarn
You’ll also need LangChain and a language model:
npm2yarn

Quick start

1. Start FalkorDB

The easiest way to run FalkorDB is with Docker:

2. Basic usage

The @langchain/community package is no longer maintained. Examples that import from @langchain/community may be outdated or broken. Use with caution.

API reference

FalkorDBGraph

initialize(config: FalkorDBGraphConfig): Promise<FalkorDBGraph>

Creates and initializes a new FalkorDB connection. Config Options:
  • host (string, optional): Database host. Default: "localhost"
  • port (number, optional): Database port. Default: 6379
  • graph (string, optional): Graph name to use
  • url (string, optional): Alternative connection URL format
  • enhancedSchema (boolean, optional): Enable enhanced schema details. Default: false
Example:

query(query: string): Promise<any>

Executes a Cypher query on the graph.

refreshSchema(): Promise<void>

Updates the graph schema information.

getSchema(): string

Returns the current graph schema as a formatted string.

getStructuredSchema(): StructuredSchema

Returns the structured schema object containing node properties, relationship properties, and relationships.

close(): Promise<void>

Closes the database connection.

Advanced usage

Custom cypher queries

Multiple queries

Working with schema

Requirements

  • Node.js >= 18
  • FalkorDB server running (Redis-compatible)
  • LangChain >= 0.1.0

Examples

For more examples, see the @falkordb/langchain-ts repository on GitHub.

License

MIT

Support