Class SmartReply
java.lang.Object
com.codename1.ai.language.SmartReply
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classReusable owner of a native Smart Reply backend. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanisSupported(LanguageOptions options) Tests whether Smart Reply is available for a backend selection.static SmartReply.Sessionopen(LanguageOptions options) Opens a reusable Smart Reply session.static AsyncResource<String[]> suggest(SmartReplyMessage[] conversation, LanguageOptions options) The conversation array and option values are copied before backend work begins.
-
Method Details
-
isSupported
public static boolean isSupported()- Returns:
- whether automatic Smart Reply is available
-
isSupported
Tests whether Smart Reply is available for a backend selection.
This capability check creates and closes a temporary native backend. Retain a
SmartReply.Sessionfromopen(LanguageOptions)when the application will immediately request repeated suggestions.- Parameters:
options- backend selection, ornullfor defaults- Returns:
- whether the selected backend supports Smart Reply
-
open
Opens a reusable Smart Reply session. Reuse it for conversations that need repeated suggestions to avoid recreating the native client.- Parameters:
options- backend options, ornull- 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.SmartReplyMessagevalues 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 firstoptions- backend options, ornull- Returns:
- asynchronous suggestions, possibly an empty array
-