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

Commit

Permalink
fix(v3beta1): Set agent default language code as required (#103)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 378978212

Source-Link: googleapis/googleapis@ecc3ac6

Source-Link: googleapis/googleapis-gen@398a922

feat(v3beta1): Support partial response feature
docs(v3beta1): Update docs of Agents, Fulfillments, SecuritySettings and Sessions
  • Loading branch information
gcf-owl-bot[bot] committed Jun 14, 2021
1 parent 6cf1175 commit 5e21ed4
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
4 changes: 2 additions & 2 deletions google/cloud/dialogflowcx_v3beta1/types/agent.py
Expand Up @@ -77,8 +77,8 @@ class Agent(proto.Message):
Required. The human-readable name of the
agent, unique within the location.
default_language_code (str):
Immutable. The default language of the agent as a language
tag. See `Language
Required. Immutable. The default language of the agent as a
language tag. See `Language
Support <https://cloud.google.com/dialogflow/cx/docs/reference/language>`__
for a list of the currently supported language codes. This
field cannot be set by the
Expand Down
14 changes: 14 additions & 0 deletions google/cloud/dialogflowcx_v3beta1/types/fulfillment.py
Expand Up @@ -52,6 +52,19 @@ class Fulfillment(proto.Message):
webhook (str):
The webhook to call. Format:
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>``.
return_partial_responses (bool):
Whether Dialogflow should return currently
queued fulfillment response messages in
streaming APIs. If a webhook is specified, it
happens before Dialogflow invokes webhook.
Warning:
1) This flag only affects streaming API.
Responses are still queued and returned once in
non-streaming API.
2) The flag can be enabled in any fulfillment
but only the first 3 partial responses will be
returned. You may only want to apply it to
fulfillments that have slow webhooks.
tag (str):
The tag used by the webhook to identify which fulfillment is
being called. This field is required if ``webhook`` is
Expand Down Expand Up @@ -143,6 +156,7 @@ class CaseContent(proto.Message):
proto.MESSAGE, number=1, message=response_message.ResponseMessage,
)
webhook = proto.Field(proto.STRING, number=2,)
return_partial_responses = proto.Field(proto.BOOL, number=8,)
tag = proto.Field(proto.STRING, number=3,)
set_parameter_actions = proto.RepeatedField(
proto.MESSAGE, number=4, message=SetParameterAction,
Expand Down
6 changes: 4 additions & 2 deletions google/cloud/dialogflowcx_v3beta1/types/security_settings.py
Expand Up @@ -165,8 +165,10 @@ class SecuritySettings(proto.Message):
If empty, we use the default DLP inspect config.
The template name will have one of the following formats:
``projects/PROJECT_ID/inspectTemplates/TEMPLATE_ID`` OR
``organizations/ORGANIZATION_ID/inspectTemplates/TEMPLATE_ID``
``projects/<Project ID>/inspectTemplates/<Template ID>`` OR
``projects/<Project ID>/locations/<Location ID>/inspectTemplates/<Template ID>``
OR
``organizations/<Organization ID>/inspectTemplates/<Template ID>``
retention_window_days (int):
Retains data in interaction logging for the
specified number of days. This does not apply to
Expand Down
23 changes: 22 additions & 1 deletion google/cloud/dialogflowcx_v3beta1/types/session.py
Expand Up @@ -116,14 +116,29 @@ class DetectIntentResponse(proto.Message):
output_audio_config (google.cloud.dialogflowcx_v3beta1.types.OutputAudioConfig):
The config used by the speech synthesizer to
generate the output audio.
response_type (google.cloud.dialogflowcx_v3beta1.types.DetectIntentResponse.ResponseType):
Response type.
allow_cancellation (bool):
Indicates whether the partial response can be
cancelled when a later response arrives. e.g. if
the agent specified some music as partial
response, it can be cancelled.
"""

class ResponseType(proto.Enum):
r"""Represents different DetectIntentResponse types."""
RESPONSE_TYPE_UNSPECIFIED = 0
PARTIAL = 1
FINAL = 2

response_id = proto.Field(proto.STRING, number=1,)
query_result = proto.Field(proto.MESSAGE, number=2, message="QueryResult",)
output_audio = proto.Field(proto.BYTES, number=4,)
output_audio_config = proto.Field(
proto.MESSAGE, number=5, message=audio_config.OutputAudioConfig,
)
response_type = proto.Field(proto.ENUM, number=6, enum=ResponseType,)
allow_cancellation = proto.Field(proto.BOOL, number=7,)


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

session = proto.Field(proto.STRING, number=1,)
Expand All @@ -197,6 +217,7 @@ class StreamingDetectIntentRequest(proto.Message):
output_audio_config = proto.Field(
proto.MESSAGE, number=4, message=audio_config.OutputAudioConfig,
)
enable_partial_response = proto.Field(proto.BOOL, number=5,)


class StreamingDetectIntentResponse(proto.Message):
Expand Down Expand Up @@ -395,7 +416,7 @@ class QueryParameters(proto.Message):
[page][google.cloud.dialogflow.cx.v3beta1.Page] to override
the [current page][QueryResult.current_page] in the session.
Format:
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/pages/<page ID>``.
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>``.
If ``current_page`` is specified, the previous state of the
session will be ignored by Dialogflow, including the
Expand Down
14 changes: 12 additions & 2 deletions tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py
Expand Up @@ -463,7 +463,10 @@ def test_detect_intent(
with mock.patch.object(type(client.transport.detect_intent), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = session.DetectIntentResponse(
response_id="response_id_value", output_audio=b"output_audio_blob",
response_id="response_id_value",
output_audio=b"output_audio_blob",
response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
allow_cancellation=True,
)
response = client.detect_intent(request)

Expand All @@ -476,6 +479,8 @@ def test_detect_intent(
assert isinstance(response, session.DetectIntentResponse)
assert response.response_id == "response_id_value"
assert response.output_audio == b"output_audio_blob"
assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
assert response.allow_cancellation is True


def test_detect_intent_from_dict():
Expand Down Expand Up @@ -514,7 +519,10 @@ async def test_detect_intent_async(
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
session.DetectIntentResponse(
response_id="response_id_value", output_audio=b"output_audio_blob",
response_id="response_id_value",
output_audio=b"output_audio_blob",
response_type=session.DetectIntentResponse.ResponseType.PARTIAL,
allow_cancellation=True,
)
)
response = await client.detect_intent(request)
Expand All @@ -528,6 +536,8 @@ async def test_detect_intent_async(
assert isinstance(response, session.DetectIntentResponse)
assert response.response_id == "response_id_value"
assert response.output_audio == b"output_audio_blob"
assert response.response_type == session.DetectIntentResponse.ResponseType.PARTIAL
assert response.allow_cancellation is True


@pytest.mark.asyncio
Expand Down

0 comments on commit 5e21ed4

Please sign in to comment.