From 41047fe4c3ba627bb5398706c64f4d7bdee006ff Mon Sep 17 00:00:00 2001 From: Nante Nantero Date: Tue, 12 Sep 2023 01:16:20 +0200 Subject: [PATCH] fix(DynamoDBChatMessageHistory): correct delete_item method call (#10383) **Description**: Fixed a bug introduced in version 0.0.281 in `DynamoDBChatMessageHistory` where `self.table.delete_item(self.key)` produced a TypeError: `TypeError: delete_item() only accepts keyword arguments`. Updated the method call to `self.table.delete_item(Key=self.key)` to resolve this issue. Please see also [the official AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/table/delete_item.html#) on this **delete_item** method - only `**kwargs` are accepted. See also the PR, which introduced this bug: https://github.com/langchain-ai/langchain/pull/9896#discussion_r1317899073 Please merge this, I rely on this delete dynamodb item functionality (because of GDPR considerations). **Dependencies**: None **Tag maintainer**: @hwchase17 @joshualwhite **Twitter handle**: [@BenjaminLinnik](https://twitter.com/BenjaminLinnik) Co-authored-by: Benjamin Linnik --- .../langchain/memory/chat_message_histories/dynamodb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/memory/chat_message_histories/dynamodb.py b/libs/langchain/langchain/memory/chat_message_histories/dynamodb.py index 06d7897dbd..34ba5694d7 100644 --- a/libs/langchain/langchain/memory/chat_message_histories/dynamodb.py +++ b/libs/langchain/langchain/memory/chat_message_histories/dynamodb.py @@ -121,6 +121,6 @@ class DynamoDBChatMessageHistory(BaseChatMessageHistory): ) from e try: - self.table.delete_item(self.key) + self.table.delete_item(Key=self.key) except ClientError as err: logger.error(err)