SmartReplyGenerator
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From interface java.io.Closeable
From interface java.lang.AutoCloseable
Public Methods
public abstract void close ()
Closes the underlying resources including models used for reply inference.
Returns suggested meaningful replies to a text message.
Currently, English is the only supported language.
Parameters
textMessages |
a list of messages from which the API generates smart replies.
The messages list should contain most recent conversation context for all
users participating in the conversation in ascending chronological order (i.e.
from oldest to newest). Internally, SmartReply considers the last 10 messages to
generate reply suggestions.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eSmartReplyGenerator\u003c/code\u003e is a client for generating smart replies to user input messages.\u003c/p\u003e\n"],["\u003cp\u003eIt uses the last 10 messages in a conversation to generate reply suggestions in English.\u003c/p\u003e\n"],["\u003cp\u003eYou can get an instance of it using \u003ccode\u003eSmartReply.getClient()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt provides a \u003ccode\u003esuggestReplies\u003c/code\u003e method that takes a list of messages and returns a \u003ccode\u003eSmartReplySuggestionResult\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eclose()\u003c/code\u003e method should be called to release resources when the generator is no longer needed.\u003c/p\u003e\n"]]],[],null,["# SmartReplyGenerator\n\npublic interface **SmartReplyGenerator** extends [Closeable](https://developer.android.com/reference/java/io/Closeable.html) LifecycleObserver [OptionalModuleApi](https:/android/reference/com/google/android/gms/common/api/OptionalModuleApi.html) \nA [SmartReply](/android/reference/com/google/mlkit/nl/smartreply/SmartReply)\nclient for suggesting meaningful replies to a user input message.\n\nA [SmartReplyGenerator](/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator)\nis created via [SmartReply.getClient()](/android/reference/com/google/mlkit/nl/smartreply/SmartReply#getClient()).\n\nExample: \n\n SmartReplyGenerator smartReplyGenerator = SmartReply.getClient();\n \n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [close](/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator#close())() Closes the underlying resources including models used for reply inference. |\n| abstract Task\\\u003c[SmartReplySuggestionResult](/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult)\\\u003e | [suggestReplies](/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator#suggestReplies(java.util.List\u003ccom.google.mlkit.nl.smartreply.TextMessage\u003e))([List](https://developer.android.com/reference/java/util/List.html)\\\u003c[TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\\\u003e textMessages) Returns suggested meaningful replies to a text message. |\n\n### Inherited Method Summary\n\nFrom interface java.io.Closeable \n\n|---------------|---------|\n| abstract void | close() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Methods\n--------------\n\n#### public abstract void **close** ()\n\nCloses the underlying resources including models used for reply inference. \n\n#### public abstract Task\\\u003c[SmartReplySuggestionResult](/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult)\\\u003e\n**suggestReplies** ([List](https://developer.android.com/reference/java/util/List.html)\\\u003c[TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\\\u003e textMessages)\n\nReturns suggested meaningful replies to a text message.\n\nCurrently, English is the only supported language. \n\n##### Parameters\n\n| textMessages | a list of messages from which the API generates smart replies. The messages list should contain most recent conversation context for all users participating in the conversation in ascending chronological order (i.e. from oldest to newest). Internally, SmartReply considers the last 10 messages to generate reply suggestions. |\n|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a [Task](/android/reference/com/google/android/gms/tasks/Task) that asynchronously returns a [SmartReplySuggestionResult](/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult) which contains a list of [SmartReplySuggestion](/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestion)s. All the replies are sorted by an internal confidence value (highest to lowest)."]]