mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
Fix ChatMessageHistory (#9594)
The initialization of the array of ChatMessageHistory is buggy. The list is shared with all instances.
This commit is contained in:
parent
fba29f203a
commit
d4c49b16e4
@ -1,6 +1,6 @@
|
||||
from typing import List
|
||||
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.pydantic_v1 import BaseModel, Field
|
||||
from langchain.schema import (
|
||||
BaseChatMessageHistory,
|
||||
)
|
||||
@ -13,7 +13,7 @@ class ChatMessageHistory(BaseChatMessageHistory, BaseModel):
|
||||
Stores messages in an in memory list.
|
||||
"""
|
||||
|
||||
messages: List[BaseMessage] = []
|
||||
messages: List[BaseMessage] = Field(default_factory=list)
|
||||
|
||||
def add_message(self, message: BaseMessage) -> None:
|
||||
"""Add a self-created message to the store"""
|
||||
|
Loading…
Reference in New Issue
Block a user