langchain_community.chat_message_histories.streamlit.StreamlitChatMessageHistory¶

class langchain_community.chat_message_histories.streamlit.StreamlitChatMessageHistory(key: str = 'langchain_messages')[source]¶

Chat message history that stores messages in Streamlit session state.

Parameters

key – The key to use in Streamlit session state for storing messages.

Attributes

messages

Retrieve the current list of messages

Methods

__init__([key])

add_ai_message(message)

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

add_message(message)

Add a message to the session memory

add_user_message(message)

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

clear()

Clear session memory

__init__(key: str = 'langchain_messages')[source]¶
add_ai_message(message: Union[AIMessage, str]) None¶

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

Parameters

message – The AI message to add.

add_message(message: BaseMessage) None[source]¶

Add a message to the session memory

add_user_message(message: Union[HumanMessage, str]) None¶

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

Parameters

message – The human message to add

clear() None[source]¶

Clear session memory

Examples using StreamlitChatMessageHistory¶