Class ChatHistory

    • Constructor Detail

      • ChatHistory

        public ChatHistory()
        The default constructor
      • ChatHistory

        public ChatHistory​(@Nullable
                           String instructions)
        Constructor that adds the given system instructions to the chat history.
        Parameters:
        instructions - The instructions to add to the chat history
      • ChatHistory

        public ChatHistory​(List<? extends ChatMessageContent<?>> chatMessageContents)
        Constructor that adds the given chat message contents to the chat history.
        Parameters:
        chatMessageContents - The chat message contents to add to the chat history
    • Method Detail

      • getMessages

        public List<ChatMessageContent<?>> getMessages()
        Get the chat history
        Returns:
        List of messages in the chat
      • getLastMessage

        public Optional<ChatMessageContent<?>> getLastMessage()
        Get last message
        Returns:
        The most recent message in chat
      • addAll

        public void addAll​(ChatHistory value)
        Add all messages from the given chat history to this chat history
        Parameters:
        value - The chat history to add to this chat history
      • addMessage

        public ChatHistory addMessage​(AuthorRole authorRole,
                                      String content,
                                      Charset encoding,
                                      FunctionResultMetadata<?> metadata)
        Add a message to the chat history
        Parameters:
        authorRole - The role of the author of the message
        content - The content of the message
        encoding - The encoding of the message
        metadata - The metadata of the message
        Returns:
        this ChatHistory
      • addMessage

        public ChatHistory addMessage​(AuthorRole authorRole,
                                      String content)
        Add a message to the chat history
        Parameters:
        authorRole - The role of the author of the message
        content - The content of the message
        Returns:
        this ChatHistory
      • addMessage

        public ChatHistory addMessage​(ChatMessageContent<?> content)
        Add a message to the chat history
        Parameters:
        content - The content of the message
        Returns:
        this ChatHistory
      • addUserMessage

        public ChatHistory addUserMessage​(String content)
        Add a user message to the chat history
        Parameters:
        content - The content of the user message
        Returns:
        this ChatHistory
      • addAssistantMessage

        public ChatHistory addAssistantMessage​(String content)
        Add an assistant message to the chat history
        Parameters:
        content - The content of the assistant message
        Returns:
        this ChatHistory
      • addSystemMessage

        public ChatHistory addSystemMessage​(String content)
        Add an system message to the chat history
        Parameters:
        content - The content of the system message
        Returns:
        this ChatHistory
      • addAll

        public ChatHistory addAll​(List<ChatMessageContent<?>> messages)
        Add all messages to the chat history
        Parameters:
        messages - The messages to add to the chat history
        Returns:
        this ChatHistory