generated from langchain-ai/integration-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
I am trying to use AsyncMongoClient for MongoDBChatMessageHistory.
def get_chat_history(client: AsyncMongoClient, session_id: str) -> MongoDBChatMessageHistory:
return MongoDBChatMessageHistory(
connection_string=None,
session_id=session_id,
client=client,
database_name="db",
collection_name="conversation",
)
prompt = ChatPromptTemplate.from_messages(
[
("system", "You're an assistant"),
MessagesPlaceholder("history"),
("human", "{input}"),
]
)
llm = ChatBedrockConverse(
model_id="model_id", region_name="region_name", provider="provider"
)
chain = prompt | llm
chain_with_history = RunnableWithMessageHistory(
chain,
get_session_history=lambda session_id: get_chat_history(client, session_id),
input_messages_key="input",
history_messages_key="history",
)
Console message
/Users/mongodb-setup/.venv/lib/python3.12/site-packages/langchain_mongodb/chat_message_histories.py:169: RuntimeWarning: coroutine 'AsyncCollection.insert_one' was never awaited
self.collection.insert_one(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I saw that MongoDBChatMessageHistory expects MongoClient and not AsyncMongoClient. Is there a way to use it? Or the support isnt available yet?
Metadata
Metadata
Assignees
Labels
No labels