Extracts messages from given list of events. If the developer provides their own memory within langgraph, we return the last user messages only. Otherwise, we return all messages between the user and the agent. Args: events: the list of events Returns: list of mess
(
self, events: list[Event]
)
| 101 | yield result_event |
| 102 | |
| 103 | def _get_messages( |
| 104 | self, events: list[Event] |
| 105 | ) -> list[Union[HumanMessage, AIMessage]]: |
| 106 | """Extracts messages from given list of events. |
| 107 | |
| 108 | If the developer provides their own memory within langgraph, we return the |
| 109 | last user messages only. Otherwise, we return all messages between the user |
| 110 | and the agent. |
| 111 | |
| 112 | Args: |
| 113 | events: the list of events |
| 114 | |
| 115 | Returns: |
| 116 | list of messages |
| 117 | """ |
| 118 | if self.graph.checkpointer: |
| 119 | return _get_last_human_messages(events) |
| 120 | else: |
| 121 | return self._get_conversation_with_agent(events) |
| 122 | |
| 123 | def _get_conversation_with_agent( |
| 124 | self, events: list[Event] |
no test coverage detected