From 46782ad79b3c43fe76527a9ff9795515392e81d9 Mon Sep 17 00:00:00 2001 From: Shu Date: Mon, 19 Jun 2023 07:39:19 +0700 Subject: [PATCH] Fixed an unhandled error that was raised when DynamoDB did not have any chat history. (#6141) The current version of chat history with DynamoDB doesn't handle the case correctly when a table has no chat history. This change solves this error handling. Fixes https://github.com/hwchase17/langchain/issues/6088 #### Who can review? Tag maintainers/contributors who might be interested: @hwchase17 --- langchain/memory/chat_message_histories/dynamodb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/langchain/memory/chat_message_histories/dynamodb.py b/langchain/memory/chat_message_histories/dynamodb.py index dfde1457..ef969922 100644 --- a/langchain/memory/chat_message_histories/dynamodb.py +++ b/langchain/memory/chat_message_histories/dynamodb.py @@ -44,6 +44,7 @@ class DynamoDBChatMessageHistory(BaseChatMessageHistory): """Retrieve the messages from DynamoDB""" from botocore.exceptions import ClientError + response = None try: response = self.table.get_item(Key={"SessionId": self.session_id}) except ClientError as error: