forked from Archives/langchain
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
442 B
Python
20 lines
442 B
Python
from typing import List
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from langchain.schema import (
|
|
BaseChatMessageHistory,
|
|
BaseMessage,
|
|
)
|
|
|
|
|
|
class ChatMessageHistory(BaseChatMessageHistory, BaseModel):
|
|
messages: List[BaseMessage] = []
|
|
|
|
def add_message(self, message: BaseMessage) -> None:
|
|
"""Add a self-created message to the store"""
|
|
self.messages.append(message)
|
|
|
|
def clear(self) -> None:
|
|
self.messages = []
|