Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cypher query language generating chain #4881

Merged
merged 11 commits into from
May 22, 2023

Conversation

tomasonjo
Copy link
Contributor

@tomasonjo tomasonjo commented May 17, 2023

Add Neo4j support and Cypher generating Chain

The idea is to add support for querying Graph Databases that use Cypher query language like Neo4j.
Since queries need to be constructed at query time, we use a similar approach as the text2sql, but instead of generating SQL statements, we generate Cypher statements based on the provided graph schema, which makes this a generic solution.

Todo

  • Integration test
  • Better exception handling

Fixes # (issue)
#4625

@tomasonjo tomasonjo changed the title <Draft> Add Cypher generating capabilities Add Cypher generating capabilities May 18, 2023
@tomasonjo
Copy link
Contributor Author

tomasonjo commented May 18, 2023

@dev2049 @vowelparrot

@tomasonjo tomasonjo changed the title Add Cypher generating capabilities Add Cypher query language generating chain May 18, 2023
Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fantastic! Can we add instructions to the top of the notebook on how to set up the relevant backend? tough for me to figure out how to test otherwise

@tomasonjo
Copy link
Contributor Author

Thanks for the review @hwchase17 . I've added instructions how to setup Neo4j in the notebook.

@dev2049 dev2049 added the 03 enhancement Enhancement of existing functionality label May 19, 2023
@hwchase17 hwchase17 changed the base branch from master to harrison/cypher May 22, 2023 04:22
@hwchase17 hwchase17 merged commit 1c89d6b into langchain-ai:harrison/cypher May 22, 2023
baskaryan added a commit that referenced this pull request Jul 24, 2023
**Description**: Serves as an introduction to LangChain's support for
[ArangoDB](https://github.com/arangodb/arangodb), similar to
#7165 and
#4881

**Issue**: No issue has been created for this feature

**Dependencies**: `python-arango` has been added as an optional
dependency via the `CONTRIBUTING.md` guidelines
 
**Twitter handle**: [at]arangodb

- Integration test has been added
- Notebook has been added:
[graph_arangodb_qa.ipynb](https://github.com/amahanna/langchain/blob/master/docs/extras/modules/chains/additional/graph_arangodb_qa.ipynb)

[![Open In
Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/amahanna/langchain/blob/master/docs/extras/modules/chains/additional/graph_arangodb_qa.ipynb)

```
docker run -p 8529:8529 -e ARANGO_ROOT_PASSWORD= arangodb/arangodb
```

```
pip install git+https://github.com/amahanna/langchain.git
```

```python
from arango import ArangoClient

from langchain.chat_models import ChatOpenAI
from langchain.graphs import ArangoGraph
from langchain.chains import ArangoGraphQAChain

db = ArangoClient(hosts="localhost:8529").db(name="_system", username="root", password="", verify=True)

graph = ArangoGraph(db)

chain = ArangoGraphQAChain.from_llm(ChatOpenAI(temperature=0), graph=graph)

chain.run("Is Ned Stark alive?")
```

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
03 enhancement Enhancement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants