Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 5e21ed4

Browse files
fix(v3beta1): Set agent default language code as required (#103)
PiperOrigin-RevId: 378978212 Source-Link: googleapis/googleapis@ecc3ac6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/398a922b805f32f61d3267232f5d2f66081fa980 feat(v3beta1): Support partial response feature docs(v3beta1): Update docs of Agents, Fulfillments, SecuritySettings and Sessions
1 parent 6cf1175 commit 5e21ed4

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

google/cloud/dialogflowcx_v3beta1/types/agent.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class Agent(proto.Message):
7777
Required. The human-readable name of the
7878
agent, unique within the location.
7979
default_language_code (str):
80-
Immutable. The default language of the agent as a language
81-
tag. See `Language
80+
Required. Immutable. The default language of the agent as a
81+
language tag. See `Language
8282
Support <https://cloud.google.com/dialogflow/cx/docs/reference/language>`__
8383
for a list of the currently supported language codes. This
8484
field cannot be set by the

google/cloud/dialogflowcx_v3beta1/types/fulfillment.py

+14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ class Fulfillment(proto.Message):
5252
webhook (str):
5353
The webhook to call. Format:
5454
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>``.
55+
return_partial_responses (bool):
56+
Whether Dialogflow should return currently
57+
queued fulfillment response messages in
58+
streaming APIs. If a webhook is specified, it
59+
happens before Dialogflow invokes webhook.
60+
Warning:
61+
1) This flag only affects streaming API.
62+
Responses are still queued and returned once in
63+
non-streaming API.
64+
2) The flag can be enabled in any fulfillment
65+
but only the first 3 partial responses will be
66+
returned. You may only want to apply it to
67+
fulfillments that have slow webhooks.
5568
tag (str):
5669
The tag used by the webhook to identify which fulfillment is
5770
being called. This field is required if ``webhook`` is
@@ -143,6 +156,7 @@ class CaseContent(proto.Message):
143156
proto.MESSAGE, number=1, message=response_message.ResponseMessage,
144157
)
145158
webhook = proto.Field(proto.STRING, number=2,)
159+
return_partial_responses = proto.Field(proto.BOOL, number=8,)
146160
tag = proto.Field(proto.STRING, number=3,)
147161
set_parameter_actions = proto.RepeatedField(
148162
proto.MESSAGE, number=4, message=SetParameterAction,

google/cloud/dialogflowcx_v3beta1/types/security_settings.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ class SecuritySettings(proto.Message):
165165
If empty, we use the default DLP inspect config.
166166
167167
The template name will have one of the following formats:
168-
``projects/PROJECT_ID/inspectTemplates/TEMPLATE_ID`` OR
169-
``organizations/ORGANIZATION_ID/inspectTemplates/TEMPLATE_ID``
168+
``projects/<Project ID>/inspectTemplates/<Template ID>`` OR
169+
``projects/<Project ID>/locations/<Location ID>/inspectTemplates/<Template ID>``
170+
OR
171+
``organizations/<Organization ID>/inspectTemplates/<Template ID>``
170172
retention_window_days (int):
171173
Retains data in interaction logging for the
172174
specified number of days. This does not apply to

google/cloud/dialogflowcx_v3beta1/types/session.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,29 @@ class DetectIntentResponse(proto.Message):
116116
output_audio_config (google.cloud.dialogflowcx_v3beta1.types.OutputAudioConfig):
117117
The config used by the speech synthesizer to
118118
generate the output audio.
119+
response_type (google.cloud.dialogflowcx_v3beta1.types.DetectIntentResponse.ResponseType):
120+
Response type.
121+
allow_cancellation (bool):
122+
Indicates whether the partial response can be
123+
cancelled when a later response arrives. e.g. if
124+
the agent specified some music as partial
125+
response, it can be cancelled.
119126
"""
120127

128+
class ResponseType(proto.Enum):
129+
r"""Represents different DetectIntentResponse types."""
130+
RESPONSE_TYPE_UNSPECIFIED = 0
131+
PARTIAL = 1
132+
FINAL = 2
133+
121134
response_id = proto.Field(proto.STRING, number=1,)
122135
query_result = proto.Field(proto.MESSAGE, number=2, message="QueryResult",)
123136
output_audio = proto.Field(proto.BYTES, number=4,)
124137
output_audio_config = proto.Field(
125138
proto.MESSAGE, number=5, message=audio_config.OutputAudioConfig,
126139
)
140+
response_type = proto.Field(proto.ENUM, number=6, enum=ResponseType,)
141+
allow_cancellation = proto.Field(proto.BOOL, number=7,)
127142

128143

129144
class StreamingDetectIntentRequest(proto.Message):
@@ -189,6 +204,11 @@ class StreamingDetectIntentRequest(proto.Message):
189204
output_audio_config (google.cloud.dialogflowcx_v3beta1.types.OutputAudioConfig):
190205
Instructs the speech synthesizer how to
191206
generate the output audio.
207+
enable_partial_response (bool):
208+
Enable partial detect intent response. If this flag is not
209+
enabled, response stream still contains only one final
210+
``DetectIntentResponse`` even if some ``Fulfillment``\ s in
211+
the agent have been configured to return partial responses.
192212
"""
193213

194214
session = proto.Field(proto.STRING, number=1,)
@@ -197,6 +217,7 @@ class StreamingDetectIntentRequest(proto.Message):
197217
output_audio_config = proto.Field(
198218
proto.MESSAGE, number=4, message=audio_config.OutputAudioConfig,
199219
)
220+
enable_partial_response = proto.Field(proto.BOOL, number=5,)
200221

201222

202223
class StreamingDetectIntentResponse(proto.Message):
@@ -395,7 +416,7 @@ class QueryParameters(proto.Message):
395416
[page][google.cloud.dialogflow.cx.v3beta1.Page] to override
396417
the [current page][QueryResult.current_page] in the session.
397418
Format:
398-
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/pages/<page ID>``.
419+
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>``.
399420
400421
If ``current_page`` is specified, the previous state of the
401422
session will be ignored by Dialogflow, including the

tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,10 @@ def test_detect_intent(
463463
with mock.patch.object(type(client.transport.detect_intent), "__call__") as call:
464464
# Designate an appropriate return value for the call.
465465
call.return_value = session.DetectIntentResponse(
466-
response_id="response_id_value", output_audio=b"output_audio_blob",
466+
response_id="response_id_value",
467+
output_audio=b"output_audio_blob",
468+
response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
469+
allow_cancellation=True,
467470
)
468471
response = client.detect_intent(request)
469472

@@ -476,6 +479,8 @@ def test_detect_intent(
476479
assert isinstance(response, session.DetectIntentResponse)
477480
assert response.response_id == "response_id_value"
478481
assert response.output_audio == b"output_audio_blob"
482+
assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
483+
assert response.allow_cancellation is True
479484

480485

481486
def test_detect_intent_from_dict():
@@ -514,7 +519,10 @@ async def test_detect_intent_async(
514519
# Designate an appropriate return value for the call.
515520
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
516521
session.DetectIntentResponse(
517-
response_id="response_id_value", output_audio=b"output_audio_blob",
522+
response_id="response_id_value",
523+
output_audio=b"output_audio_blob",
524+
response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
525+
allow_cancellation=True,
518526
)
519527
)
520528
response = await client.detect_intent(request)
@@ -528,6 +536,8 @@ async def test_detect_intent_async(
528536
assert isinstance(response, session.DetectIntentResponse)
529537
assert response.response_id == "response_id_value"
530538
assert response.output_audio == b"output_audio_blob"
539+
assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
540+
assert response.allow_cancellation is True
531541

532542

533543
@pytest.mark.asyncio

0 commit comments

Comments
 (0)