Source code for langchain_elasticsearch.chat_history
from typing import List
from langchain_core.messages import BaseMessage
from langchain_elasticsearch._async.chat_history import (
AsyncElasticsearchChatMessageHistory as _AsyncElasticsearchChatMessageHistory,
)
from langchain_elasticsearch._sync.chat_history import (
ElasticsearchChatMessageHistory as _ElasticsearchChatMessageHistory,
)
# add the messages property which is only in the sync version
[docs]
class ElasticsearchChatMessageHistory(_ElasticsearchChatMessageHistory):
@property
def messages(self) -> List[BaseMessage]: # type: ignore[override]
return self.get_messages()
# langchain defines some sync methods as abstract in its base class
# so we have to add dummy methods for them, even though we only use the async versions
[docs]
class AsyncElasticsearchChatMessageHistory(_AsyncElasticsearchChatMessageHistory):
[docs]
def clear(self) -> None:
raise NotImplementedError("This class is asynchronous, use aclear()")