Class SmartReply.Session

java.lang.Object
com.codename1.ai.language.SmartReply.Session
All Implemented Interfaces:
AutoCloseable
Enclosing class:
SmartReply

public static final class SmartReply.Session extends Object implements AutoCloseable

Reusable owner of a native Smart Reply backend.

Calling close() prevents new requests immediately and defers native release until suggestions already in progress have completed.

  • Method Details

    • suggest

      public AsyncResource<String[]> suggest(SmartReplyMessage[] conversation)
      Generates reply suggestions without recreating the native backend. Cancelling the returned resource suppresses late callbacks without closing this reusable session.
      Parameters:
      conversation - chronological messages, oldest first; null is treated as an empty conversation
      Returns:
      asynchronous suggestions, possibly empty
      Throws:
      IllegalStateException - if this session is closed
    • close

      public void close()
      Closes the session. This method is idempotent; native release is deferred until pending suggestions finish.
      Specified by:
      close in interface AutoCloseable