mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
ChatMessageHistory does throw error after upgrading, neither sync nor async connection works #18
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gingters on GitHub (May 22, 2024).
I moved from langchain_community to langchain_postgres.
With the previous community implementation everything worked, but we need to update as we have other dependencies that need newer versions.
When I use the (sync) Connection, I get this error:
That prompted me to use the AsyncConnection instead, but when using the AsyncConnection, I run into this error when the message history is to be fetched:
I currently use:
@christianramsey commented on GitHub (May 22, 2024):
I have a similar error.
I am using RunnableWithMessageHistory
and if I run it with sync it says I need to make it async.
then I change it to an async connection and get the same AttributeError.
I even try to async await the connection -
async def get_connection():
return await psycopg.AsyncConnection(POSTGRES_AI)
def create_message_history(session_id: str) -> PostgresChatMessageHistory:
return PostgresChatMessageHistory(
table_name, session_id, async_connection=get_connection()
)
File "/Users/fanli/Library/Caches/pypoetry/virtualenvs/ai-6oX_ziT5-py3.12/lib/python3.12/site-packages/langchain_postgres/chat_message_histories.py", line 336, in aget_messages
| async with self._aconnection.cursor() as cursor:
| ^^^^^^^^^^^^^^^^^^^^^^^^
| AttributeError: 'coroutine' object has no attribute 'cursor'
+------------------------------------
@35sui-com commented on GitHub (May 26, 2024):
same error, looking forward to fix
@christianramsey commented on GitHub (Jun 3, 2024):
Double clicking this again
@eyurtsev commented on GitHub (Jun 10, 2024):
The community should feel free to open a PR to fix