Skip to content

Commit

Permalink
feat: [google-cloud-dialogflow] add sections field to HumanAgentAssis…
Browse files Browse the repository at this point in the history
…tantConfig.SuggestionQueryConfig (#12128)

- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE
feat: Add sections field to
HumanAgentAssistantConfig.SuggestionQueryConfig
feat: Add enable_conversation_augmented_query field to
HumanAgentAssistantConfig.SuggestionFeatureConfig message
feat: Add INTENT enum in SearchKnowledgeAnswer.AnswerType message
feat: Add rewritten_query in field in SearchKnowledgeResponse message
docs: Improved comments on audio_config proto
END_COMMIT_OVERRIDE


PiperOrigin-RevId: 591042460

Source-Link:
googleapis/googleapis@8e2e403

Source-Link:
googleapis/googleapis-gen@c8cdc4d
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpYWxvZ2Zsb3cvLk93bEJvdC55YW1sIiwiaCI6ImM4Y2RjNGQzODYzNTJjODYwZmNlMmI2ZWZjNWMwMmU2ODA0MDNhM2QifQ==

---------

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] committed Dec 15, 2023
1 parent e063fa9 commit a481c80
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 35 deletions.
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -471,23 +471,9 @@ class InputAudioConfig(proto.Message):
documentation <https://cloud.google.com/speech-to-text/docs/basics#phrase-hints>`__
for more details.
model (str):
Which Speech model to select for the given request. Select
the model best suited to your domain to get best results. If
a model is not explicitly specified, then we auto-select a
model based on the parameters in the InputAudioConfig. If
enhanced speech model is enabled for the agent and an
enhanced version of the specified model for the language
does not exist, then the speech is recognized using the
standard version of the specified model. Refer to `Cloud
Speech API
documentation <https://cloud.google.com/speech-to-text/docs/basics#select-model>`__
for more details. If you specify a model, the following
models typically have the best performance:
- phone_call (best for Agent Assist and telephony)
- latest_short (best for Dialogflow non-telephony)
- command_and_search (best for very short utterances and
commands)
Optional. Which Speech model to select for the given
request. For more information, see `Speech
models <https://cloud.google.com/dialogflow/es/docs/speech-models>`__.
model_variant (google.cloud.dialogflow_v2beta1.types.SpeechModelVariant):
Which variant of the [Speech
model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model]
Expand Down Expand Up @@ -739,10 +725,24 @@ class SpeechToTextConfig(proto.Message):
model (str):
Which Speech model to select. Select the model best suited
to your domain to get best results. If a model is not
explicitly specified, then a default model is used. Refer to
`Cloud Speech API
explicitly specified, then Dialogflow auto-selects a model
based on other parameters in the SpeechToTextConfig and
Agent settings. If enhanced speech model is enabled for the
agent and an enhanced version of the specified model for the
language does not exist, then the speech is recognized using
the standard version of the specified model. Refer to `Cloud
Speech API
documentation <https://cloud.google.com/speech-to-text/docs/basics#select-model>`__
for more details.
for more details. If you specify a model, the following
models typically have the best performance:
- phone_call (best for Agent Assist and telephony)
- latest_short (best for Dialogflow non-telephony)
- command_and_search
Leave this field unspecified to use `Agent Speech
settings <https://cloud.google.com/dialogflow/cx/docs/concept/agent#settings-speech>`__
for model selection.
use_timeout_based_endpointing (bool):
Use timeout based endpointing, interpreting
endpointer sensitivy as seconds of timeout
Expand Down
Expand Up @@ -826,13 +826,19 @@ class SearchKnowledgeResponse(proto.Message):
Most relevant snippets extracted from
articles in the given knowledge base, ordered by
confidence.
rewritten_query (str):
The rewritten query used to search knowledge.
"""

answers: MutableSequence["SearchKnowledgeAnswer"] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message="SearchKnowledgeAnswer",
)
rewritten_query: str = proto.Field(
proto.STRING,
number=3,
)


class SearchKnowledgeAnswer(proto.Message):
Expand All @@ -858,13 +864,16 @@ class AnswerType(proto.Enum):
ANSWER_TYPE_UNSPECIFIED (0):
The answer has a unspecified type.
FAQ (1):
The answer is from FAQ doucments.
The answer is from FAQ documents.
GENERATIVE (2):
The answer is from generative model.
INTENT (3):
The answer is from intent matching.
"""
ANSWER_TYPE_UNSPECIFIED = 0
FAQ = 1
GENERATIVE = 2
INTENT = 3

class AnswerSource(proto.Message):
r"""The sources of the answers.
Expand Down
Expand Up @@ -208,12 +208,12 @@ class AutomatedAgentConfig(proto.Message):
If environment is not specified, the default ``draft``
environment is used.
session_ttl (google.protobuf.duration_pb2.Duration):
Optional. Sets Dialogflow CX session life
time. By default, a Dialogflow CX session
remains active and its data is stored for 30
minutes after the last request is sent for the
session. This value should be no longer than 1
day.
Optional. Configure lifetime of the
Dialogflow session. By default, a Dialogflow CX
session remains active and its data is stored
for 30 minutes after the last request is sent
for the session. This value should be no longer
than 1 day.
"""

agent: str = proto.Field(
Expand Down Expand Up @@ -286,6 +286,9 @@ class SuggestionFeatureConfig(proto.Message):
at answer records.
Supported features: KNOWLEDGE_SEARCH.
enable_conversation_augmented_query (bool):
Optional. Enable including conversation context during query
answer generation. Supported features: KNOWLEDGE_SEARCH.
suggestion_trigger_settings (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionTriggerSettings):
Settings of suggestion trigger.
Expand All @@ -312,6 +315,10 @@ class SuggestionFeatureConfig(proto.Message):
proto.BOOL,
number=14,
)
enable_conversation_augmented_query: bool = proto.Field(
proto.BOOL,
number=16,
)
suggestion_trigger_settings: "HumanAgentAssistantConfig.SuggestionTriggerSettings" = proto.Field(
proto.MESSAGE,
number=10,
Expand Down Expand Up @@ -424,6 +431,10 @@ class SuggestionQueryConfig(proto.Message):
Determines how recent conversation context is
filtered when generating suggestions. If
unspecified, no messages will be dropped.
sections (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionQueryConfig.Sections):
Optional. The customized sections chosen to
return when requesting a summary of a
conversation.
"""

class KnowledgeBaseQuerySource(proto.Message):
Expand Down Expand Up @@ -534,6 +545,72 @@ class ContextFilterSettings(proto.Message):
number=3,
)

class Sections(proto.Message):
r"""Custom sections to return when requesting a summary of a
conversation. This is only supported when ``baseline_model_version``
== '2.0'.
Supported features: CONVERSATION_SUMMARIZATION,
CONVERSATION_SUMMARIZATION_VOICE.
Attributes:
section_types (MutableSequence[google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType]):
The selected sections chosen to return when
requesting a summary of a conversation. A
duplicate selected section will be treated as a
single selected section. If section types are
not provided, the default will be {SITUATION,
ACTION, RESULT}.
"""

class SectionType(proto.Enum):
r"""Selectable sections to return when requesting a summary of a
conversation.
Values:
SECTION_TYPE_UNSPECIFIED (0):
Undefined section type, does not return
anything.
SITUATION (1):
What the customer needs help with or has
question about. Section name: "situation".
ACTION (2):
What the agent does to help the customer.
Section name: "action".
RESOLUTION (3):
Result of the customer service. A single word
describing the result of the conversation.
Section name: "resolution".
REASON_FOR_CANCELLATION (4):
Reason for cancellation if the customer requests for a
cancellation. "N/A" otherwise. Section name:
"reason_for_cancellation".
CUSTOMER_SATISFACTION (5):
"Unsatisfied" or "Satisfied" depending on the customer's
feelings at the end of the conversation. Section name:
"customer_satisfaction".
ENTITIES (6):
Key entities extracted from the conversation,
such as ticket number, order number, dollar
amount, etc. Section names are prefixed by
"entities/".
"""
SECTION_TYPE_UNSPECIFIED = 0
SITUATION = 1
ACTION = 2
RESOLUTION = 3
REASON_FOR_CANCELLATION = 4
CUSTOMER_SATISFACTION = 5
ENTITIES = 6

section_types: MutableSequence[
"HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType"
] = proto.RepeatedField(
proto.ENUM,
number=1,
enum="HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType",
)

knowledge_base_query_source: "HumanAgentAssistantConfig.SuggestionQueryConfig.KnowledgeBaseQuerySource" = proto.Field(
proto.MESSAGE,
number=1,
Expand Down Expand Up @@ -565,6 +642,13 @@ class ContextFilterSettings(proto.Message):
number=7,
message="HumanAgentAssistantConfig.SuggestionQueryConfig.ContextFilterSettings",
)
sections: "HumanAgentAssistantConfig.SuggestionQueryConfig.Sections" = (
proto.Field(
proto.MESSAGE,
number=8,
message="HumanAgentAssistantConfig.SuggestionQueryConfig.Sections",
)
)

class ConversationModelConfig(proto.Message):
r"""Custom conversation models used in agent assist feature.
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-dialogflow",
"version": "2.26.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-dialogflow",
"version": "2.26.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -3497,6 +3497,7 @@ def test_create_conversation_profile_rest(request_type):
"suggestion_feature": {"type_": 1},
"enable_event_based_suggestion": True,
"disable_agent_query_logging": True,
"enable_conversation_augmented_query": True,
"suggestion_trigger_settings": {
"no_small_talk": True,
"only_end_user": True,
Expand All @@ -3522,6 +3523,7 @@ def test_create_conversation_profile_rest(request_type):
"drop_virtual_agent_messages": True,
"drop_ivr_messages": True,
},
"sections": {"section_types": [1]},
},
"conversation_model_config": {
"model": "model_value",
Expand Down Expand Up @@ -3960,6 +3962,7 @@ def test_update_conversation_profile_rest(request_type):
"suggestion_feature": {"type_": 1},
"enable_event_based_suggestion": True,
"disable_agent_query_logging": True,
"enable_conversation_augmented_query": True,
"suggestion_trigger_settings": {
"no_small_talk": True,
"only_end_user": True,
Expand All @@ -3985,6 +3988,7 @@ def test_update_conversation_profile_rest(request_type):
"drop_virtual_agent_messages": True,
"drop_ivr_messages": True,
},
"sections": {"section_types": [1]},
},
"conversation_model_config": {
"model": "model_value",
Expand Down
Expand Up @@ -3064,7 +3064,9 @@ def test_search_knowledge(request_type, transport: str = "grpc"):
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = conversation.SearchKnowledgeResponse()
call.return_value = conversation.SearchKnowledgeResponse(
rewritten_query="rewritten_query_value",
)
response = client.search_knowledge(request)

# Establish that the underlying gRPC stub method was called.
Expand All @@ -3074,6 +3076,7 @@ def test_search_knowledge(request_type, transport: str = "grpc"):

# Establish that the response is the type that we expect.
assert isinstance(response, conversation.SearchKnowledgeResponse)
assert response.rewritten_query == "rewritten_query_value"


def test_search_knowledge_empty_call():
Expand Down Expand Up @@ -3109,7 +3112,9 @@ async def test_search_knowledge_async(
with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
conversation.SearchKnowledgeResponse()
conversation.SearchKnowledgeResponse(
rewritten_query="rewritten_query_value",
)
)
response = await client.search_knowledge(request)

Expand All @@ -3120,6 +3125,7 @@ async def test_search_knowledge_async(

# Establish that the response is the type that we expect.
assert isinstance(response, conversation.SearchKnowledgeResponse)
assert response.rewritten_query == "rewritten_query_value"


@pytest.mark.asyncio
Expand Down Expand Up @@ -5614,7 +5620,9 @@ def test_search_knowledge_rest(request_type):
# Mock the http request call within the method and fake a response.
with mock.patch.object(type(client.transport._session), "request") as req:
# Designate an appropriate value for the returned response.
return_value = conversation.SearchKnowledgeResponse()
return_value = conversation.SearchKnowledgeResponse(
rewritten_query="rewritten_query_value",
)

# Wrap the value into a proper Response obj
response_value = Response()
Expand All @@ -5629,6 +5637,7 @@ def test_search_knowledge_rest(request_type):

# Establish that the response is the type that we expect.
assert isinstance(response, conversation.SearchKnowledgeResponse)
assert response.rewritten_query == "rewritten_query_value"


def test_search_knowledge_rest_required_fields(
Expand Down

0 comments on commit a481c80

Please sign in to comment.