Introduce TextClassifier.suggestConversationActions
Example usage: // App side ConversationAction.TypeConfig typeConfig = new ConversationAction.TypeConfig.Builder().setIncludedTypes( Collections.singletonList(ConversationAction.TYPE_TEXT_REPLY)).build(); ConversationAction.Message message = ConversationAction.Message.Builder().setText("How are you?").build(); ConversationAction.Request request = new ConversationAction.Request.Builder( Collections.singletonList(message), HINT_FOR_IN_APP) .setTypeConfig(typeConfig) .build(); List<ConversationAction> conversationActions = textClassifier.suggestConversationActions(request).getConversationActions(); for (ConversationAction conversationAction : conversationActions) { // 1. Use the RemoteAction directly (if available) RemoteAction actions= conversationAction.getActions(); // 2. Use the parsed action types and entities. String type = conversationAction.getType(); ConversationAction.Entities entities = conversationAction.getEntities(); } // In the TextClassificationService side: ConversationAction.Entities entities = new ConversationAction.Entities.Builder().setReplies(Arrays.asList("I am good.", ":(", ":)")).build(); ConversationAction conversationAction = new ConversationAction.Builder( ConversationAction.TYPE_TEXT_REPLY).setEntities(entities).build(); BUG: 111437455 BUG: 111406942 Test: atest cts/tests/tests/view/src/android/view/textclassifier/cts/*cts/tests/tests/view/src/android/view/textclassifier/cts/TextClassificationManagerTest.java Test: cts/tests/tests/view/src/android/view/textclassifier/cts/ConversationActionsTest.java Change-Id: Ie8639f93f88336ecdfda602ce14cd8ca578c092a
Loading
Please register or sign in to comment