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

Commit 2346322

Browse files
feat: add the API of StreamingAnalyzeContent (#925)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 446850583 Source-Link: googleapis/googleapis@b9927eb Source-Link: https://github.com/googleapis/googleapis-gen/commit/d44285499a0e757e68d39dc18f91d2800694ad90 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDQ0Mjg1NDk5YTBlNzU3ZTY4ZDM5ZGMxOGY5MWQyODAwNjk0YWQ5MCJ9 docs: add the fields for setting CX virtual agent session parameters PiperOrigin-RevId: 446825520 Source-Link: googleapis/googleapis@f6bb255 Source-Link: https://github.com/googleapis/googleapis-gen/commit/cd1450b403b5a3f92676d8a34f0cfc07fc767b40 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2QxNDUwYjQwM2I1YTNmOTI2NzZkOGEzNGYwY2ZjMDdmYzc2N2I0MCJ9
1 parent 1407153 commit 2346322

37 files changed

+13165
-473
lines changed

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ public final AnalyzeContentResponse analyzeContent(String participant, TextInput
801801
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
802802
* .setQueryParams(QueryParameters.newBuilder().build())
803803
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
804+
* .setCxParameters(Struct.newBuilder().build())
804805
* .setRequestId("requestId693933066")
805806
* .build();
806807
* AnalyzeContentResponse response = participantsClient.analyzeContent(request);
@@ -837,6 +838,7 @@ public final AnalyzeContentResponse analyzeContent(AnalyzeContentRequest request
837838
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
838839
* .setQueryParams(QueryParameters.newBuilder().build())
839840
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
841+
* .setCxParameters(Struct.newBuilder().build())
840842
* .setRequestId("requestId693933066")
841843
* .build();
842844
* ApiFuture<AnalyzeContentResponse> future =

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public FulfillmentsStub getStub() {
161161
* }
162162
* }</pre>
163163
*
164-
* @param name Required. The name of the fulfillment. Supported formats: - `projects/&lt;Project
165-
* ID&gt;/agent/fulfillment` - `projects/&lt;Project ID&gt;/locations/&lt;Location
166-
* ID&gt;/agent/fulfillment`
164+
* @param name Required. The name of the fulfillment. Supported formats:
165+
* <p>- `projects/&lt;Project ID&gt;/agent/fulfillment` - `projects/&lt;Project
166+
* ID&gt;/locations/&lt;Location ID&gt;/agent/fulfillment`
167167
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
168168
*/
169169
public final Fulfillment getFulfillment(FulfillmentName name) {
@@ -187,9 +187,9 @@ public final Fulfillment getFulfillment(FulfillmentName name) {
187187
* }
188188
* }</pre>
189189
*
190-
* @param name Required. The name of the fulfillment. Supported formats: - `projects/&lt;Project
191-
* ID&gt;/agent/fulfillment` - `projects/&lt;Project ID&gt;/locations/&lt;Location
192-
* ID&gt;/agent/fulfillment`
190+
* @param name Required. The name of the fulfillment. Supported formats:
191+
* <p>- `projects/&lt;Project ID&gt;/agent/fulfillment` - `projects/&lt;Project
192+
* ID&gt;/locations/&lt;Location ID&gt;/agent/fulfillment`
193193
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
194194
*/
195195
public final Fulfillment getFulfillment(String name) {

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClient.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2424
import com.google.api.gax.paging.AbstractPage;
2525
import com.google.api.gax.paging.AbstractPagedListResponse;
26+
import com.google.api.gax.rpc.BidiStreamingCallable;
2627
import com.google.api.gax.rpc.PageContext;
2728
import com.google.api.gax.rpc.UnaryCallable;
2829
import com.google.cloud.dialogflow.v2beta1.stub.ParticipantsStub;
@@ -803,6 +804,7 @@ public final AnalyzeContentResponse analyzeContent(String participant, TextInput
803804
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
804805
* .setQueryParams(QueryParameters.newBuilder().build())
805806
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
807+
* .setCxParameters(Struct.newBuilder().build())
806808
* .setMessageSendTime(Timestamp.newBuilder().build())
807809
* .setRequestId("requestId693933066")
808810
* .build();
@@ -840,6 +842,7 @@ public final AnalyzeContentResponse analyzeContent(AnalyzeContentRequest request
840842
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
841843
* .setQueryParams(QueryParameters.newBuilder().build())
842844
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
845+
* .setCxParameters(Struct.newBuilder().build())
843846
* .setMessageSendTime(Timestamp.newBuilder().build())
844847
* .setRequestId("requestId693933066")
845848
* .build();
@@ -855,6 +858,53 @@ public final AnalyzeContentResponse analyzeContent(AnalyzeContentRequest request
855858
return stub.analyzeContentCallable();
856859
}
857860

861+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
862+
/**
863+
* Adds a text (e.g., chat) or audio (e.g., phone recording) message from a participant into the
864+
* conversation. Note: This method is only available through the gRPC API (not REST).
865+
*
866+
* <p>The top-level message sent to the client by the server is `StreamingAnalyzeContentResponse`.
867+
* Multiple response messages can be returned in order. The first one or more messages contain the
868+
* `recognition_result` field. Each result represents a more complete transcript of what the user
869+
* said. The next message contains the `reply_text` field, and potentially the `reply_audio`
870+
* and/or the `automated_agent_reply` fields.
871+
*
872+
* <p>Note: Always use agent versions for production traffic sent to virtual agents. See [Versions
873+
* and environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
874+
*
875+
* <p>Sample code:
876+
*
877+
* <pre>{@code
878+
* // This snippet has been automatically generated for illustrative purposes only.
879+
* // It may require modifications to work in your environment.
880+
* try (ParticipantsClient participantsClient = ParticipantsClient.create()) {
881+
* BidiStream<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse> bidiStream =
882+
* participantsClient.streamingAnalyzeContentCallable().call();
883+
* StreamingAnalyzeContentRequest request =
884+
* StreamingAnalyzeContentRequest.newBuilder()
885+
* .setParticipant(
886+
* ParticipantName.ofProjectConversationParticipantName(
887+
* "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]")
888+
* .toString())
889+
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
890+
* .setQueryParams(QueryParameters.newBuilder().build())
891+
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
892+
* .setCxParameters(Struct.newBuilder().build())
893+
* .setEnablePartialAutomatedAgentReply(true)
894+
* .build();
895+
* bidiStream.send(request);
896+
* for (StreamingAnalyzeContentResponse response : bidiStream) {
897+
* // Do something when a response is received.
898+
* }
899+
* }
900+
* }</pre>
901+
*/
902+
public final BidiStreamingCallable<
903+
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
904+
streamingAnalyzeContentCallable() {
905+
return stub.streamingAnalyzeContentCallable();
906+
}
907+
858908
// AUTO-GENERATED DOCUMENTATION AND METHOD.
859909
/**
860910
* Gets suggested articles for a participant based on specific historical messages.

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsSettings.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.api.gax.rpc.ClientContext;
2929
import com.google.api.gax.rpc.ClientSettings;
3030
import com.google.api.gax.rpc.PagedCallSettings;
31+
import com.google.api.gax.rpc.StreamingCallSettings;
3132
import com.google.api.gax.rpc.TransportChannelProvider;
3233
import com.google.api.gax.rpc.UnaryCallSettings;
3334
import com.google.cloud.dialogflow.v2beta1.stub.ParticipantsStubSettings;
@@ -99,6 +100,12 @@ public UnaryCallSettings<AnalyzeContentRequest, AnalyzeContentResponse> analyzeC
99100
return ((ParticipantsStubSettings) getStubSettings()).analyzeContentSettings();
100101
}
101102

103+
/** Returns the object with the settings used for calls to streamingAnalyzeContent. */
104+
public StreamingCallSettings<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
105+
streamingAnalyzeContentSettings() {
106+
return ((ParticipantsStubSettings) getStubSettings()).streamingAnalyzeContentSettings();
107+
}
108+
102109
/** Returns the object with the settings used for calls to suggestArticles. */
103110
public UnaryCallSettings<SuggestArticlesRequest, SuggestArticlesResponse>
104111
suggestArticlesSettings() {
@@ -267,6 +274,13 @@ public UnaryCallSettings.Builder<GetParticipantRequest, Participant> getParticip
267274
return getStubSettingsBuilder().analyzeContentSettings();
268275
}
269276

277+
/** Returns the builder for the settings used for calls to streamingAnalyzeContent. */
278+
public StreamingCallSettings.Builder<
279+
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
280+
streamingAnalyzeContentSettings() {
281+
return getStubSettingsBuilder().streamingAnalyzeContentSettings();
282+
}
283+
270284
/** Returns the builder for the settings used for calls to suggestArticles. */
271285
public UnaryCallSettings.Builder<SuggestArticlesRequest, SuggestArticlesResponse>
272286
suggestArticlesSettings() {

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/gapic_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@
331331
"ListSuggestions": {
332332
"methods": ["listSuggestions", "listSuggestionsPagedCallable", "listSuggestionsCallable"]
333333
},
334+
"StreamingAnalyzeContent": {
335+
"methods": ["streamingAnalyzeContentCallable"]
336+
},
334337
"SuggestArticles": {
335338
"methods": ["suggestArticles", "suggestArticles", "suggestArticles", "suggestArticlesCallable"]
336339
},

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcParticipantsStub.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.api.gax.core.BackgroundResourceAggregation;
2525
import com.google.api.gax.grpc.GrpcCallSettings;
2626
import com.google.api.gax.grpc.GrpcStubCallableFactory;
27+
import com.google.api.gax.rpc.BidiStreamingCallable;
2728
import com.google.api.gax.rpc.ClientContext;
2829
import com.google.api.gax.rpc.UnaryCallable;
2930
import com.google.cloud.dialogflow.v2beta1.AnalyzeContentRequest;
@@ -37,6 +38,8 @@
3738
import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest;
3839
import com.google.cloud.dialogflow.v2beta1.ListSuggestionsResponse;
3940
import com.google.cloud.dialogflow.v2beta1.Participant;
41+
import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentRequest;
42+
import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentResponse;
4043
import com.google.cloud.dialogflow.v2beta1.SuggestArticlesRequest;
4144
import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse;
4245
import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersRequest;
@@ -113,6 +116,20 @@ public class GrpcParticipantsStub extends ParticipantsStub {
113116
ProtoUtils.marshaller(AnalyzeContentResponse.getDefaultInstance()))
114117
.build();
115118

119+
private static final MethodDescriptor<
120+
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
121+
streamingAnalyzeContentMethodDescriptor =
122+
MethodDescriptor
123+
.<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>newBuilder()
124+
.setType(MethodDescriptor.MethodType.BIDI_STREAMING)
125+
.setFullMethodName(
126+
"google.cloud.dialogflow.v2beta1.Participants/StreamingAnalyzeContent")
127+
.setRequestMarshaller(
128+
ProtoUtils.marshaller(StreamingAnalyzeContentRequest.getDefaultInstance()))
129+
.setResponseMarshaller(
130+
ProtoUtils.marshaller(StreamingAnalyzeContentResponse.getDefaultInstance()))
131+
.build();
132+
116133
private static final MethodDescriptor<SuggestArticlesRequest, SuggestArticlesResponse>
117134
suggestArticlesMethodDescriptor =
118135
MethodDescriptor.<SuggestArticlesRequest, SuggestArticlesResponse>newBuilder()
@@ -176,6 +193,9 @@ public class GrpcParticipantsStub extends ParticipantsStub {
176193
listParticipantsPagedCallable;
177194
private final UnaryCallable<UpdateParticipantRequest, Participant> updateParticipantCallable;
178195
private final UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeContentCallable;
196+
private final BidiStreamingCallable<
197+
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
198+
streamingAnalyzeContentCallable;
179199
private final UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse>
180200
suggestArticlesCallable;
181201
private final UnaryCallable<SuggestFaqAnswersRequest, SuggestFaqAnswersResponse>
@@ -284,6 +304,12 @@ protected GrpcParticipantsStub(
284304
return params.build();
285305
})
286306
.build();
307+
GrpcCallSettings<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
308+
streamingAnalyzeContentTransportSettings =
309+
GrpcCallSettings
310+
.<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>newBuilder()
311+
.setMethodDescriptor(streamingAnalyzeContentMethodDescriptor)
312+
.build();
287313
GrpcCallSettings<SuggestArticlesRequest, SuggestArticlesResponse>
288314
suggestArticlesTransportSettings =
289315
GrpcCallSettings.<SuggestArticlesRequest, SuggestArticlesResponse>newBuilder()
@@ -362,6 +388,11 @@ protected GrpcParticipantsStub(
362388
this.analyzeContentCallable =
363389
callableFactory.createUnaryCallable(
364390
analyzeContentTransportSettings, settings.analyzeContentSettings(), clientContext);
391+
this.streamingAnalyzeContentCallable =
392+
callableFactory.createBidiStreamingCallable(
393+
streamingAnalyzeContentTransportSettings,
394+
settings.streamingAnalyzeContentSettings(),
395+
clientContext);
365396
this.suggestArticlesCallable =
366397
callableFactory.createUnaryCallable(
367398
suggestArticlesTransportSettings, settings.suggestArticlesSettings(), clientContext);
@@ -427,6 +458,12 @@ public UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeConte
427458
return analyzeContentCallable;
428459
}
429460

461+
@Override
462+
public BidiStreamingCallable<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
463+
streamingAnalyzeContentCallable() {
464+
return streamingAnalyzeContentCallable;
465+
}
466+
430467
@Override
431468
public UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse> suggestArticlesCallable() {
432469
return suggestArticlesCallable;

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ParticipantsStub.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.google.api.core.BetaApi;
2323
import com.google.api.gax.core.BackgroundResource;
24+
import com.google.api.gax.rpc.BidiStreamingCallable;
2425
import com.google.api.gax.rpc.UnaryCallable;
2526
import com.google.cloud.dialogflow.v2beta1.AnalyzeContentRequest;
2627
import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse;
@@ -33,6 +34,8 @@
3334
import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest;
3435
import com.google.cloud.dialogflow.v2beta1.ListSuggestionsResponse;
3536
import com.google.cloud.dialogflow.v2beta1.Participant;
37+
import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentRequest;
38+
import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentResponse;
3639
import com.google.cloud.dialogflow.v2beta1.SuggestArticlesRequest;
3740
import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse;
3841
import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersRequest;
@@ -78,6 +81,11 @@ public UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeConte
7881
throw new UnsupportedOperationException("Not implemented: analyzeContentCallable()");
7982
}
8083

84+
public BidiStreamingCallable<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
85+
streamingAnalyzeContentCallable() {
86+
throw new UnsupportedOperationException("Not implemented: streamingAnalyzeContentCallable()");
87+
}
88+
8189
public UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse> suggestArticlesCallable() {
8290
throw new UnsupportedOperationException("Not implemented: suggestArticlesCallable()");
8391
}

0 commit comments

Comments
 (0)