Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

feat: Add Agent Assist Summarization API (https://cloud.google.com/agent-assist/docs/summarization) #1026

Merged
merged 4 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,148 @@ public final UnaryCallable<ListMessagesRequest, ListMessagesResponse> listMessag
return stub.listMessagesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Suggest summary for a conversation based on specific historical messages. The range of the
* messages to be used for summary can be specified in the request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ConversationsClient conversationsClient = ConversationsClient.create()) {
* ConversationName conversation =
* ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
* SuggestConversationSummaryResponse response =
* conversationsClient.suggestConversationSummary(conversation);
* }
* }</pre>
*
* @param conversation Required. The conversation to fetch suggestion for. Format:
* `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
* ID&gt;`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SuggestConversationSummaryResponse suggestConversationSummary(
ConversationName conversation) {
SuggestConversationSummaryRequest request =
SuggestConversationSummaryRequest.newBuilder()
.setConversation(conversation == null ? null : conversation.toString())
.build();
return suggestConversationSummary(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Suggest summary for a conversation based on specific historical messages. The range of the
* messages to be used for summary can be specified in the request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ConversationsClient conversationsClient = ConversationsClient.create()) {
* String conversation =
* ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
* SuggestConversationSummaryResponse response =
* conversationsClient.suggestConversationSummary(conversation);
* }
* }</pre>
*
* @param conversation Required. The conversation to fetch suggestion for. Format:
* `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/conversations/&lt;Conversation
* ID&gt;`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SuggestConversationSummaryResponse suggestConversationSummary(String conversation) {
SuggestConversationSummaryRequest request =
SuggestConversationSummaryRequest.newBuilder().setConversation(conversation).build();
return suggestConversationSummary(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Suggest summary for a conversation based on specific historical messages. The range of the
* messages to be used for summary can be specified in the request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ConversationsClient conversationsClient = ConversationsClient.create()) {
* SuggestConversationSummaryRequest request =
* SuggestConversationSummaryRequest.newBuilder()
* .setConversation(
* ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
* .toString())
* .setLatestMessage(
* MessageName.ofProjectConversationMessageName(
* "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
* .toString())
* .setContextSize(1116903569)
* .build();
* SuggestConversationSummaryResponse response =
* conversationsClient.suggestConversationSummary(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SuggestConversationSummaryResponse suggestConversationSummary(
SuggestConversationSummaryRequest request) {
return suggestConversationSummaryCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Suggest summary for a conversation based on specific historical messages. The range of the
* messages to be used for summary can be specified in the request.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (ConversationsClient conversationsClient = ConversationsClient.create()) {
* SuggestConversationSummaryRequest request =
* SuggestConversationSummaryRequest.newBuilder()
* .setConversation(
* ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
* .toString())
* .setLatestMessage(
* MessageName.ofProjectConversationMessageName(
* "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
* .toString())
* .setContextSize(1116903569)
* .build();
* ApiFuture<SuggestConversationSummaryResponse> future =
* conversationsClient.suggestConversationSummaryCallable().futureCall(request);
* // Do something.
* SuggestConversationSummaryResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummaryCallable() {
return stub.suggestConversationSummaryCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public UnaryCallSettings<GetConversationRequest, Conversation> getConversationSe
return ((ConversationsStubSettings) getStubSettings()).listMessagesSettings();
}

/** Returns the object with the settings used for calls to suggestConversationSummary. */
public UnaryCallSettings<SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings() {
return ((ConversationsStubSettings) getStubSettings()).suggestConversationSummarySettings();
}

/** Returns the object with the settings used for calls to listLocations. */
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings() {
Expand Down Expand Up @@ -277,6 +283,13 @@ public Builder applyToAllUnaryMethods(
return getStubSettingsBuilder().listMessagesSettings();
}

/** Returns the builder for the settings used for calls to suggestConversationSummary. */
public UnaryCallSettings.Builder<
SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings() {
return getStubSettingsBuilder().suggestConversationSummarySettings();
}

/** Returns the builder for the settings used for calls to listLocations. */
public PagedCallSettings.Builder<
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
},
"ListMessages": {
"methods": ["listMessages", "listMessages", "listMessages", "listMessagesPagedCallable", "listMessagesCallable"]
},
"SuggestConversationSummary": {
"methods": ["suggestConversationSummary", "suggestConversationSummary", "suggestConversationSummary", "suggestConversationSummaryCallable"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import com.google.cloud.dialogflow.v2beta1.ListConversationsResponse;
import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest;
import com.google.cloud.dialogflow.v2beta1.ListMessagesResponse;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryRequest;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryResponse;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
Expand Down Expand Up @@ -84,6 +86,12 @@ public UnaryCallable<ListMessagesRequest, ListMessagesResponse> listMessagesCall
throw new UnsupportedOperationException("Not implemented: listMessagesCallable()");
}

public UnaryCallable<SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummaryCallable() {
throw new UnsupportedOperationException(
"Not implemented: suggestConversationSummaryCallable()");
}

public UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable() {
throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest;
import com.google.cloud.dialogflow.v2beta1.ListMessagesResponse;
import com.google.cloud.dialogflow.v2beta1.Message;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryRequest;
import com.google.cloud.dialogflow.v2beta1.SuggestConversationSummaryResponse;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
Expand Down Expand Up @@ -126,6 +128,9 @@ public class ConversationsStubSettings extends StubSettings<ConversationsStubSet
private final PagedCallSettings<
ListMessagesRequest, ListMessagesResponse, ListMessagesPagedResponse>
listMessagesSettings;
private final UnaryCallSettings<
SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings;
private final PagedCallSettings<
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings;
Expand Down Expand Up @@ -333,6 +338,12 @@ public UnaryCallSettings<GetConversationRequest, Conversation> getConversationSe
return listMessagesSettings;
}

/** Returns the object with the settings used for calls to suggestConversationSummary. */
public UnaryCallSettings<SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings() {
return suggestConversationSummarySettings;
}

/** Returns the object with the settings used for calls to listLocations. */
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings() {
Expand Down Expand Up @@ -456,6 +467,8 @@ protected ConversationsStubSettings(Builder settingsBuilder) throws IOException
completeConversationSettings = settingsBuilder.completeConversationSettings().build();
batchCreateMessagesSettings = settingsBuilder.batchCreateMessagesSettings().build();
listMessagesSettings = settingsBuilder.listMessagesSettings().build();
suggestConversationSummarySettings =
settingsBuilder.suggestConversationSummarySettings().build();
listLocationsSettings = settingsBuilder.listLocationsSettings().build();
getLocationSettings = settingsBuilder.getLocationSettings().build();
}
Expand All @@ -477,6 +490,9 @@ public static class Builder extends StubSettings.Builder<ConversationsStubSettin
private final PagedCallSettings.Builder<
ListMessagesRequest, ListMessagesResponse, ListMessagesPagedResponse>
listMessagesSettings;
private final UnaryCallSettings.Builder<
SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings;
private final PagedCallSettings.Builder<
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings;
Expand Down Expand Up @@ -525,6 +541,7 @@ protected Builder(ClientContext clientContext) {
completeConversationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
batchCreateMessagesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
listMessagesSettings = PagedCallSettings.newBuilder(LIST_MESSAGES_PAGE_STR_FACT);
suggestConversationSummarySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT);
getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();

Expand All @@ -536,6 +553,7 @@ protected Builder(ClientContext clientContext) {
completeConversationSettings,
batchCreateMessagesSettings,
listMessagesSettings,
suggestConversationSummarySettings,
listLocationsSettings,
getLocationSettings);
initDefaults(this);
Expand All @@ -550,6 +568,7 @@ protected Builder(ConversationsStubSettings settings) {
completeConversationSettings = settings.completeConversationSettings.toBuilder();
batchCreateMessagesSettings = settings.batchCreateMessagesSettings.toBuilder();
listMessagesSettings = settings.listMessagesSettings.toBuilder();
suggestConversationSummarySettings = settings.suggestConversationSummarySettings.toBuilder();
listLocationsSettings = settings.listLocationsSettings.toBuilder();
getLocationSettings = settings.getLocationSettings.toBuilder();

Expand All @@ -561,6 +580,7 @@ protected Builder(ConversationsStubSettings settings) {
completeConversationSettings,
batchCreateMessagesSettings,
listMessagesSettings,
suggestConversationSummarySettings,
listLocationsSettings,
getLocationSettings);
}
Expand Down Expand Up @@ -622,6 +642,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));

builder
.suggestConversationSummarySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));

builder
.listLocationsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
Expand Down Expand Up @@ -688,6 +713,13 @@ public Builder applyToAllUnaryMethods(
return listMessagesSettings;
}

/** Returns the builder for the settings used for calls to suggestConversationSummary. */
public UnaryCallSettings.Builder<
SuggestConversationSummaryRequest, SuggestConversationSummaryResponse>
suggestConversationSummarySettings() {
return suggestConversationSummarySettings;
}

/** Returns the builder for the settings used for calls to listLocations. */
public PagedCallSettings.Builder<
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
Expand Down
Loading