| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static void | delete(List<ChatMessage> chatHistory, String id)
Removes the message with the specified ID from history. |
| public static Optional | Returns: the last user messag, or empty if no user message is foundthe chat history to search chatHistory)Finds the last user message in the chat history by iterating backwards. |
| public static Optional | Returns: the content to regenerate or empty if the message was not foundRewinds history to the point before the specified message and returns the user content to be re-sent. |
| public static void | updateSystemMessage(List<ChatMessage>
the chat history to update chatHistory, String the new system message content newSystemMessage)Updates the system message in the chat history. |
| ChatHistoryUtils | back to summary |
|---|---|
| private ChatHistoryUtils() | |
| delete | back to summary |
|---|---|
| public static void delete(List<ChatMessage> chatHistory, String id) Removes the message with the specified ID from history. Leaves a "hole" in context, but this is intended. | |
| getLastUserMessage | back to summary |
|---|---|
| public static Optional Finds the last user message in the chat history by iterating backwards.
| |
| regenerate | back to summary |
|---|---|
| public static Optional Rewinds history to the point before the specified message and returns the user content to be re-sent. Modifies the chat history in-place. | |
| updateSystemMessage | back to summary |
|---|---|
| public static void updateSystemMessage(List<ChatMessage> chatHistory, String newSystemMessage) Updates the system message in the chat history. If a system message already exists, it is replaced. Otherwise, a new system message is added at the beginning.
| |