Replies: 1 comment
-
Hey @zoitsa93! I'm here to help you with any bugs, questions, or contributions while waiting for a human maintainer. Let's tackle this together! You can store a query that has been produced with a syntax error when using Here's an example of how you can modify your code to achieve this: from langchain.chains import GraphCypherQAChain
from langchain.graphs import Neo4jGraph
llm = AzureChatOpenAI(
deployment_name="gpt-4",
openai_api_version="2024-02-15-preview",
model_version="1106-Preview",
max_tokens=4096,
temperature=0,
openai_api_key=openai_api_key,
azure_endpoint=azure_endpoint
)
graph = Neo4jGraph(url=url, username=username, password=password, sanitize=False)
chain = GraphCypherQAChain.from_llm(
llm, graph=graph, verbose=True, return_intermediate_steps=True, return_aql_query=True
)
try:
answer = chain.invoke({"query": "Question_to_database"})
except ValueError as e:
print(f"Error: {e}")
# Access the erroneous query from the result
erroneous_query = e.args[1].get("aql_query", "No query available")
print(f"Erroneous Query: {erroneous_query}") In this example, if a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked other resources
Commit to Help
Example Code
Description
I am using the GraphCypherQAChain in python 3.12.4 in order to produce automatically cypher queries using LLM.
While using the return_intermediate_steps=True, when a cypher query is correctly produced from LLM I can store it in a variable.
On the other hand, when then cypher query is produced with a syntax error the chain brakes and so does the code, providing me with a value error that refers to cypher syntax error.
As a result, I am unable to store the wrong query in a variable, as the return_intermediate_steps has never run.
Is there any other way to store a query that has been produced with a syntax error?
System Info
langchain==0.2.16
langchain-community==0.2.16
langchain-core==0.2.38
langchain-openai==0.1.16
langchain-text-splitters==0.2.2
Beta Was this translation helpful? Give feedback.
All reactions