Skip to content

Commit

Permalink
feat(dialogflow): Add AgentsClient#get_validation_result (ValidationR…
Browse files Browse the repository at this point in the history
…esult)

* Add DetectIntentRequest#output_audio_config_mask (FieldMask)
* Add StreamingDetectIntentRequest#output_audio_config_mask (FieldMask)
  • Loading branch information
yoshi-automation committed Feb 28, 2020
1 parent f8b5713 commit d54b072
Show file tree
Hide file tree
Showing 18 changed files with 308 additions and 39 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -303,6 +303,14 @@ def initialize \
{'parent' => request.parent}
end
)
@get_validation_result = Google::Gax.create_api_call(
@agents_stub.method(:get_validation_result),
defaults["get_validation_result"],
exception_transformer: exception_transformer,
params_extractor: proc do |request|
{'parent' => request.parent}
end
)
end

# Service calls
Expand Down Expand Up @@ -753,6 +761,45 @@ def restore_agent \
operation.on_done { |operation| yield(operation) } if block_given?
operation
end

# Gets agent validation result. Agent validation is performed during
# training time and is updated automatically when training is completed.
#
# @param parent [String]
# Required. The project that the agent is associated with.
# Format: `projects/<Project ID>`.
# @param language_code [String]
# Optional. The language for which you want a validation result. If not
# specified, the agent's default language is used. [Many
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
# are supported. Note: languages must be enabled in the agent before they can
# be used.
# @param options [Google::Gax::CallOptions]
# Overrides the default settings for this call, e.g, timeout,
# retries, etc.
# @yield [result, operation] Access the result along with the RPC operation
# @yieldparam result [Google::Cloud::Dialogflow::V2::ValidationResult]
# @yieldparam operation [GRPC::ActiveCall::Operation]
# @return [Google::Cloud::Dialogflow::V2::ValidationResult]
# @raise [Google::Gax::GaxError] if the RPC is aborted.
# @example
# require "google/cloud/dialogflow"
#
# agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
# response = agents_client.get_validation_result

def get_validation_result \
parent: nil,
language_code: nil,
options: nil,
&block
req = {
parent: parent,
language_code: language_code
}.delete_if { |_, v| v.nil? }
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetValidationResultRequest)
@get_validation_result.call(req, options, &block)
end
end
end
end
Expand Down
Expand Up @@ -59,6 +59,11 @@
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"GetValidationResult": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -227,6 +227,20 @@ class ImportAgentRequest; end
# @return [String]
# Zip compressed raw byte content for agent.
class RestoreAgentRequest; end

# The request message for {Google::Cloud::Dialogflow::V2::Agents::GetValidationResult Agents::GetValidationResult}.
# @!attribute [rw] parent
# @return [String]
# Required. The project that the agent is associated with.
# Format: `projects/<Project ID>`.
# @!attribute [rw] language_code
# @return [String]
# Optional. The language for which you want a validation result. If not
# specified, the agent's default language is used. [Many
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
# are supported. Note: languages must be enabled in the agent before they can
# be used.
class GetValidationResultRequest; end
end
end
end
Expand Down
Expand Up @@ -198,14 +198,14 @@ class SynthesizeSpeechConfig; end
# Required. Audio encoding of the synthesized audio content.
# @!attribute [rw] sample_rate_hertz
# @return [Integer]
# Optional. The synthesis sample rate (in hertz) for this audio. If not
# The synthesis sample rate (in hertz) for this audio. If not
# provided, then the synthesizer will use the default sample rate based on
# the audio encoding. If this is different from the voice's natural sample
# rate, then the synthesizer will honor this request by converting to the
# desired sample rate (which might result in worse audio quality).
# @!attribute [rw] synthesize_speech_config
# @return [Google::Cloud::Dialogflow::V2::SynthesizeSpeechConfig]
# Optional. Configuration of how speech should be synthesized.
# Configuration of how speech should be synthesized.
class OutputAudioConfig; end

# Audio encoding of the audio content sent in the conversational query request.
Expand Down
Expand Up @@ -29,7 +29,7 @@ module V2
# ID must not exceed 36 bytes.
# @!attribute [rw] query_params
# @return [Google::Cloud::Dialogflow::V2::QueryParameters]
# Optional. The parameters of this query.
# The parameters of this query.
# @!attribute [rw] query_input
# @return [Google::Cloud::Dialogflow::V2::QueryInput]
# Required. The input specification. It can be set to:
Expand All @@ -42,12 +42,20 @@ module V2
# 3. an event that specifies which intent to trigger.
# @!attribute [rw] output_audio_config
# @return [Google::Cloud::Dialogflow::V2::OutputAudioConfig]
# Optional. Instructs the speech synthesizer how to generate the output
# Instructs the speech synthesizer how to generate the output
# audio. If this field is not set and agent-level speech synthesizer is not
# configured, no output audio is generated.
# @!attribute [rw] output_audio_config_mask
# @return [Google::Protobuf::FieldMask]
# Mask for {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} indicating which settings in this
# request-level config should override speech synthesizer settings defined at
# agent-level.
#
# If unspecified or empty, {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} replaces the agent-level
# config in its entirety.
# @!attribute [rw] input_audio
# @return [String]
# Optional. The natural language speech audio to be processed. This field
# The natural language speech audio to be processed. This field
# should be populated iff `query_input` is set to an input audio config.
# A single request can contain up to 1 minute of speech audio data.
class DetectIntentRequest; end
Expand Down Expand Up @@ -80,33 +88,33 @@ class DetectIntentResponse; end
# Represents the parameters of the conversational query.
# @!attribute [rw] time_zone
# @return [String]
# Optional. The time zone of this conversational query from the
# The time zone of this conversational query from the
# [time zone database](https://www.iana.org/time-zones), e.g.,
# America/New_York, Europe/Paris. If not provided, the time zone specified in
# agent settings is used.
# @!attribute [rw] geo_location
# @return [Google::Type::LatLng]
# Optional. The geo location of this conversational query.
# The geo location of this conversational query.
# @!attribute [rw] contexts
# @return [Array<Google::Cloud::Dialogflow::V2::Context>]
# Optional. The collection of contexts to be activated before this query is
# The collection of contexts to be activated before this query is
# executed.
# @!attribute [rw] reset_contexts
# @return [true, false]
# Optional. Specifies whether to delete all contexts in the current session
# Specifies whether to delete all contexts in the current session
# before the new ones are activated.
# @!attribute [rw] session_entity_types
# @return [Array<Google::Cloud::Dialogflow::V2::SessionEntityType>]
# Optional. Additional session entity types to replace or extend developer
# Additional session entity types to replace or extend developer
# entity types with. The entity synonyms apply to all languages and persist
# for the session of this query.
# @!attribute [rw] payload
# @return [Google::Protobuf::Struct]
# Optional. This field can be used to pass custom data into the webhook
# This field can be used to pass custom data into the webhook
# associated with the agent. Arbitrary JSON objects are supported.
# @!attribute [rw] sentiment_analysis_request_config
# @return [Google::Cloud::Dialogflow::V2::SentimentAnalysisRequestConfig]
# Optional. Configures the type of sentiment analysis to perform. If not
# Configures the type of sentiment analysis to perform. If not
# provided, sentiment analysis is not performed.
class QueryParameters; end

Expand Down Expand Up @@ -263,7 +271,7 @@ class QueryResult; end
# ID must not exceed 36 characters.
# @!attribute [rw] query_params
# @return [Google::Cloud::Dialogflow::V2::QueryParameters]
# Optional. The parameters of this query.
# The parameters of this query.
# @!attribute [rw] query_input
# @return [Google::Cloud::Dialogflow::V2::QueryInput]
# Required. The input specification. It can be set to:
Expand All @@ -276,7 +284,7 @@ class QueryResult; end
# 3. an event that specifies which intent to trigger.
# @!attribute [rw] single_utterance
# @return [true, false]
# Optional. Please use {Google::Cloud::Dialogflow::V2::InputAudioConfig#single_utterance InputAudioConfig#single_utterance} instead.
# Please use {Google::Cloud::Dialogflow::V2::InputAudioConfig#single_utterance InputAudioConfig#single_utterance} instead.
# If `false` (default), recognition does not cease until
# the client closes the stream. If `true`, the recognizer will detect a
# single spoken utterance in input audio. Recognition ceases when it detects
Expand All @@ -286,12 +294,20 @@ class QueryResult; end
# This setting is ignored when `query_input` is a piece of text or an event.
# @!attribute [rw] output_audio_config
# @return [Google::Cloud::Dialogflow::V2::OutputAudioConfig]
# Optional. Instructs the speech synthesizer how to generate the output
# Instructs the speech synthesizer how to generate the output
# audio. If this field is not set and agent-level speech synthesizer is not
# configured, no output audio is generated.
# @!attribute [rw] output_audio_config_mask
# @return [Google::Protobuf::FieldMask]
# Mask for {Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest#output_audio_config output_audio_config} indicating which settings in this
# request-level config should override speech synthesizer settings defined at
# agent-level.
#
# If unspecified or empty, {Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest#output_audio_config output_audio_config} replaces the agent-level
# config in its entirety.
# @!attribute [rw] input_audio
# @return [String]
# Optional. The input audio content to be recognized. Must be sent if
# The input audio content to be recognized. Must be sent if
# `query_input` was set to a streaming input audio config. The complete audio
# over all streaming messages must not exceed 1 minute.
class StreamingDetectIntentRequest; end
Expand Down Expand Up @@ -441,7 +457,7 @@ class TextInput; end
# Required. The unique identifier of the event.
# @!attribute [rw] parameters
# @return [Google::Protobuf::Struct]
# Optional. The collection of parameters associated with the event.
# The collection of parameters associated with the event.
# @!attribute [rw] language_code
# @return [String]
# Required. The language of this query. See [Language
Expand All @@ -453,7 +469,7 @@ class EventInput; end
# Configures the types of sentiment analysis to perform.
# @!attribute [rw] analyze_query_text_sentiment
# @return [true, false]
# Optional. Instructs the service to perform sentiment analysis on
# Instructs the service to perform sentiment analysis on
# `query_text`. If not provided, sentiment analysis is not performed on
# `query_text`.
class SentimentAnalysisRequestConfig; end
Expand Down
@@ -0,0 +1,71 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


module Google
module Cloud
module Dialogflow
module V2
# Represents a single validation error.
# @!attribute [rw] severity
# @return [Google::Cloud::Dialogflow::V2::ValidationError::Severity]
# The severity of the error.
# @!attribute [rw] entries
# @return [Array<String>]
# The names of the entries that the error is associated with.
# Format:
#
# * "projects/<Project ID>/agent", if the error is associated with the entire
# agent.
# * "projects/<Project ID>/agent/intents/<Intent ID>", if the error is
# associated with certain intents.
# * "projects/<Project
# ID>/agent/intents/<Intent Id>/trainingPhrases/<Training Phrase ID>", if the
# error is associated with certain intent training phrases.
# * "projects/<Project ID>/agent/intents/<Intent Id>/parameters/<Parameter
# ID>", if the error is associated with certain intent parameters.
# * "projects/<Project ID>/agent/entities/<Entity ID>", if the error is
# associated with certain entities.
# @!attribute [rw] error_message
# @return [String]
# The detailed error messsage.
class ValidationError
# Represents a level of severity.
module Severity
# Not specified. This value should never be used.
SEVERITY_UNSPECIFIED = 0

# The agent doesn't follow Dialogflow best practicies.
INFO = 1

# The agent may not behave as expected.
WARNING = 2

# The agent may experience partial failures.
ERROR = 3

# The agent may completely fail.
CRITICAL = 4
end
end

# Represents the output of agent validation.
# @!attribute [rw] validation_errors
# @return [Array<Google::Cloud::Dialogflow::V2::ValidationError>]
# Contains all validation errors.
class ValidationResult; end
end
end
end
end

0 comments on commit d54b072

Please sign in to comment.