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 void 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
      • addMessage

        public void 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
      • addMessage

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

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

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

        public void addSystemMessage​(String content)
        Add an system message to the chat history
        Parameters:
        content - The content of the system message