Class SmartReply

java.lang.Object
com.codename1.ai.language.SmartReply

public final class SmartReply extends Object
Produces short reply suggestions for a chronological conversation without uploading its messages. ML Kit may return no suggestions when the language or conversation context is unsupported.
  • Method Details

    • isSupported

      public static boolean isSupported()
      Returns:
      whether automatic Smart Reply is available
    • isSupported

      public static boolean isSupported(LanguageOptions options)

      Tests whether Smart Reply is available for a backend selection.

      This capability check creates and closes a temporary native backend. Retain a SmartReply.Session from open(LanguageOptions) when the application will immediately request repeated suggestions.

      Parameters:
      options - backend selection, or null for defaults
      Returns:
      whether the selected backend supports Smart Reply
    • open

      public static SmartReply.Session open(LanguageOptions options)
      Opens a reusable Smart Reply session. Reuse it for conversations that need repeated suggestions to avoid recreating the native client.
      Parameters:
      options - backend options, or null
      Returns:
      a reusable session that owns one native language backend
      Throws:
      UnsupportedOperationException - if the selected backend is absent
    • suggest

      public static AsyncResource<String[]> suggest(SmartReplyMessage[] conversation, LanguageOptions options)
      The conversation array and option values are copied before backend work begins. SmartReplyMessage values are immutable. Cancelling the returned resource suppresses late result callbacks; the temporary backend is released after its pending native work settles.
      Parameters:
      conversation - chronological messages, oldest first
      options - backend options, or null
      Returns:
      asynchronous suggestions, possibly an empty array