langchain.memory.chat_message_histories.elasticsearch.ElasticsearchChatMessageHistory

class langchain.memory.chat_message_histories.elasticsearch.ElasticsearchChatMessageHistory(index: str, session_id: str, *, es_connection: Optional[Elasticsearch] = None, es_url: Optional[str] = None, es_cloud_id: Optional[str] = None, es_user: Optional[str] = None, es_api_key: Optional[str] = None, es_password: Optional[str] = None)[source]

Chat message history that stores history in Elasticsearch.

Parameters
  • es_url – URL of the Elasticsearch instance to connect to.

  • es_cloud_id – Cloud ID of the Elasticsearch instance to connect to.

  • es_user – Username to use when connecting to Elasticsearch.

  • es_password – Password to use when connecting to Elasticsearch.

  • es_api_key – API key to use when connecting to Elasticsearch.

  • es_connection – Optional pre-existing Elasticsearch connection.

  • index – Name of the index to use.

  • session_id – Arbitrary key that is used to store the messages of a single chat session.

Attributes

messages

Retrieve the messages from Elasticsearch

Methods

__init__(index, session_id, *[, ...])

add_ai_message(message)

Convenience method for adding an AI message string to the store.

add_message(message)

Add a message to the chat session in Elasticsearch

add_user_message(message)

Convenience method for adding a human message string to the store.

clear()

Clear session memory in Elasticsearch

connect_to_elasticsearch(*[, es_url, ...])

get_user_agent()

__init__(index: str, session_id: str, *, es_connection: Optional[Elasticsearch] = None, es_url: Optional[str] = None, es_cloud_id: Optional[str] = None, es_user: Optional[str] = None, es_api_key: Optional[str] = None, es_password: Optional[str] = None)[source]
add_ai_message(message: str) None

Convenience method for adding an AI message string to the store.

Parameters

message – The string contents of an AI message.

add_message(message: BaseMessage) None[source]

Add a message to the chat session in Elasticsearch

add_user_message(message: str) None

Convenience method for adding a human message string to the store.

Parameters

message – The string contents of a human message.

clear() None[source]

Clear session memory in Elasticsearch

static connect_to_elasticsearch(*, es_url: Optional[str] = None, cloud_id: Optional[str] = None, api_key: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None) Elasticsearch[source]
static get_user_agent() str[source]