接口 ChatMemory
public interface ChatMemory
Represents the memory (history) of a chat conversation.
Since language models do not keep the state of the conversation, it is necessary to provide all previous messages
on every interaction with the language model.
ChatMemory helps with keeping track of the conversation and ensuring that messages fit within language model's context window.-
方法概要
修饰符和类型方法说明voidadd(ChatMessage message) Adds a message to the chat memory.voidclear()Clears the chat memory.id()The ID of theChatMemory.messages()Retrieves messages from the chat memory.
-
方法详细资料
-
id
Object id()The ID of theChatMemory.- 返回:
- The ID of the
ChatMemory.
-
add
Adds a message to the chat memory.- 参数:
message- TheChatMessageto add.
-
messages
List<ChatMessage> messages()Retrieves messages from the chat memory. Depending on the implementation, it may not return all previously added messages, but rather a subset, a summary, or a combination thereof.- 返回:
- A list of
ChatMessageobjects that represent the current state of the chat memory.
-
clear
void clear()Clears the chat memory.
-