diff --git a/docs/docs/integrations/graphs/kuzu_db.ipynb b/docs/docs/integrations/graphs/kuzu_db.ipynb index dde4dddc6c6f4..a030a205380c1 100644 --- a/docs/docs/integrations/graphs/kuzu_db.ipynb +++ b/docs/docs/integrations/graphs/kuzu_db.ipynb @@ -7,12 +7,17 @@ "source": [ "# Kuzu\n", "\n", - ">[Kùzu](https://kuzudb.com) is an embeddable property graph database management system built for query speed and scalability.\n", - "> \n", - "> Kùzu has a permissive (MIT) open source license and implements [Cypher](https://en.wikipedia.org/wiki/Cypher_(query_language)), a declarative graph query language that allows for expressive and efficient data querying in a property graph.\n", - "> It uses columnar storage and its query processor contains novel join algorithms that allow it to scale to very large graphs without sacrificing query performance.\n", - "> \n", - "> This notebook shows how to use LLMs to provide a natural language interface to [Kùzu](https://kuzudb.com) database with Cypher." + "> [Kùzu](https://kuzudb.com/) is an embeddable, scalable, extremely fast graph database.\n", + "> It is permissively licensed with an MIT license, and you can see its source code [here](https://github.com/kuzudb/kuzu).\n", + "\n", + "> Key characteristics of Kùzu:\n", + ">- Performance and scalability: Implements modern, state-of-the-art join algorithms for graphs.\n", + ">- Usability: Very easy to set up and get started with, as there are no servers (embedded architecture).\n", + ">- Interoperability: Can conveniently scan and copy data from external columnar formats, CSV, JSON and relational databases.\n", + ">- Structured property graph model: Implements the property graph model, with added structure.\n", + ">- Cypher support: Allows convenient querying of the graph in Cypher, a declarative query language.\n", + "\n", + "> Get started with Kùzu by visiting their [documentation](https://docs.kuzudb.com/)." ] }, { @@ -22,19 +27,28 @@ "source": [ "## Setting up\n", "\n", - "Kùzu is an embedded database (it runs in-process), so there are no servers to manage.\n", - "Simply install it via its Python package:\n", + "Kùzu is an embedded database (it runs in-process), so there are no servers to manage. Install the\n", + "following dependencies to get started:\n", "\n", "```bash\n", - "pip install kuzu\n", + "pip install -U langchain-kuzu langchain-openai langchain-experimental\n", "```\n", "\n", - "Create a database on the local machine and connect to it:" + "This installs Kùzu along with the LangChain integration for it, as well as the OpenAI Python package\n", + "so that we can use OpenAI's LLMs. If you want to use other LLM providers, you can install their\n", + "respective Python packages that come with LangChain." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here's how you would first create a Kùzu database on your local machine and connect to it:" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -45,102 +59,75 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "First, we create the schema for a simple movie database:" + "## Create `KuzuGraph`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Kùzu's integration with LangChain makes it convenient to create and update graphs from unstructured text, and also to query graphs via a Text2Cypher pipeline that utilizes the\n", + "power of LangChain's LLM chains. To begin, we create a `KuzuGraph` object that uses the database object we created above in combination with the `KuzuGraph` constructor." ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "conn.execute(\"CREATE NODE TABLE Movie (name STRING, PRIMARY KEY(name))\")\n", - "conn.execute(\n", - " \"CREATE NODE TABLE Person (name STRING, birthDate STRING, PRIMARY KEY(name))\"\n", - ")\n", - "conn.execute(\"CREATE REL TABLE ActedIn (FROM Person TO Movie)\")" + "from langchain_kuzu.graphs.kuzu_graph import KuzuGraph\n", + "\n", + "graph = KuzuGraph(db, allow_dangerous_requests=True)" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "Then we can insert some data." + "Say we want to transform the following text into a graph:" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "conn.execute(\"CREATE (:Person {name: 'Al Pacino', birthDate: '1940-04-25'})\")\n", - "conn.execute(\"CREATE (:Person {name: 'Robert De Niro', birthDate: '1943-08-17'})\")\n", - "conn.execute(\"CREATE (:Movie {name: 'The Godfather'})\")\n", - "conn.execute(\"CREATE (:Movie {name: 'The Godfather: Part II'})\")\n", - "conn.execute(\n", - " \"CREATE (:Movie {name: 'The Godfather Coda: The Death of Michael Corleone'})\"\n", - ")\n", - "conn.execute(\n", - " \"MATCH (p:Person), (m:Movie) WHERE p.name = 'Al Pacino' AND m.name = 'The Godfather' CREATE (p)-[:ActedIn]->(m)\"\n", - ")\n", - "conn.execute(\n", - " \"MATCH (p:Person), (m:Movie) WHERE p.name = 'Al Pacino' AND m.name = 'The Godfather: Part II' CREATE (p)-[:ActedIn]->(m)\"\n", - ")\n", - "conn.execute(\n", - " \"MATCH (p:Person), (m:Movie) WHERE p.name = 'Al Pacino' AND m.name = 'The Godfather Coda: The Death of Michael Corleone' CREATE (p)-[:ActedIn]->(m)\"\n", - ")\n", - "conn.execute(\n", - " \"MATCH (p:Person), (m:Movie) WHERE p.name = 'Robert De Niro' AND m.name = 'The Godfather: Part II' CREATE (p)-[:ActedIn]->(m)\"\n", - ")" + "text = \"Tim Cook is the CEO of Apple. Apple has its headquarters in California.\"" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "## Creating `KuzuQAChain`\n", - "\n", - "We can now create the `KuzuGraph` and `KuzuQAChain`. To create the `KuzuGraph` we simply need to pass the database object to the `KuzuGraph` constructor." + "We will make use of `LLMGraphTransformer` to use an LLM to extract nodes and relationships from the text.\n", + "To make the graph more useful, we will define the following schema, such that the LLM will only\n", + "extract nodes and relationships that match the schema." ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "from langchain.chains import KuzuQAChain\n", - "from langchain_community.graphs import KuzuGraph\n", - "from langchain_openai import ChatOpenAI" + "# Define schema\n", + "allowed_nodes = [\"Person\", \"Company\", \"Location\"]\n", + "allowed_relationships = [\n", + " (\"Person\", \"IS_CEO_OF\", \"Company\"),\n", + " (\"Company\", \"HAS_HEADQUARTERS_IN\", \"Location\"),\n", + "]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `LLMGraphTransformer` class provides a convenient way to convert the text into a list of graph documents." ] }, { @@ -149,7 +136,47 @@ "metadata": {}, "outputs": [], "source": [ - "graph = KuzuGraph(db)" + "from langchain_core.documents import Document\n", + "from langchain_experimental.graph_transformers import LLMGraphTransformer\n", + "from langchain_openai import ChatOpenAI\n", + "\n", + "# Define the LLMGraphTransformer\n", + "llm_transformer = LLMGraphTransformer(\n", + " llm=ChatOpenAI(model=\"gpt-4o-mini\", temperature=0, api_key=OPENAI_API_KEY), # noqa: F821\n", + " allowed_nodes=allowed_nodes,\n", + " allowed_relationships=allowed_relationships,\n", + ")\n", + "\n", + "documents = [Document(page_content=text)]\n", + "graph_documents = llm_transformer.convert_to_graph_documents(documents)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[GraphDocument(nodes=[Node(id='Tim Cook', type='Person', properties={}), Node(id='Apple', type='Company', properties={}), Node(id='California', type='Location', properties={})], relationships=[Relationship(source=Node(id='Tim Cook', type='Person', properties={}), target=Node(id='Apple', type='Company', properties={}), type='IS_CEO_OF', properties={}), Relationship(source=Node(id='Apple', type='Company', properties={}), target=Node(id='California', type='Location', properties={}), type='HAS_HEADQUARTERS_IN', properties={})], source=Document(metadata={}, page_content='Tim Cook is the CEO of Apple. Apple has its headquarters in California.'))]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "graph_documents[:2]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can then call the above defined `KuzuGraph` object's `add_graph_documents` method to ingest the graph documents into the Kùzu database.\n", + "The `include_source` argument is set to `True` so that we also create relationships between each entity node and the source document that it came from." ] }, { @@ -158,10 +185,10 @@ "metadata": {}, "outputs": [], "source": [ - "chain = KuzuQAChain.from_llm(\n", - " llm=ChatOpenAI(temperature=0, model=\"gpt-3.5-turbo-16k\"),\n", - " graph=graph,\n", - " verbose=True,\n", + "# Add the graph document to the graph\n", + "graph.add_graph_documents(\n", + " graph_documents,\n", + " include_source=True,\n", ")" ] }, @@ -170,10 +197,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Refresh graph schema information\n", + "## Creating `KuzuQAChain`\n", "\n", - "If the schema of database changes, you can refresh the schema information needed to generate Cypher statements.\n", - "You can also display the schema of the Kùzu graph as demonstrated below." + "To query the graph via a Text2Cypher pipeline, we can define a `KuzuQAChain` object. Then, we can invoke the chain with a query by connecting to the existing database that's stored in the `test_db` directory defined above." ] }, { @@ -182,27 +208,22 @@ "metadata": {}, "outputs": [], "source": [ - "# graph.refresh_schema()" + "from langchain_kuzu.chains.graph_qa.kuzu import KuzuQAChain\n", + "\n", + "# Create the KuzuQAChain with verbosity enabled to see the generated Cypher queries\n", + "chain = KuzuQAChain.from_llm(\n", + " llm=ChatOpenAI(model=\"gpt-4o-mini\", temperature=0.3, api_key=OPENAI_API_KEY), # noqa: F821\n", + " graph=graph,\n", + " verbose=True,\n", + " allow_dangerous_requests=True,\n", + ")" ] }, { - "cell_type": "code", - "execution_count": 10, + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Node properties: [{'properties': [('name', 'STRING')], 'label': 'Movie'}, {'properties': [('name', 'STRING'), ('birthDate', 'STRING')], 'label': 'Person'}]\n", - "Relationships properties: [{'properties': [], 'label': 'ActedIn'}]\n", - "Relationships: ['(:Person)-[:ActedIn]->(:Movie)']\n", - "\n" - ] - } - ], "source": [ - "print(graph.get_schema)" + "Note that we set a temperature that's slightly higher than zero to avoid the LLM being overly concise in its response." ] }, { @@ -210,14 +231,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Querying the graph\n", - "\n", - "We can now use the `KuzuQAChain` to ask questions of the graph." + "Let's ask some questions using the QA chain." ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -228,11 +247,9 @@ "\n", "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n", "Generated Cypher:\n", - "\u001b[32;1m\u001b[1;3mMATCH (p:Person)-[:ActedIn]->(m:Movie)\n", - "WHERE m.name = 'The Godfather: Part II'\n", - "RETURN p.name\u001b[0m\n", + "\u001b[32;1m\u001b[1;3mMATCH (p:Person)-[:IS_CEO_OF]->(c:Company {id: 'Apple'}) RETURN p\u001b[0m\n", "Full Context:\n", - "\u001b[32;1m\u001b[1;3m[{'p.name': 'Al Pacino'}, {'p.name': 'Robert De Niro'}]\u001b[0m\n", + "\u001b[32;1m\u001b[1;3m[{'p': {'_id': {'offset': 0, 'table': 1}, '_label': 'Person', 'id': 'Tim Cook', 'type': 'entity'}}]\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n" ] @@ -240,22 +257,22 @@ { "data": { "text/plain": [ - "{'query': 'Who acted in The Godfather: Part II?',\n", - " 'result': 'Al Pacino, Robert De Niro acted in The Godfather: Part II.'}" + "{'query': 'Who is the CEO of Apple?',\n", + " 'result': 'Tim Cook is the CEO of Apple.'}" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chain.invoke(\"Who acted in The Godfather: Part II?\")" + "chain.invoke(\"Who is the CEO of Apple?\")" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -266,11 +283,9 @@ "\n", "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n", "Generated Cypher:\n", - "\u001b[32;1m\u001b[1;3mMATCH (p:Person)-[:ActedIn]->(m:Movie)\n", - "WHERE p.name = 'Robert De Niro'\n", - "RETURN m.name\u001b[0m\n", + "\u001b[32;1m\u001b[1;3mMATCH (c:Company {id: 'Apple'})-[:HAS_HEADQUARTERS_IN]->(l:Location) RETURN l\u001b[0m\n", "Full Context:\n", - "\u001b[32;1m\u001b[1;3m[{'m.name': 'The Godfather: Part II'}]\u001b[0m\n", + "\u001b[32;1m\u001b[1;3m[{'l': {'_id': {'offset': 0, 'table': 2}, '_label': 'Location', 'id': 'California', 'type': 'entity'}}]\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n" ] @@ -278,93 +293,50 @@ { "data": { "text/plain": [ - "{'query': 'Robert De Niro played in which movies?',\n", - " 'result': 'Robert De Niro played in The Godfather: Part II.'}" + "{'query': 'Where is Apple headquartered?',\n", + " 'result': 'Apple is headquartered in California.'}" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chain.invoke(\"Robert De Niro played in which movies?\")" + "chain.invoke(\"Where is Apple headquartered?\")" ] }, { - "cell_type": "code", - "execution_count": 13, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n", - "Generated Cypher:\n", - "\u001b[32;1m\u001b[1;3mMATCH (:Person)-[:ActedIn]->(:Movie {name: 'Godfather: Part II'})\n", - "RETURN count(*)\u001b[0m\n", - "Full Context:\n", - "\u001b[32;1m\u001b[1;3m[{'COUNT_STAR()': 0}]\u001b[0m\n", - "\n", - "\u001b[1m> Finished chain.\u001b[0m\n" - ] - }, - { - "data": { - "text/plain": [ - "{'query': 'How many actors played in the Godfather: Part II?',\n", - " 'result': \"I don't know the answer.\"}" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ - "chain.invoke(\"How many actors played in the Godfather: Part II?\")" + "## Refresh graph schema\n", + "\n", + "If you mutate or update the graph, you can inspect the refreshed schema information that's used by the Text2Cypher chain to generate Cypher statements.\n", + "You don't need to manually call `refresh_schema()` each time as it's called automatically when you invoke the chain." ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\n", - "\n", - "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n", - "Generated Cypher:\n", - "\u001b[32;1m\u001b[1;3mMATCH (p:Person)-[:ActedIn]->(m:Movie {name: 'The Godfather: Part II'})\n", - "RETURN p.name\n", - "ORDER BY p.birthDate ASC\n", - "LIMIT 1\u001b[0m\n", - "Full Context:\n", - "\u001b[32;1m\u001b[1;3m[{'p.name': 'Al Pacino'}]\u001b[0m\n", - "\n", - "\u001b[1m> Finished chain.\u001b[0m\n" + "Node properties: [{'properties': [('id', 'STRING'), ('type', 'STRING')], 'label': 'Person'}, {'properties': [('id', 'STRING'), ('type', 'STRING')], 'label': 'Location'}, {'properties': [('id', 'STRING'), ('text', 'STRING'), ('type', 'STRING')], 'label': 'Chunk'}, {'properties': [('id', 'STRING'), ('type', 'STRING')], 'label': 'Company'}]\n", + "Relationships properties: [{'properties': [], 'label': 'HAS_HEADQUARTERS_IN'}, {'properties': [('label', 'STRING'), ('triplet_source_id', 'STRING')], 'label': 'MENTIONS_Chunk_Person'}, {'properties': [('label', 'STRING'), ('triplet_source_id', 'STRING')], 'label': 'MENTIONS_Chunk_Location'}, {'properties': [], 'label': 'IS_CEO_OF'}, {'properties': [('label', 'STRING'), ('triplet_source_id', 'STRING')], 'label': 'MENTIONS_Chunk_Company'}]\n", + "Relationships: ['(:Company)-[:HAS_HEADQUARTERS_IN]->(:Location)', '(:Chunk)-[:MENTIONS_Chunk_Person]->(:Person)', '(:Chunk)-[:MENTIONS_Chunk_Location]->(:Location)', '(:Person)-[:IS_CEO_OF]->(:Company)', '(:Chunk)-[:MENTIONS_Chunk_Company]->(:Company)']\n", + "\n" ] - }, - { - "data": { - "text/plain": [ - "{'query': 'Who is the oldest actor who played in The Godfather: Part II?',\n", - " 'result': 'Al Pacino is the oldest actor who played in The Godfather: Part II.'}" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ - "chain.invoke(\"Who is the oldest actor who played in The Godfather: Part II?\")" + "graph.refresh_schema()\n", + "\n", + "print(graph.get_schema)" ] }, { @@ -378,30 +350,22 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/prrao/code/langchain/.venv/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The class `LLMChain` was deprecated in LangChain 0.1.17 and will be removed in 0.3.0. Use RunnableSequence, e.g., `prompt | llm` instead.\n", - " warn_deprecated(\n" - ] - } - ], + "outputs": [], "source": [ "chain = KuzuQAChain.from_llm(\n", - " cypher_llm=ChatOpenAI(temperature=0, model=\"gpt-3.5-turbo-16k\"),\n", + " cypher_llm=ChatOpenAI(temperature=0, model=\"gpt-4o-mini\"),\n", " qa_llm=ChatOpenAI(temperature=0, model=\"gpt-4\"),\n", " graph=graph,\n", " verbose=True,\n", + " allow_dangerous_requests=True,\n", ")" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -410,40 +374,11 @@ "text": [ "\n", "\n", - "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/prrao/code/langchain/.venv/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", - " warn_deprecated(\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "\u001b[1m> Entering new KuzuQAChain chain...\u001b[0m\n", "Generated Cypher:\n", - "\u001b[32;1m\u001b[1;3mMATCH (:Person)-[:ActedIn]->(:Movie {name: 'The Godfather: Part II'})\n", - "RETURN count(*)\u001b[0m\n", + "\u001b[32;1m\u001b[1;3mMATCH (p:Person)-[:IS_CEO_OF]->(c:Company {id: 'Apple'}) RETURN p.id, p.type\u001b[0m\n", "Full Context:\n", - "\u001b[32;1m\u001b[1;3m[{'COUNT_STAR()': 2}]\u001b[0m\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/prrao/code/langchain/.venv/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.__call__` was deprecated in langchain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", - " warn_deprecated(\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "\u001b[32;1m\u001b[1;3m[{'p.id': 'Tim Cook', 'p.type': 'entity'}]\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n" ] @@ -451,17 +386,17 @@ { "data": { "text/plain": [ - "{'query': 'How many actors played in The Godfather: Part II?',\n", - " 'result': 'Two actors played in The Godfather: Part II.'}" + "{'query': 'Who is the CEO of Apple?',\n", + " 'result': 'Tim Cook is the CEO of Apple.'}" ] }, - "execution_count": 16, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chain.invoke(\"How many actors played in The Godfather: Part II?\")" + "chain.invoke(\"Who is the CEO of Apple?\")" ] } ], @@ -481,7 +416,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.13.1" } }, "nbformat": 4, diff --git a/docs/docs/integrations/providers/kuzu.mdx b/docs/docs/integrations/providers/kuzu.mdx index 286b38e0d81cc..aff0a0f668933 100644 --- a/docs/docs/integrations/providers/kuzu.mdx +++ b/docs/docs/integrations/providers/kuzu.mdx @@ -1,32 +1,40 @@ # Kùzu ->[Kùzu](https://kuzudb.com/) is a company based in Waterloo, Ontario, Canada. -> It provides a highly scalable, extremely fast, easy-to-use [embeddable graph database](https://github.com/kuzudb/kuzu). +> [Kùzu](https://kuzudb.com/) is an embeddable, scalable, extremely fast graph database. +> It is permissively licensed with an MIT license, and you can see its source code [here](https://github.com/kuzudb/kuzu). +> Key characteristics of Kùzu: +>- Performance and scalability: Implements modern, state-of-the-art join algorithms for graphs. +>- Usability: Very easy to set up and get started with, as there are no servers (embedded architecture). +>- Interoperability: Can conveniently scan and copy data from external columnar formats, CSV, JSON and relational databases. +>- Structured property graph model: Implements the property graph model, with added structure. +>- Cypher support: Allows convenient querying of the graph in Cypher, a declarative query language. + +> Get started with Kùzu by visiting their [documentation](https://docs.kuzudb.com/). ## Installation and Setup -You need to install the `kuzu` python package. +Install the Python SDK as follows: ```bash -pip install kuzu +pip install -U langchain-kuzu ``` -## Graph database +## Usage + +## Graphs See a [usage example](/docs/integrations/graphs/kuzu_db). ```python -from langchain_community.graphs import KuzuGraph +from langchain_kuzu.graphs.kuzu_graph import KuzuGraph ``` -## Chain +## Chains See a [usage example](/docs/integrations/graphs/kuzu_db/#creating-kuzuqachain). ```python -from langchain.chains import KuzuQAChain +from langchain_kuzu.chains.graph_qa.kuzu import KuzuQAChain ``` - - diff --git a/libs/packages.yml b/libs/packages.yml index 5fd27064a365f..ce75cf8672cb0 100644 --- a/libs/packages.yml +++ b/libs/packages.yml @@ -324,4 +324,8 @@ packages: - name: langchain-pull-md path: . repo: chigwell/langchain-pull-md - downloads: 0 \ No newline at end of file + downloads: 0 +- name: langchain-kuzu + path: . + repo: kuzudb/langchain-kuzu + downloads: 0