Interface Message


@Experimental public interface Message
A specific message in the context of a generative AI request.
Since:
5.2.240708
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for a message object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Typical role for a prompt/response from the generative AI.
    static final String
    Typical role for a system prompt.
    static final String
    Typical role for a user prompt.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull Message.Builder
    Creates a new builder for creating message object.
    static @NotNull Message
    create(@NotNull String role, @NotNull String text)
    Creates a new text message.
    @NotNull List<MessagePart>
    Returns the message content parts.
    default <T extends MessagePart>
    @NotNull Stream<T>
    getContent(@NotNull Class<T> type)
    Returns the message content object.
    @NotNull String
    Returns the configured role of the message author.
    default @NotNull Optional<String>
    Returns textual content of this message, if available.
  • Field Details

  • Method Details

    • builder

      @NotNull static @NotNull Message.Builder builder()
      Creates a new builder for creating message object.
      Returns:
      The new builder instance.
      Since:
      5.2.240708
    • create

      @NotNull static @NotNull Message create(@NotNull @NotNull String role, @NotNull @NotNull String text)
      Creates a new text message.
      Parameters:
      role - The role of the author (e.g. "user").
      text - The message text.
      Returns:
      The new message object.
      Since:
      5.2.240708
    • getRole

      @NotNull @NotNull String getRole()
      Returns the configured role of the message author. Any implementation of a GenerativeAIConnectorPlugin is encouraged to support common roles like "user", "system" and "assistant", if possible. This allows users of the GenerativeAIAgent do be as generic as possible.
      Returns:
      The message role.
      Since:
      5.2.240708
    • getContent

      @NotNull @NotNull List<MessagePart> getContent()
      Returns the message content parts.
      Returns:
      The message content.
      Since:
      5.2.240708
    • getContent

      @NotNull default <T extends MessagePart> @NotNull Stream<T> getContent(@NotNull @NotNull Class<T> type)
      Returns the message content object.
      Returns:
      The message content.
      Since:
      5.2.240708
    • getText

      @NotNull default @NotNull Optional<String> getText()
      Returns textual content of this message, if available.
      Returns:
      The message content as text, or empty.
      Since:
      5.2.240708