Skip to content
Commit c9d31e27 authored by Tony Mak's avatar Tony Mak
Browse files

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
parent ac197316
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment