langchain/docs/snippets/modules/memory/chat_messages/get_started.mdx

23 lines
373 B
Plaintext
Raw Normal View History

```python
from langchain.memory import ChatMessageHistory
history = ChatMessageHistory()
history.add_user_message("hi!")
history.add_ai_message("whats up?")
```
```python
history.messages
```
<CodeOutputBlock lang="python">
```
[HumanMessage(content='hi!', additional_kwargs={}),
AIMessage(content='whats up?', additional_kwargs={})]
```
</CodeOutputBlock>