Interface OpenAiMessage

All Known Implementing Classes:
OpenAiAssistantMessage, OpenAiSystemMessage, OpenAiToolMessage, OpenAiUserMessage

public sealed interface OpenAiMessage permits OpenAiUserMessage, OpenAiAssistantMessage, OpenAiSystemMessage, OpenAiToolMessage
Interface representing convenience wrappers of chat message to the openai service.
Since:
1.4.0
  • Method Details

    • user

      @Nonnull static OpenAiUserMessage user(@Nonnull String message)
      A convenience method to create a user message.
      Parameters:
      message - the message content.
      Returns:
      the user message.
    • user

      @Nonnull static OpenAiUserMessage user(@Nonnull OpenAiImageItem openAiImageItem)
      A convenience method to create a user message containing only an image.
      Parameters:
      openAiImageItem - the message content.
      Returns:
      the user message.
    • assistant

      @Nonnull static OpenAiAssistantMessage assistant(@Nonnull String message)
      A convenience method to create an assistant message.
      Parameters:
      message - the message content.
      Returns:
      the assistant message.
    • assistant

      @Nonnull static OpenAiAssistantMessage assistant(@Nonnull List<OpenAiToolCall> toolCalls)
      A convenience method to create an assistant message.
      Parameters:
      toolCalls - tool calls to associate with the message.
      Returns:
      the assistant message.
    • system

      @Nonnull static OpenAiSystemMessage system(@Nonnull String message)
      A convenience method to create a system message.
      Parameters:
      message - the message content.
      Returns:
      the system message.
    • tool

      @Nonnull static OpenAiToolMessage tool(@Nonnull String message, @Nonnull String toolCallId)
      A convenience method to create a tool message.
      Parameters:
      message - response of the executed tool call.
      toolCallId - identifier of the tool call that the assistant expected.
      Returns:
      the tool message.
    • role

      @Nonnull String role()
      Returns the role associated with the message.
      Returns:
      the role.
    • content

      @Nonnull OpenAiMessageContent content()
      Returns the content of the message.
      Returns:
      the content.