Skip to content

Commit

Permalink
feat: [dialogflow] Added StreamingAnalyzeContent API (#8684)
Browse files Browse the repository at this point in the history
* feat: Added StreamingAnalyzeContent API
feat: Added obfuscated_external_user_id to Participant
feat: Can directly set Cloud Speech model on the SpeechToTextConfig

PiperOrigin-RevId: 483696090

Source-Link: googleapis/googleapis@3772bf3

Source-Link: https://github.com/googleapis/googleapis-gen/commit/e358d269b1f0eb9964189d18768823bc9e8ab41c
Copy-Tag: eyJwIjoiamF2YS1kaWFsb2dmbG93Ly5Pd2xCb3QueWFtbCIsImgiOiJlMzU4ZDI2OWIxZjBlYjk5NjQxODlkMTg3Njg4MjNiYzllOGFiNDFjIn0=

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Oct 27, 2022
1 parent 0635008 commit 97a0958
Show file tree
Hide file tree
Showing 32 changed files with 11,521 additions and 279 deletions.
17 changes: 17 additions & 0 deletions java-dialogflow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Maven
target/

# Eclipse
.classpath
.project
.settings

# Intellij
*.iml
.idea/

# python utilities
*.pyc
__pycache__

.flattened-pom.xml
6 changes: 3 additions & 3 deletions java-dialogflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dialogflow</artifactId>
<version>4.10.0</version>
<version>4.11.0</version>
</dependency>
```

If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-dialogflow:4.10.0'
implementation 'com.google.cloud:google-cloud-dialogflow:4.11.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-dialogflow" % "4.10.0"
libraryDependencies += "com.google.cloud" % "google-cloud-dialogflow" % "4.11.0"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dialogflow.v2.stub.ParticipantsStub;
Expand Down Expand Up @@ -945,6 +946,57 @@ public final AnalyzeContentResponse analyzeContent(AnalyzeContentRequest request
return stub.analyzeContentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Adds a text (chat, for example), or audio (phone recording, for example) message from a
* participant into the conversation. Note: This method is only available through the gRPC API
* (not REST).
*
* <p>The top-level message sent to the client by the server is `StreamingAnalyzeContentResponse`.
* Multiple response messages can be returned in order. The first one or more messages contain the
* `recognition_result` field. Each result represents a more complete transcript of what the user
* said. The next message contains the `reply_text` field and potentially the `reply_audio` field.
* The message can also contain the `automated_agent_reply` field.
*
* <p>Note: Always use agent versions for production traffic sent to virtual agents. See [Versions
* and environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
*
* <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 (ParticipantsClient participantsClient = ParticipantsClient.create()) {
* BidiStream<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse> bidiStream =
* participantsClient.streamingAnalyzeContentCallable().call();
* StreamingAnalyzeContentRequest request =
* StreamingAnalyzeContentRequest.newBuilder()
* .setParticipant(
* ParticipantName.ofProjectConversationParticipantName(
* "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]")
* .toString())
* .setReplyAudioConfig(OutputAudioConfig.newBuilder().build())
* .setQueryParams(QueryParameters.newBuilder().build())
* .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
* .setCxParameters(Struct.newBuilder().build())
* .setEnablePartialAutomatedAgentReply(true)
* .build();
* bidiStream.send(request);
* for (StreamingAnalyzeContentResponse response : bidiStream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final BidiStreamingCallable<
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentCallable() {
return stub.streamingAnalyzeContentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets suggested articles for a participant based on specific historical messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.dialogflow.v2.stub.ParticipantsStubSettings;
Expand Down Expand Up @@ -103,6 +104,12 @@ public UnaryCallSettings<AnalyzeContentRequest, AnalyzeContentResponse> analyzeC
return ((ParticipantsStubSettings) getStubSettings()).analyzeContentSettings();
}

/** Returns the object with the settings used for calls to streamingAnalyzeContent. */
public StreamingCallSettings<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentSettings() {
return ((ParticipantsStubSettings) getStubSettings()).streamingAnalyzeContentSettings();
}

/** Returns the object with the settings used for calls to suggestArticles. */
public UnaryCallSettings<SuggestArticlesRequest, SuggestArticlesResponse>
suggestArticlesSettings() {
Expand Down Expand Up @@ -277,6 +284,13 @@ public UnaryCallSettings.Builder<GetParticipantRequest, Participant> getParticip
return getStubSettingsBuilder().analyzeContentSettings();
}

/** Returns the builder for the settings used for calls to streamingAnalyzeContent. */
public StreamingCallSettings.Builder<
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentSettings() {
return getStubSettingsBuilder().streamingAnalyzeContentSettings();
}

/** Returns the builder for the settings used for calls to suggestArticles. */
public UnaryCallSettings.Builder<SuggestArticlesRequest, SuggestArticlesResponse>
suggestArticlesSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@
"ListParticipants": {
"methods": ["listParticipants", "listParticipants", "listParticipants", "listParticipantsPagedCallable", "listParticipantsCallable"]
},
"StreamingAnalyzeContent": {
"methods": ["streamingAnalyzeContentCallable"]
},
"SuggestArticles": {
"methods": ["suggestArticles", "suggestArticles", "suggestArticles", "suggestArticlesCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dialogflow.v2.AnalyzeContentRequest;
Expand All @@ -32,6 +33,8 @@
import com.google.cloud.dialogflow.v2.ListParticipantsRequest;
import com.google.cloud.dialogflow.v2.ListParticipantsResponse;
import com.google.cloud.dialogflow.v2.Participant;
import com.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest;
import com.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse;
import com.google.cloud.dialogflow.v2.SuggestArticlesRequest;
import com.google.cloud.dialogflow.v2.SuggestArticlesResponse;
import com.google.cloud.dialogflow.v2.SuggestFaqAnswersRequest;
Expand Down Expand Up @@ -111,6 +114,19 @@ public class GrpcParticipantsStub extends ParticipantsStub {
ProtoUtils.marshaller(AnalyzeContentResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentMethodDescriptor =
MethodDescriptor
.<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>newBuilder()
.setType(MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName("google.cloud.dialogflow.v2.Participants/StreamingAnalyzeContent")
.setRequestMarshaller(
ProtoUtils.marshaller(StreamingAnalyzeContentRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(StreamingAnalyzeContentResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<SuggestArticlesRequest, SuggestArticlesResponse>
suggestArticlesMethodDescriptor =
MethodDescriptor.<SuggestArticlesRequest, SuggestArticlesResponse>newBuilder()
Expand Down Expand Up @@ -171,6 +187,9 @@ public class GrpcParticipantsStub extends ParticipantsStub {
listParticipantsPagedCallable;
private final UnaryCallable<UpdateParticipantRequest, Participant> updateParticipantCallable;
private final UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeContentCallable;
private final BidiStreamingCallable<
StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentCallable;
private final UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse>
suggestArticlesCallable;
private final UnaryCallable<SuggestFaqAnswersRequest, SuggestFaqAnswersResponse>
Expand Down Expand Up @@ -277,6 +296,12 @@ protected GrpcParticipantsStub(
return params.build();
})
.build();
GrpcCallSettings<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentTransportSettings =
GrpcCallSettings
.<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>newBuilder()
.setMethodDescriptor(streamingAnalyzeContentMethodDescriptor)
.build();
GrpcCallSettings<SuggestArticlesRequest, SuggestArticlesResponse>
suggestArticlesTransportSettings =
GrpcCallSettings.<SuggestArticlesRequest, SuggestArticlesResponse>newBuilder()
Expand Down Expand Up @@ -353,6 +378,11 @@ protected GrpcParticipantsStub(
this.analyzeContentCallable =
callableFactory.createUnaryCallable(
analyzeContentTransportSettings, settings.analyzeContentSettings(), clientContext);
this.streamingAnalyzeContentCallable =
callableFactory.createBidiStreamingCallable(
streamingAnalyzeContentTransportSettings,
settings.streamingAnalyzeContentSettings(),
clientContext);
this.suggestArticlesCallable =
callableFactory.createUnaryCallable(
suggestArticlesTransportSettings, settings.suggestArticlesSettings(), clientContext);
Expand Down Expand Up @@ -416,6 +446,12 @@ public UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeConte
return analyzeContentCallable;
}

@Override
public BidiStreamingCallable<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentCallable() {
return streamingAnalyzeContentCallable;
}

@Override
public UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse> suggestArticlesCallable() {
return suggestArticlesCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public class HttpJsonIntentsStub extends IntentsStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<ListIntentsRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "intentView", request.getIntentView());
serializer.putQueryParam(
fields, "intentView", request.getIntentViewValue());
serializer.putQueryParam(
fields, "languageCode", request.getLanguageCode());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
Expand Down Expand Up @@ -140,7 +141,8 @@ public class HttpJsonIntentsStub extends IntentsStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<GetIntentRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "intentView", request.getIntentView());
serializer.putQueryParam(
fields, "intentView", request.getIntentViewValue());
serializer.putQueryParam(fields, "languageCode", request.getLanguageCode());
return fields;
})
Expand Down Expand Up @@ -176,7 +178,8 @@ public class HttpJsonIntentsStub extends IntentsStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<CreateIntentRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "intentView", request.getIntentView());
serializer.putQueryParam(
fields, "intentView", request.getIntentViewValue());
serializer.putQueryParam(
fields, "languageCode", request.getLanguageCode());
return fields;
Expand Down Expand Up @@ -218,7 +221,8 @@ public class HttpJsonIntentsStub extends IntentsStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<UpdateIntentRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "intentView", request.getIntentView());
serializer.putQueryParam(
fields, "intentView", request.getIntentViewValue());
serializer.putQueryParam(
fields, "languageCode", request.getLanguageCode());
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.google.cloud.dialogflow.v2.ParticipantsClient.ListParticipantsPagedResponse;

import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dialogflow.v2.AnalyzeContentRequest;
import com.google.cloud.dialogflow.v2.AnalyzeContentResponse;
Expand All @@ -28,6 +29,8 @@
import com.google.cloud.dialogflow.v2.ListParticipantsRequest;
import com.google.cloud.dialogflow.v2.ListParticipantsResponse;
import com.google.cloud.dialogflow.v2.Participant;
import com.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest;
import com.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse;
import com.google.cloud.dialogflow.v2.SuggestArticlesRequest;
import com.google.cloud.dialogflow.v2.SuggestArticlesResponse;
import com.google.cloud.dialogflow.v2.SuggestFaqAnswersRequest;
Expand Down Expand Up @@ -76,6 +79,11 @@ public UnaryCallable<AnalyzeContentRequest, AnalyzeContentResponse> analyzeConte
throw new UnsupportedOperationException("Not implemented: analyzeContentCallable()");
}

public BidiStreamingCallable<StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse>
streamingAnalyzeContentCallable() {
throw new UnsupportedOperationException("Not implemented: streamingAnalyzeContentCallable()");
}

public UnaryCallable<SuggestArticlesRequest, SuggestArticlesResponse> suggestArticlesCallable() {
throw new UnsupportedOperationException("Not implemented: suggestArticlesCallable()");
}
Expand Down
Loading

0 comments on commit 97a0958

Please sign in to comment.