Open
Description
The constructor of PostgresChatMessageHistory
accepts only sync or async connection, and not an Engine.
First, the connection was open in get_session_history, and pending during the life cycle of RunnableWithMessageHistory
.
So, it's impossible to use it in a "singleton" approach.
With langserv, you must declare the API with
add_routes(
app,
chain,
path="/",
)
You must have a global variable chain
.
chat_chain = RunnableWithMessageHistory(
_context_and_question | retriever_chain,
get_session_history=get_session_history, # <-- here
input_messages_key="question",
history_messages_key="chat_history",
)
The get_session_history
cannot be async. The PostgresChatMessageHistory.async_connection()
can not be used.
PostgresChatMessageHistory
must be used if the singleton form, to be use with langserv. The engine must be set, without connection.
Metadata
Metadata
Assignees
Labels
No labels