-
Notifications
You must be signed in to change notification settings - Fork 736
Neo4j Schema Query Builder Integration #520
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is awesome! i'm really excited for this.
sorry for the delay in reviewing, a few comments. would be excited to help get this out
llama_hub/tools/neo4j_db/README.md
Outdated
@@ -0,0 +1,67 @@ | |||
|
|||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove these top-level lines
llama_hub/tools/neo4j_db/base.py
Outdated
This class is responsible for querying a Neo4j graph database based on a provided schema definition. | ||
""" | ||
|
||
def __init__(self, url, user, password, llm): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the native llamaindex llm abstractions? they include our native integrations (openai, anthropic, etc.) and also integrate with langchain llms:
https://gpt-index.readthedocs.io/en/latest/core_modules/model_modules/llms/root.html
llama_hub/tools/neo4j_db/README.md
Outdated
from llama_hub.tools.neo4j_db.base import Neo4jQueryToolSpec | ||
from langchain.chat_models import ChatOpenAI | ||
|
||
llm = ChatOpenAI( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned below, would be good to have a native llamaindex demo e.g.
from llama_index.llms import OpenAI
llm = OpenAI(model="gpt-4", ...)
query_builder = Neo4jQueryToolSpec('url', 'user', 'password', llm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually a lot of this logic seems duplicated from our Neo4jGraphStore abstraction in the core LlamaIndex repo. Is there a way we can reuse code from there? E.g. define the tool spec, but just call Neo4jGraphStore under the hood instead of re-implementing the functions here
Hey @jerryjliu |
Use Neo4jGraphStore class instead of new graph database
@jerryjliu I have changed the pull, |
Use Neo4jGraphStore class instead of new graph database
# Conflicts: # llama_hub/tools/neo4j_db/base.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @shahafp, sorry for the delay, some final comments. maybe a general question here is do you have a notebook to show use cases?
the original intent of the tool spec was so that it could be used by agents, but curious how you've been using this so far!
add spec_functions fix string formatting
Yeah, maybe I kind missed the whole point of the tool at first and thought perhaps it could be used also for RAG in the main repo of llama_index because it might help get information from the graph in a more accurate way. I used this tool with the chat engine to get the information about the data from the graph and some reasoning. |
no worries! it's good feedback for how we position these tools - maybe we should make it clear it can be used for both human and agent use :)
I'd actually be really interested if you're able to get an agent up and running with this |
Sure,
Response:
Please let me know if this example is ok if so I will add it to the README file |
yeah this works! |
OMG the code seems so easy to use : do you think this feature could be released soon ? I'd like to use it at #nodes23 : Btw, I already started to talk about llama_index on one of the datasets, but querying with llama_index could help compare with oter approaches. What I like the most with llama_index is how simple code is 🤩 ... making it very helpful during demos. |
Thank you both for your feedback! |
@shahafp merged! https://llamahub.ai/l/tools-neo4j_db what's your twitter handle? :) promoting soon |
When will it be GA ? |
That’s awesome!!! Thank you very much! |
Summary:
This pull request introduces the
Neo4jQueryToolSpec
class which provides an innovative way to query a Neo4j graph database based on a provided schema definition. It incorporates a language model to dynamically generate Cypher queries from user questions and is equipped with a self-healing mechanism for Cypher syntax errors.Changes:
Neo4jQueryToolSpec
class to enable schema-based querying.Testing:
Ensure the Neo4j database is set up and running. Initialize the
Neo4jQueryToolSpec
with appropriate database credentials and a valid language model, then run various queries to test its functionality and error-handling capabilities.Impact:
This tool will significantly enhance the user's experience by facilitating intuitive and schema-aware querying of the Neo4j database, while also providing robust error handling.