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

[Question]: Using RedisChatStore in a workflow #16615

Open
1 task done
hristogg opened this issue Oct 20, 2024 · 3 comments
Open
1 task done

[Question]: Using RedisChatStore in a workflow #16615

hristogg opened this issue Oct 20, 2024 · 3 comments
Labels
question Further information is requested

Comments

@hristogg
Copy link

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

Hi,

I have a workflow in which i initialize a CondensePlusContextChatEngine.from_defualts() passing a ChatMemoryBuffer.from_defaults which gets passed a RedisChatStore

Every run of the workflow I get
Exception ignored in: <function AbstractConnection.__del__ at 0x000001CD05D63EC0> Traceback (most recent call last): File "c:\Users\hgospodinov\venv\v3_gradio\Lib\site-packages\redis\asyncio\connection.py", line 217, in __del__ File "c:\Users\hgospodinov\venv\v3_gradio\Lib\site-packages\redis\asyncio\connection.py", line 224, in _close File "C:\Users\hgospodinov\venv\python3119\Lib\asyncio\streams.py", line 358, in close File "C:\Users\hgospodinov\venv\python3119\Lib\asyncio\proactor_events.py", line 109, in close File "C:\Users\hgospodinov\venv\python3119\Lib\asyncio\base_events.py", line 762, in call_soon File "C:\Users\hgospodinov\venv\python3119\Lib\asyncio\base_events.py", line 520, in _check_closed RuntimeError: Event loop is closed

I am not sure whether I am doing something wrong myself or it is part of how the chatstore is actually called.
If I understand correctly the flow CondensePlusContextChatEngine's achat calls _arun_c3 which calls _memory.get(input=message) going to the ChatMemoryBuffer which calls get_messages of the RedisChatStore, my assumption was that if I am doing achat it should finally reach the aget_messages in the clienet and not the get_messages.

The versions I have:
llama-index-storage-chat-store-redis==0.3.2
llama-index==0.11.18
llama-index-core==0.11.18

I am guessing I am doing something wrong but hope you guys can point me in the right direction, let me know if I should post the full code.

@hristogg hristogg added the question Further information is requested label Oct 20, 2024
Copy link

dosubot bot commented Oct 20, 2024

Hello, @hristogg! I'm here to assist you with any bugs, questions, or contributions you need help with. Let's tackle this issue together!

The error you're encountering, "RuntimeError: Event loop is closed," typically occurs when an asynchronous operation is attempted after the event loop has been closed. This can happen if the asynchronous resources are not properly managed or closed before the event loop ends.

In your workflow, it seems like the CondensePlusContextChatEngine might be using synchronous methods instead of asynchronous ones, which could lead to this issue. Specifically, if get_messages is being called instead of aget_messages, it might indicate that the asynchronous context is not being properly utilized.

Here are a few suggestions to resolve this issue:

  1. Ensure Asynchronous Context: Make sure that all parts of your workflow that involve asynchronous operations are running within an async function and that you are using await where necessary.

  2. Check Method Usage: Verify that the CondensePlusContextChatEngine and ChatMemoryBuffer are configured to use asynchronous methods. If achat is expected to be asynchronous, ensure that it is correctly reaching aget_messages instead of get_messages.

  3. Properly Close Connections: Ensure that any connections or resources opened during the workflow are properly closed before the event loop is terminated. This might involve explicitly closing the Redis connection or other resources.

  4. Review Initialization: Double-check the initialization of your components to ensure they are set up for asynchronous operation. This includes verifying that the RedisChatStore is initialized with an asynchronous client if needed.

If these steps do not resolve the issue, you might want to review the specific implementation details of the CondensePlusContextChatEngine and ChatMemoryBuffer to ensure they are compatible with asynchronous workflows.

To continue talking to Dosu, mention @dosu.

@logan-markewich
Copy link
Collaborator

This seems fine actually?

If I had to guess, your workflow is running fine, and you are able to get a result. This is getting printed when the program shuts down (probably due to the class not closing the connection properly?)

@hristogg
Copy link
Author

Oh thanks, not to worry about it then, saw the documentation on redis for closing the connection but thought it might have other impacts and then ran down the rabbit hole of seeing what is happenning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants