Replies: 24 comments 27 replies
-
Hey @arindam77! I'm here to help you with your technical questions and bug resolution. If you need assistance, feel free to ask. To capture the values of Cypher and context from Here is an example of how you can modify the def _call(
self,
inputs: Dict[str, Any],
run_manager: Optional[CallbackManagerForChainRun] = None,
) -> Dict[str, Any]:
"""Generate Cypher statement, use it to look up in db and answer question."""
_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
callbacks = _run_manager.get_child()
question = inputs[self.input_key]
intermediate_steps: List = []
generated_cypher = self.cypher_generation_chain.run(
{"question": question, "schema": self.graph.get_schema}, callbacks=callbacks
)
# Extract Cypher code if it is wrapped in triple backticks
generated_cypher = remove_prefix(extract_cypher(generated_cypher), "cypher")
_run_manager.on_text("Generated Cypher:", end="\n", verbose=self.verbose)
_run_manager.on_text(
generated_cypher, color="green", end="\n", verbose=self.verbose
)
intermediate_steps.append({"query": generated_cypher})
# Retrieve and limit the number of results
context = self.graph.query(generated_cypher)
if self.return_direct:
final_result = context
else:
_run_manager.on_text("Full Context:", end="\n", verbose=self.verbose)
_run_manager.on_text(
str(context), color="green", end="\n", verbose=self.verbose
)
intermediate_steps.append({"context": context})
result = self.qa_chain(
{"question": question, "context": context},
callbacks=callbacks,
)
final_result = result[self.qa_chain.output_key]
chain_result: Dict[str, Any] = {self.output_key: final_result}
if self.return_intermediate_steps:
chain_result[INTERMEDIATE_STEPS_KEY] = intermediate_steps
return chain_result By setting |
Beta Was this translation helpful? Give feedback.
-
@dosu this is giving
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@dosu getting this -- Error invoking chain: "CustomGraphCypherQAChain" object has no field "captured_cypher" |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@dosu No its entering the chain twice at the beginning and generating 2 outputs always for valid( cypher, context, answer) |
Beta Was this translation helpful? Give feedback.
-
@dosu Trying to convert this into a flask endpoint for deployment but this has issues with speed, takes lot of time, getting "CUDA out of memory. Tried to allocate 1002.00 MiB. GPU" , "error": "Object of type DateTime is not JSON serializable". Suggest fixes here to make it scalable and get good results. this is the updated code.
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@dosu Trying to run this in parallel is throwing errors and not executing correctly. the error is RuntimeError: probability tensor contains either inf, nan or element < 0. suggest changes
|
Beta Was this translation helpful? Give feedback.
-
@dosu Please suggest changes to this code to make it more efficient and run fast using less GPU. Currently there are lot of instances where it doesn't work in low gpu instances. Suggest a way I can make the model not use the GPU for loading and only use GPU for processing. Make this as memory efficient as possible with all suggestions on architecture as well. Code for reference. Suggest changes and possible updates
|
Beta Was this translation helpful? Give feedback.
-
@dosu Getting |
Beta Was this translation helpful? Give feedback.
-
@dosu Unable to clear neo4j cache from the code using from langchain_community.graphs import Neo4jGraph. |
Beta Was this translation helpful? Give feedback.
-
@dosu getting AttributeError: 'Neo4jGraph' object has no attribute 'clear' |
Beta Was this translation helpful? Give feedback.
-
@dosu It should not touch the base graph, which I am calling but only remove cache of my sessions. The base graph should be untouched, only my sessions shouldn't have any cache |
Beta Was this translation helpful? Give feedback.
-
Let me know in which places in the existing code this needs to be used.
|
Beta Was this translation helpful? Give feedback.
-
This is my existing code
Tell me here I have not used any Neo4jChatMessageHistory, so if I create one and add it as you recommended will it help in clearing session details without touching base graph? And suggest where to invoke the clear method |
Beta Was this translation helpful? Give feedback.
-
@dosu the biggest issue is there are duplicates generated in the final answer which I dont want. Let me know what can be the cause based on my existing code and suggest remidiation without making changes to base graph |
Beta Was this translation helpful? Give feedback.
-
@dosu I am trying to add more examples as few shot learning template for my model, but now nothing is working. Can you please validate if the format or the template is proper with escape characters. Also I am getting an error sometime of 'This is a friendly reminder - the current text generation call will exceed the model's predefined maximum length (8192). Depending on the model, you may observe exceptions, performance degradation, or nothing at all.' My current template with new examples is as follows: Please correct if any errors in escape characters etc or let me know if it's the issue with model's maximum length.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am using opensource LLama3 with GraphCypherQAChain to get the cypher and context and use it to generate an answer. The chain doesnot enable you to capture the values while it is running.
I am thinking here to store the logs in a file and then parse it to get cypher and context. Fyi, I am running this on Sagemaker Jupyter notebook instance. Need suggestions
System Info
Sagemaker, Jupyter notebook
Beta Was this translation helpful? Give feedback.
All reactions