From 0443a6e5560f267507efc40abbad85094e50fcff Mon Sep 17 00:00:00 2001 From: Naseem Ali <34807727+Naseem77@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:25:10 +0300 Subject: [PATCH 1/5] feat: add FalkorDB integration documentation for JavaScript - Add comprehensive FalkorDB integration guide at src/oss/javascript/integrations/tools/falkordb.mdx - Include installation instructions, API reference, and usage examples - Add FalkorDB card to tools index page in alphabetical order - Document graph database features: Cypher support, schema management, LLM integration --- .../integrations/tools/falkordb.mdx | 209 ++++++++++++++++++ .../javascript/integrations/tools/index.mdx | 7 + 2 files changed, 216 insertions(+) create mode 100644 src/oss/javascript/integrations/tools/falkordb.mdx diff --git a/src/oss/javascript/integrations/tools/falkordb.mdx b/src/oss/javascript/integrations/tools/falkordb.mdx new file mode 100644 index 000000000..c4ec54f53 --- /dev/null +++ b/src/oss/javascript/integrations/tools/falkordb.mdx @@ -0,0 +1,209 @@ +--- +sidebar_label: FalkorDB +--- + +# FalkorDB + +The [@falkordb/langchain-ts](https://www.npmjs.com/package/@falkordb/langchain-ts) package enables developers to use FalkorDB's blazing fast graph database alongside their LangChain applications. + +[FalkorDB](https://www.falkordb.com/) is a high-performance graph database built on Redis that enables you to build knowledge graphs and perform complex graph queries with exceptional speed. + +## Features + +- 🚀 **Blazing Fast**: Built on Redis with optimized graph operations +- 🔗 **Cypher Support**: Use the powerful Cypher query language +- 🧠 **LLM Integration**: Seamless integration with LangChain's QA chains +- 📊 **Schema Management**: Automatic schema detection and updates +- 🔄 **Async/Await**: Modern async API +- 📝 **TypeScript**: Full TypeScript support with type definitions + +## Installation + +```bash npm2yarn +npm install @falkordb/langchain-ts falkordb +``` + +You'll also need LangChain and a language model: + +```bash npm2yarn +npm install langchain @langchain/openai +``` + +## Quick Start + +### 1. Start FalkorDB + +The easiest way to run FalkorDB is with Docker: + +```bash +docker run -p 6379:6379 -it --rm falkordb/falkordb:latest +``` + +### 2. Basic Usage + +```typescript +import { FalkorDBGraph } from "@falkordb/langchain-ts"; +import { ChatOpenAI } from "@langchain/openai"; +import { GraphCypherQAChain } from "@langchain/community/chains/graph_qa/cypher"; + +// Initialize FalkorDB connection +const graph = await FalkorDBGraph.initialize({ + host: "localhost", + port: 6379, + graph: "movies" // Your graph name +}); + +// Set up the language model +const model = new ChatOpenAI({ temperature: 0 }); + +// Create and populate the graph with some data +await graph.query( + "CREATE (a:Actor {name:'Bruce Willis'})" + + "-[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'})" +); + +// Refresh the graph schema +await graph.refreshSchema(); + +// Create a graph QA chain +const chain = GraphCypherQAChain.fromLLM({ + llm: model, + graph: graph as any, // Type assertion for LangChain compatibility +}); + +// Ask questions about your graph +const response = await chain.run("Who played in Pulp Fiction?"); +console.log(response); +// Output: Bruce Willis played in Pulp Fiction. + +// Clean up +await graph.close(); +``` + +## API Reference + +### FalkorDBGraph + +#### `initialize(config: FalkorDBGraphConfig): Promise` + +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:** +```typescript +const graph = await FalkorDBGraph.initialize({ + host: "localhost", + port: 6379, + graph: "myGraph", + enhancedSchema: true +}); +``` + +#### `query(query: string): Promise` + +Executes a Cypher query on the graph. + +```typescript +const result = await graph.query( + "MATCH (n:Person) RETURN n.name LIMIT 10" +); +``` + +#### `refreshSchema(): Promise` + +Updates the graph schema information. + +```typescript +await graph.refreshSchema(); +console.log(graph.getSchema()); +``` + +#### `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` + +Closes the database connection. + +```typescript +await graph.close(); +``` + +## Advanced Usage + +### Custom Cypher Queries + +```typescript +const graph = await FalkorDBGraph.initialize({ + host: "localhost", + port: 6379, + graph: "movies" +}); + +// Complex query +const result = await graph.query(` + MATCH (a:Actor)-[:ACTED_IN]->(m:Movie) + WHERE m.year > 2000 + RETURN a.name, m.title, m.year + ORDER BY m.year DESC + LIMIT 10 +`); + +console.log(result.data); +``` + +### Multiple Queries + +```typescript +await graph.executeQueries([ + "CREATE (p:Person {name: 'Alice'})", + "CREATE (p:Person {name: 'Bob'})", + "MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'}) CREATE (a)-[:KNOWS]->(b)" +]); +``` + +### Working with Schema + +```typescript +await graph.refreshSchema(); + +// Get formatted schema +const schema = graph.getSchema(); +console.log(schema); + +// Get structured schema +const structuredSchema = graph.getStructuredSchema(); +console.log(structuredSchema.nodeProps); +console.log(structuredSchema.relationships); +``` + +## Requirements + +- Node.js >= 18 +- FalkorDB server running (Redis-compatible) +- LangChain >= 0.1.0 + +## Examples + +For more examples, see the [@falkordb/langchain-ts repository](https://github.com/FalkorDB/FalkorDB-Langchain-js) on GitHub. + +## License + +MIT + +## Support + +- 📫 [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) +- 🌐 Website: https://www.falkordb.com/ \ No newline at end of file diff --git a/src/oss/javascript/integrations/tools/index.mdx b/src/oss/javascript/integrations/tools/index.mdx index 56efb896a..bb9cb8efa 100644 --- a/src/oss/javascript/integrations/tools/index.mdx +++ b/src/oss/javascript/integrations/tools/index.mdx @@ -58,6 +58,13 @@ A [toolkit](/oss/langchain/tools#toolkits) is a collection of tools meant to be arrow="true" cta="View guide" /> + Date: Thu, 23 Oct 2025 14:37:21 +0300 Subject: [PATCH 2/5] Revise FalkorDB LangChain JS/TS integration docs Updated the FalkorDB integration documentation to enhance clarity and detail about its features and usage with LangChain. --- .../javascript/integrations/tools/falkordb.mdx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/oss/javascript/integrations/tools/falkordb.mdx b/src/oss/javascript/integrations/tools/falkordb.mdx index c4ec54f53..68303790d 100644 --- a/src/oss/javascript/integrations/tools/falkordb.mdx +++ b/src/oss/javascript/integrations/tools/falkordb.mdx @@ -2,20 +2,12 @@ sidebar_label: FalkorDB --- -# FalkorDB +# FalkorDB LangChain JS/TS Integration -The [@falkordb/langchain-ts](https://www.npmjs.com/package/@falkordb/langchain-ts) package enables developers to use FalkorDB's blazing fast graph database alongside their LangChain applications. +The [@falkordb/langchain-ts](https://www.npmjs.com/package/@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. -[FalkorDB](https://www.falkordb.com/) is a high-performance graph database built on Redis that enables you to build knowledge graphs and perform complex graph queries with exceptional speed. +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. -## Features - -- 🚀 **Blazing Fast**: Built on Redis with optimized graph operations -- 🔗 **Cypher Support**: Use the powerful Cypher query language -- 🧠 **LLM Integration**: Seamless integration with LangChain's QA chains -- 📊 **Schema Management**: Automatic schema detection and updates -- 🔄 **Async/Await**: Modern async API -- 📝 **TypeScript**: Full TypeScript support with type definitions ## Installation @@ -205,5 +197,5 @@ MIT ## Support -- 📫 [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) -- 🌐 Website: https://www.falkordb.com/ \ No newline at end of file +- [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) +- Website: https://www.falkordb.com/ From de5d5f5b09dea1e996cde9a3bfad6a6ebd44f614 Mon Sep 17 00:00:00 2001 From: Dandan7 <182233217+danshalev7@users.noreply.github.com> Date: Thu, 23 Oct 2025 14:41:06 +0300 Subject: [PATCH 3/5] Update falkordb.mdx --- src/oss/javascript/integrations/tools/falkordb.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/oss/javascript/integrations/tools/falkordb.mdx b/src/oss/javascript/integrations/tools/falkordb.mdx index 68303790d..31acb8ef0 100644 --- a/src/oss/javascript/integrations/tools/falkordb.mdx +++ b/src/oss/javascript/integrations/tools/falkordb.mdx @@ -8,6 +8,9 @@ The [@falkordb/langchain-ts](https://www.npmjs.com/package/@falkordb/langchain-t 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](https://falkordb.com) is the first queryable Property Graph Database to leverage sparse matrices for representing the adjacency matrix in graphs and linear algebra for querying. + ## Installation From 3fd473ce884f82156cc0e3786a823b299e94edc6 Mon Sep 17 00:00:00 2001 From: Naseem Ali <34807727+Naseem77@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:58:16 +0200 Subject: [PATCH 4/5] Update falkordb.mdx --- .../integrations/tools/falkordb.mdx | 155 +++++++++++++++++- 1 file changed, 153 insertions(+), 2 deletions(-) diff --git a/src/oss/javascript/integrations/tools/falkordb.mdx b/src/oss/javascript/integrations/tools/falkordb.mdx index 31acb8ef0..a66a80191 100644 --- a/src/oss/javascript/integrations/tools/falkordb.mdx +++ b/src/oss/javascript/integrations/tools/falkordb.mdx @@ -1,4 +1,6 @@ --- +title: FalkorDB +description: Use FalkorDB's ultra-fast graph database with LangChain for natural language queries over knowledge graphs using Cypher sidebar_label: FalkorDB --- @@ -9,6 +11,7 @@ The [@falkordb/langchain-ts](https://www.npmjs.com/package/@falkordb/langchain-t 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](https://falkordb.com) is the first queryable Property Graph Database to leverage sparse matrices for representing the adjacency matrix in graphs and linear algebra for querying. @@ -24,7 +27,7 @@ You'll also need LangChain and a language model: npm install langchain @langchain/openai ``` -## Quick Start +## Quick start ### 1. Start FalkorDB @@ -34,7 +37,7 @@ The easiest way to run FalkorDB is with Docker: docker run -p 6379:6379 -it --rm falkordb/falkordb:latest ``` -### 2. Basic Usage +### 2. Basic usage ```typescript import { FalkorDBGraph } from "@falkordb/langchain-ts"; @@ -136,6 +139,154 @@ Closes the database connection. await graph.close(); ``` +## Advanced usage + +### Custom Cypher queries + +```typescript +const graph = await FalkorDBGraph.initialize({ + host: "localhost", + port: 6379, + graph: "movies" +}); + +// Complex query +const result = await graph.query(` + MATCH (a:Actor)-[:ACTED_IN]->(m:Movie) + WHERE m.year > 2000 + RETURN a.name, m.title, m.year + ORDER BY m.year DESC + LIMIT 10 +`); + +console.log(result.data); +``` + +### Multiple queries + +```typescript +await graph.executeQueries([ + "CREATE (p:Person {name: 'Alice'})", + "CREATE (p:Person {name: 'Bob'})", + "MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'}) CREATE (a)-[:KNOWS]->(b)" +]); +``` + +### Working with schema + +```typescript +await graph.refreshSchema(); + +// Get formatted schema +const schema = graph.getSchema(); +console.log(schema); + +// Get structured schema +const structuredSchema = graph.getStructuredSchema(); +console.log(structuredSchema.nodeProps); +console.log(structuredSchema.relationships); +``` + +## Requirements + +- Node.js >= 18 +- FalkorDB server running (Redis-compatible) +- LangChain >= 0.1.0 + +## Examples + +For more examples, see the [@falkordb/langchain-ts repository](https://github.com/FalkorDB/FalkorDB-Langchain-js) on GitHub. + +## License + +MIT + +## Support + +- [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) +- Website: https://www.falkordb.com/ + "-[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'})" +); + +// Refresh the graph schema +await graph.refreshSchema(); + +// Create a graph QA chain +const chain = GraphCypherQAChain.fromLLM({ + llm: model, + graph: graph as any, // Type assertion for LangChain compatibility +}); + +// Ask questions about your graph +const response = await chain.run("Who played in Pulp Fiction?"); +console.log(response); +// Output: Bruce Willis played in Pulp Fiction. + +// Clean up +await graph.close(); +``` + +## API Reference + +### FalkorDBGraph + +#### `initialize(config: FalkorDBGraphConfig): Promise` + +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:** +```typescript +const graph = await FalkorDBGraph.initialize({ + host: "localhost", + port: 6379, + graph: "myGraph", + enhancedSchema: true +}); +``` + +#### `query(query: string): Promise` + +Executes a Cypher query on the graph. + +```typescript +const result = await graph.query( + "MATCH (n:Person) RETURN n.name LIMIT 10" +); +``` + +#### `refreshSchema(): Promise` + +Updates the graph schema information. + +```typescript +await graph.refreshSchema(); +console.log(graph.getSchema()); +``` + +#### `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` + +Closes the database connection. + +```typescript +await graph.close(); +``` + ## Advanced Usage ### Custom Cypher Queries From 03e76e9cbdb0f8dafa903ce081d0d6d2adfbad7c Mon Sep 17 00:00:00 2001 From: Naseem Ali <34807727+Naseem77@users.noreply.github.com> Date: Mon, 27 Oct 2025 10:12:03 +0200 Subject: [PATCH 5/5] Update falkordb.mdx --- .../integrations/tools/falkordb.mdx | 148 ------------------ 1 file changed, 148 deletions(-) diff --git a/src/oss/javascript/integrations/tools/falkordb.mdx b/src/oss/javascript/integrations/tools/falkordb.mdx index a66a80191..dffb61ac6 100644 --- a/src/oss/javascript/integrations/tools/falkordb.mdx +++ b/src/oss/javascript/integrations/tools/falkordb.mdx @@ -203,153 +203,5 @@ MIT ## Support -- [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) -- Website: https://www.falkordb.com/ - "-[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'})" -); - -// Refresh the graph schema -await graph.refreshSchema(); - -// Create a graph QA chain -const chain = GraphCypherQAChain.fromLLM({ - llm: model, - graph: graph as any, // Type assertion for LangChain compatibility -}); - -// Ask questions about your graph -const response = await chain.run("Who played in Pulp Fiction?"); -console.log(response); -// Output: Bruce Willis played in Pulp Fiction. - -// Clean up -await graph.close(); -``` - -## API Reference - -### FalkorDBGraph - -#### `initialize(config: FalkorDBGraphConfig): Promise` - -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:** -```typescript -const graph = await FalkorDBGraph.initialize({ - host: "localhost", - port: 6379, - graph: "myGraph", - enhancedSchema: true -}); -``` - -#### `query(query: string): Promise` - -Executes a Cypher query on the graph. - -```typescript -const result = await graph.query( - "MATCH (n:Person) RETURN n.name LIMIT 10" -); -``` - -#### `refreshSchema(): Promise` - -Updates the graph schema information. - -```typescript -await graph.refreshSchema(); -console.log(graph.getSchema()); -``` - -#### `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` - -Closes the database connection. - -```typescript -await graph.close(); -``` - -## Advanced Usage - -### Custom Cypher Queries - -```typescript -const graph = await FalkorDBGraph.initialize({ - host: "localhost", - port: 6379, - graph: "movies" -}); - -// Complex query -const result = await graph.query(` - MATCH (a:Actor)-[:ACTED_IN]->(m:Movie) - WHERE m.year > 2000 - RETURN a.name, m.title, m.year - ORDER BY m.year DESC - LIMIT 10 -`); - -console.log(result.data); -``` - -### Multiple Queries - -```typescript -await graph.executeQueries([ - "CREATE (p:Person {name: 'Alice'})", - "CREATE (p:Person {name: 'Bob'})", - "MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'}) CREATE (a)-[:KNOWS]->(b)" -]); -``` - -### Working with Schema - -```typescript -await graph.refreshSchema(); - -// Get formatted schema -const schema = graph.getSchema(); -console.log(schema); - -// Get structured schema -const structuredSchema = graph.getStructuredSchema(); -console.log(structuredSchema.nodeProps); -console.log(structuredSchema.relationships); -``` - -## Requirements - -- Node.js >= 18 -- FalkorDB server running (Redis-compatible) -- LangChain >= 0.1.0 - -## Examples - -For more examples, see the [@falkordb/langchain-ts repository](https://github.com/FalkorDB/FalkorDB-Langchain-js) on GitHub. - -## License - -MIT - -## Support - - [GitHub Issues](https://github.com/FalkorDB/FalkorDB-Langchain-js/issues) - Website: https://www.falkordb.com/