google-cloud-dialogflow 0.14.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/AUTHENTICATION.md +51 -59
- data/LICENSE.md +203 -0
- data/MIGRATING.md +445 -0
- data/README.md +35 -25
- data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
- data/lib/google/cloud/dialogflow.rb +256 -506
- data/lib/google/cloud/dialogflow/version.rb +1 -1
- metadata +63 -86
- data/LICENSE +0 -201
- data/lib/google/cloud/dialogflow/v2.rb +0 -598
- data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -121
- data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -111
- data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -807
- data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -71
- data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
- data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
- data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -75
- data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -519
- data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
- data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -247
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -498
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/validation_result.rb +0 -71
- data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
- data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -105
- data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -994
- data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
- data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
- data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -93
- data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -760
- data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
- data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
- data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -93
- data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -504
- data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
- data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -141
- data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -56
- data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -337
- data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
- data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +0 -36
- data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
@@ -1,51 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"interfaces": {
|
3
|
-
"google.cloud.dialogflow.v2.SessionEntityTypes": {
|
4
|
-
"retry_codes": {
|
5
|
-
"idempotent": [
|
6
|
-
"DEADLINE_EXCEEDED",
|
7
|
-
"UNAVAILABLE"
|
8
|
-
],
|
9
|
-
"non_idempotent": []
|
10
|
-
},
|
11
|
-
"retry_params": {
|
12
|
-
"default": {
|
13
|
-
"initial_retry_delay_millis": 100,
|
14
|
-
"retry_delay_multiplier": 1.3,
|
15
|
-
"max_retry_delay_millis": 60000,
|
16
|
-
"initial_rpc_timeout_millis": 20000,
|
17
|
-
"rpc_timeout_multiplier": 1.0,
|
18
|
-
"max_rpc_timeout_millis": 20000,
|
19
|
-
"total_timeout_millis": 600000
|
20
|
-
}
|
21
|
-
},
|
22
|
-
"methods": {
|
23
|
-
"ListSessionEntityTypes": {
|
24
|
-
"timeout_millis": 60000,
|
25
|
-
"retry_codes_name": "idempotent",
|
26
|
-
"retry_params_name": "default"
|
27
|
-
},
|
28
|
-
"GetSessionEntityType": {
|
29
|
-
"timeout_millis": 60000,
|
30
|
-
"retry_codes_name": "idempotent",
|
31
|
-
"retry_params_name": "default"
|
32
|
-
},
|
33
|
-
"CreateSessionEntityType": {
|
34
|
-
"timeout_millis": 60000,
|
35
|
-
"retry_codes_name": "non_idempotent",
|
36
|
-
"retry_params_name": "default"
|
37
|
-
},
|
38
|
-
"UpdateSessionEntityType": {
|
39
|
-
"timeout_millis": 60000,
|
40
|
-
"retry_codes_name": "non_idempotent",
|
41
|
-
"retry_params_name": "default"
|
42
|
-
},
|
43
|
-
"DeleteSessionEntityType": {
|
44
|
-
"timeout_millis": 60000,
|
45
|
-
"retry_codes_name": "idempotent",
|
46
|
-
"retry_params_name": "default"
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
}
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
-
# source: google/cloud/dialogflow/v2/session.proto
|
3
|
-
|
4
|
-
|
5
|
-
require 'google/protobuf'
|
6
|
-
|
7
|
-
require 'google/api/annotations_pb'
|
8
|
-
require 'google/api/client_pb'
|
9
|
-
require 'google/api/field_behavior_pb'
|
10
|
-
require 'google/api/resource_pb'
|
11
|
-
require 'google/cloud/dialogflow/v2/audio_config_pb'
|
12
|
-
require 'google/cloud/dialogflow/v2/context_pb'
|
13
|
-
require 'google/cloud/dialogflow/v2/intent_pb'
|
14
|
-
require 'google/cloud/dialogflow/v2/session_entity_type_pb'
|
15
|
-
require 'google/protobuf/duration_pb'
|
16
|
-
require 'google/protobuf/field_mask_pb'
|
17
|
-
require 'google/protobuf/struct_pb'
|
18
|
-
require 'google/rpc/status_pb'
|
19
|
-
require 'google/type/latlng_pb'
|
20
|
-
Google::Protobuf::DescriptorPool.generated_pool.build do
|
21
|
-
add_message "google.cloud.dialogflow.v2.DetectIntentRequest" do
|
22
|
-
optional :session, :string, 1
|
23
|
-
optional :query_params, :message, 2, "google.cloud.dialogflow.v2.QueryParameters"
|
24
|
-
optional :query_input, :message, 3, "google.cloud.dialogflow.v2.QueryInput"
|
25
|
-
optional :output_audio_config, :message, 4, "google.cloud.dialogflow.v2.OutputAudioConfig"
|
26
|
-
optional :output_audio_config_mask, :message, 7, "google.protobuf.FieldMask"
|
27
|
-
optional :input_audio, :bytes, 5
|
28
|
-
end
|
29
|
-
add_message "google.cloud.dialogflow.v2.DetectIntentResponse" do
|
30
|
-
optional :response_id, :string, 1
|
31
|
-
optional :query_result, :message, 2, "google.cloud.dialogflow.v2.QueryResult"
|
32
|
-
optional :webhook_status, :message, 3, "google.rpc.Status"
|
33
|
-
optional :output_audio, :bytes, 4
|
34
|
-
optional :output_audio_config, :message, 6, "google.cloud.dialogflow.v2.OutputAudioConfig"
|
35
|
-
end
|
36
|
-
add_message "google.cloud.dialogflow.v2.QueryParameters" do
|
37
|
-
optional :time_zone, :string, 1
|
38
|
-
optional :geo_location, :message, 2, "google.type.LatLng"
|
39
|
-
repeated :contexts, :message, 3, "google.cloud.dialogflow.v2.Context"
|
40
|
-
optional :reset_contexts, :bool, 4
|
41
|
-
repeated :session_entity_types, :message, 5, "google.cloud.dialogflow.v2.SessionEntityType"
|
42
|
-
optional :payload, :message, 6, "google.protobuf.Struct"
|
43
|
-
optional :sentiment_analysis_request_config, :message, 10, "google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig"
|
44
|
-
end
|
45
|
-
add_message "google.cloud.dialogflow.v2.QueryInput" do
|
46
|
-
oneof :input do
|
47
|
-
optional :audio_config, :message, 1, "google.cloud.dialogflow.v2.InputAudioConfig"
|
48
|
-
optional :text, :message, 2, "google.cloud.dialogflow.v2.TextInput"
|
49
|
-
optional :event, :message, 3, "google.cloud.dialogflow.v2.EventInput"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
add_message "google.cloud.dialogflow.v2.QueryResult" do
|
53
|
-
optional :query_text, :string, 1
|
54
|
-
optional :language_code, :string, 15
|
55
|
-
optional :speech_recognition_confidence, :float, 2
|
56
|
-
optional :action, :string, 3
|
57
|
-
optional :parameters, :message, 4, "google.protobuf.Struct"
|
58
|
-
optional :all_required_params_present, :bool, 5
|
59
|
-
optional :fulfillment_text, :string, 6
|
60
|
-
repeated :fulfillment_messages, :message, 7, "google.cloud.dialogflow.v2.Intent.Message"
|
61
|
-
optional :webhook_source, :string, 8
|
62
|
-
optional :webhook_payload, :message, 9, "google.protobuf.Struct"
|
63
|
-
repeated :output_contexts, :message, 10, "google.cloud.dialogflow.v2.Context"
|
64
|
-
optional :intent, :message, 11, "google.cloud.dialogflow.v2.Intent"
|
65
|
-
optional :intent_detection_confidence, :float, 12
|
66
|
-
optional :diagnostic_info, :message, 14, "google.protobuf.Struct"
|
67
|
-
optional :sentiment_analysis_result, :message, 17, "google.cloud.dialogflow.v2.SentimentAnalysisResult"
|
68
|
-
end
|
69
|
-
add_message "google.cloud.dialogflow.v2.StreamingDetectIntentRequest" do
|
70
|
-
optional :session, :string, 1
|
71
|
-
optional :query_params, :message, 2, "google.cloud.dialogflow.v2.QueryParameters"
|
72
|
-
optional :query_input, :message, 3, "google.cloud.dialogflow.v2.QueryInput"
|
73
|
-
optional :single_utterance, :bool, 4
|
74
|
-
optional :output_audio_config, :message, 5, "google.cloud.dialogflow.v2.OutputAudioConfig"
|
75
|
-
optional :output_audio_config_mask, :message, 7, "google.protobuf.FieldMask"
|
76
|
-
optional :input_audio, :bytes, 6
|
77
|
-
end
|
78
|
-
add_message "google.cloud.dialogflow.v2.StreamingDetectIntentResponse" do
|
79
|
-
optional :response_id, :string, 1
|
80
|
-
optional :recognition_result, :message, 2, "google.cloud.dialogflow.v2.StreamingRecognitionResult"
|
81
|
-
optional :query_result, :message, 3, "google.cloud.dialogflow.v2.QueryResult"
|
82
|
-
optional :webhook_status, :message, 4, "google.rpc.Status"
|
83
|
-
optional :output_audio, :bytes, 5
|
84
|
-
optional :output_audio_config, :message, 6, "google.cloud.dialogflow.v2.OutputAudioConfig"
|
85
|
-
end
|
86
|
-
add_message "google.cloud.dialogflow.v2.StreamingRecognitionResult" do
|
87
|
-
optional :message_type, :enum, 1, "google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType"
|
88
|
-
optional :transcript, :string, 2
|
89
|
-
optional :is_final, :bool, 3
|
90
|
-
optional :confidence, :float, 4
|
91
|
-
repeated :speech_word_info, :message, 7, "google.cloud.dialogflow.v2.SpeechWordInfo"
|
92
|
-
optional :speech_end_offset, :message, 8, "google.protobuf.Duration"
|
93
|
-
end
|
94
|
-
add_enum "google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType" do
|
95
|
-
value :MESSAGE_TYPE_UNSPECIFIED, 0
|
96
|
-
value :TRANSCRIPT, 1
|
97
|
-
value :END_OF_SINGLE_UTTERANCE, 2
|
98
|
-
end
|
99
|
-
add_message "google.cloud.dialogflow.v2.TextInput" do
|
100
|
-
optional :text, :string, 1
|
101
|
-
optional :language_code, :string, 2
|
102
|
-
end
|
103
|
-
add_message "google.cloud.dialogflow.v2.EventInput" do
|
104
|
-
optional :name, :string, 1
|
105
|
-
optional :parameters, :message, 2, "google.protobuf.Struct"
|
106
|
-
optional :language_code, :string, 3
|
107
|
-
end
|
108
|
-
add_message "google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig" do
|
109
|
-
optional :analyze_query_text_sentiment, :bool, 1
|
110
|
-
end
|
111
|
-
add_message "google.cloud.dialogflow.v2.SentimentAnalysisResult" do
|
112
|
-
optional :query_text_sentiment, :message, 1, "google.cloud.dialogflow.v2.Sentiment"
|
113
|
-
end
|
114
|
-
add_message "google.cloud.dialogflow.v2.Sentiment" do
|
115
|
-
optional :score, :float, 1
|
116
|
-
optional :magnitude, :float, 2
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
module Google
|
121
|
-
module Cloud
|
122
|
-
module Dialogflow
|
123
|
-
module V2
|
124
|
-
DetectIntentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DetectIntentRequest").msgclass
|
125
|
-
DetectIntentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DetectIntentResponse").msgclass
|
126
|
-
QueryParameters = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryParameters").msgclass
|
127
|
-
QueryInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryInput").msgclass
|
128
|
-
QueryResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryResult").msgclass
|
129
|
-
StreamingDetectIntentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingDetectIntentRequest").msgclass
|
130
|
-
StreamingDetectIntentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingDetectIntentResponse").msgclass
|
131
|
-
StreamingRecognitionResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingRecognitionResult").msgclass
|
132
|
-
StreamingRecognitionResult::MessageType = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType").enummodule
|
133
|
-
TextInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.TextInput").msgclass
|
134
|
-
EventInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EventInput").msgclass
|
135
|
-
SentimentAnalysisRequestConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig").msgclass
|
136
|
-
SentimentAnalysisResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SentimentAnalysisResult").msgclass
|
137
|
-
Sentiment = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Sentiment").msgclass
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
-
# Source: google/cloud/dialogflow/v2/session.proto for package 'google.cloud.dialogflow.v2'
|
3
|
-
# Original file comments:
|
4
|
-
# Copyright 2020 Google LLC
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
require 'grpc'
|
21
|
-
require 'google/cloud/dialogflow/v2/session_pb'
|
22
|
-
|
23
|
-
module Google
|
24
|
-
module Cloud
|
25
|
-
module Dialogflow
|
26
|
-
module V2
|
27
|
-
module Sessions
|
28
|
-
# A session represents an interaction with a user. You retrieve user input
|
29
|
-
# and pass it to the [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
|
30
|
-
# [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method to determine
|
31
|
-
# user intent and respond.
|
32
|
-
class Service
|
33
|
-
|
34
|
-
include GRPC::GenericService
|
35
|
-
|
36
|
-
self.marshal_class_method = :encode
|
37
|
-
self.unmarshal_class_method = :decode
|
38
|
-
self.service_name = 'google.cloud.dialogflow.v2.Sessions'
|
39
|
-
|
40
|
-
# Processes a natural language query and returns structured, actionable data
|
41
|
-
# as a result. This method is not idempotent, because it may cause contexts
|
42
|
-
# and session entity types to be updated, which in turn might affect
|
43
|
-
# results of future queries.
|
44
|
-
rpc :DetectIntent, DetectIntentRequest, DetectIntentResponse
|
45
|
-
# Processes a natural language query in audio format in a streaming fashion
|
46
|
-
# and returns structured, actionable data as a result. This method is only
|
47
|
-
# available via the gRPC API (not REST).
|
48
|
-
rpc :StreamingDetectIntent, stream(StreamingDetectIntentRequest), stream(StreamingDetectIntentResponse)
|
49
|
-
end
|
50
|
-
|
51
|
-
Stub = Service.rpc_stub_class
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,337 +0,0 @@
|
|
1
|
-
# Copyright 2020 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#
|
15
|
-
# EDITING INSTRUCTIONS
|
16
|
-
# This file was generated from the file
|
17
|
-
# https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/v2/session.proto,
|
18
|
-
# and updates to that file get reflected here through a refresh process.
|
19
|
-
# For the short term, the refresh process will only be runnable by Google
|
20
|
-
# engineers.
|
21
|
-
|
22
|
-
|
23
|
-
require "json"
|
24
|
-
require "pathname"
|
25
|
-
|
26
|
-
require "google/gax"
|
27
|
-
|
28
|
-
require "google/cloud/dialogflow/v2/session_pb"
|
29
|
-
require "google/cloud/dialogflow/v2/credentials"
|
30
|
-
require "google/cloud/dialogflow/version"
|
31
|
-
|
32
|
-
module Google
|
33
|
-
module Cloud
|
34
|
-
module Dialogflow
|
35
|
-
module V2
|
36
|
-
# A session represents an interaction with a user. You retrieve user input
|
37
|
-
# and pass it to the {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
|
38
|
-
# {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) method to determine
|
39
|
-
# user intent and respond.
|
40
|
-
#
|
41
|
-
# @!attribute [r] sessions_stub
|
42
|
-
# @return [Google::Cloud::Dialogflow::V2::Sessions::Stub]
|
43
|
-
class SessionsClient
|
44
|
-
# @private
|
45
|
-
attr_reader :sessions_stub
|
46
|
-
|
47
|
-
# The default address of the service.
|
48
|
-
SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
|
49
|
-
|
50
|
-
# The default port of the service.
|
51
|
-
DEFAULT_SERVICE_PORT = 443
|
52
|
-
|
53
|
-
# The default set of gRPC interceptors.
|
54
|
-
GRPC_INTERCEPTORS = []
|
55
|
-
|
56
|
-
DEFAULT_TIMEOUT = 30
|
57
|
-
|
58
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
59
|
-
# this service.
|
60
|
-
ALL_SCOPES = [
|
61
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
62
|
-
"https://www.googleapis.com/auth/dialogflow"
|
63
|
-
].freeze
|
64
|
-
|
65
|
-
|
66
|
-
SESSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
67
|
-
"projects/{project}/agent/sessions/{session}"
|
68
|
-
)
|
69
|
-
|
70
|
-
private_constant :SESSION_PATH_TEMPLATE
|
71
|
-
|
72
|
-
# Returns a fully-qualified session resource name string.
|
73
|
-
# @param project [String]
|
74
|
-
# @param session [String]
|
75
|
-
# @return [String]
|
76
|
-
def self.session_path project, session
|
77
|
-
SESSION_PATH_TEMPLATE.render(
|
78
|
-
:"project" => project,
|
79
|
-
:"session" => session
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
84
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
85
|
-
# be many types.
|
86
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
87
|
-
# authenticating requests made by this client.
|
88
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
89
|
-
# credentials for this client.
|
90
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
91
|
-
# credentials for this client.
|
92
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
93
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
94
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
95
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
96
|
-
# metadata for requests, generally, to give OAuth credentials.
|
97
|
-
# @param scopes [Array<String>]
|
98
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
99
|
-
# an updater_proc is supplied.
|
100
|
-
# @param client_config [Hash]
|
101
|
-
# A Hash for call options for each method. See
|
102
|
-
# Google::Gax#construct_settings for the structure of
|
103
|
-
# this data. Falls back to the default config if not specified
|
104
|
-
# or the specified config is missing data points.
|
105
|
-
# @param timeout [Numeric]
|
106
|
-
# The default timeout, in seconds, for calls made through this client.
|
107
|
-
# @param metadata [Hash]
|
108
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
109
|
-
# @param service_address [String]
|
110
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
111
|
-
# @param service_port [Integer]
|
112
|
-
# Override for the service port, or `nil` to leave as the default.
|
113
|
-
# @param exception_transformer [Proc]
|
114
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
115
|
-
# custom error handling.
|
116
|
-
def initialize \
|
117
|
-
credentials: nil,
|
118
|
-
scopes: ALL_SCOPES,
|
119
|
-
client_config: {},
|
120
|
-
timeout: DEFAULT_TIMEOUT,
|
121
|
-
metadata: nil,
|
122
|
-
service_address: nil,
|
123
|
-
service_port: nil,
|
124
|
-
exception_transformer: nil,
|
125
|
-
lib_name: nil,
|
126
|
-
lib_version: ""
|
127
|
-
# These require statements are intentionally placed here to initialize
|
128
|
-
# the gRPC module only when it's required.
|
129
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
130
|
-
require "google/gax/grpc"
|
131
|
-
require "google/cloud/dialogflow/v2/session_services_pb"
|
132
|
-
|
133
|
-
credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
|
134
|
-
|
135
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
136
|
-
updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
|
137
|
-
end
|
138
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
139
|
-
channel = credentials
|
140
|
-
end
|
141
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
142
|
-
chan_creds = credentials
|
143
|
-
end
|
144
|
-
if credentials.is_a?(Proc)
|
145
|
-
updater_proc = credentials
|
146
|
-
end
|
147
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
148
|
-
updater_proc = credentials.updater_proc
|
149
|
-
end
|
150
|
-
|
151
|
-
package_version = Google::Cloud::Dialogflow::VERSION
|
152
|
-
|
153
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
154
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
155
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
156
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
157
|
-
google_api_client.freeze
|
158
|
-
|
159
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
160
|
-
headers.merge!(metadata) unless metadata.nil?
|
161
|
-
client_config_file = Pathname.new(__dir__).join(
|
162
|
-
"sessions_client_config.json"
|
163
|
-
)
|
164
|
-
defaults = client_config_file.open do |f|
|
165
|
-
Google::Gax.construct_settings(
|
166
|
-
"google.cloud.dialogflow.v2.Sessions",
|
167
|
-
JSON.parse(f.read),
|
168
|
-
client_config,
|
169
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
170
|
-
timeout,
|
171
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
172
|
-
metadata: headers
|
173
|
-
)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Allow overriding the service path/port in subclasses.
|
177
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
178
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
179
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
180
|
-
@sessions_stub = Google::Gax::Grpc.create_stub(
|
181
|
-
service_path,
|
182
|
-
port,
|
183
|
-
chan_creds: chan_creds,
|
184
|
-
channel: channel,
|
185
|
-
updater_proc: updater_proc,
|
186
|
-
scopes: scopes,
|
187
|
-
interceptors: interceptors,
|
188
|
-
&Google::Cloud::Dialogflow::V2::Sessions::Stub.method(:new)
|
189
|
-
)
|
190
|
-
|
191
|
-
@detect_intent = Google::Gax.create_api_call(
|
192
|
-
@sessions_stub.method(:detect_intent),
|
193
|
-
defaults["detect_intent"],
|
194
|
-
exception_transformer: exception_transformer,
|
195
|
-
params_extractor: proc do |request|
|
196
|
-
{'session' => request.session}
|
197
|
-
end
|
198
|
-
)
|
199
|
-
@streaming_detect_intent = Google::Gax.create_api_call(
|
200
|
-
@sessions_stub.method(:streaming_detect_intent),
|
201
|
-
defaults["streaming_detect_intent"],
|
202
|
-
exception_transformer: exception_transformer
|
203
|
-
)
|
204
|
-
end
|
205
|
-
|
206
|
-
# Service calls
|
207
|
-
|
208
|
-
# Processes a natural language query and returns structured, actionable data
|
209
|
-
# as a result. This method is not idempotent, because it may cause contexts
|
210
|
-
# and session entity types to be updated, which in turn might affect
|
211
|
-
# results of future queries.
|
212
|
-
#
|
213
|
-
# @param session [String]
|
214
|
-
# Required. The name of the session this query is sent to. Format:
|
215
|
-
# `projects/<Project ID>/agent/sessions/<Session ID>`. It's up to the API
|
216
|
-
# caller to choose an appropriate session ID. It can be a random number or
|
217
|
-
# some type of user identifier (preferably hashed). The length of the session
|
218
|
-
# ID must not exceed 36 bytes.
|
219
|
-
# @param query_input [Google::Cloud::Dialogflow::V2::QueryInput | Hash]
|
220
|
-
# Required. The input specification. It can be set to:
|
221
|
-
#
|
222
|
-
# 1. an audio config
|
223
|
-
# which instructs the speech recognizer how to process the speech audio,
|
224
|
-
#
|
225
|
-
# 2. a conversational query in the form of text, or
|
226
|
-
#
|
227
|
-
# 3. an event that specifies which intent to trigger.
|
228
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::QueryInput`
|
229
|
-
# can also be provided.
|
230
|
-
# @param query_params [Google::Cloud::Dialogflow::V2::QueryParameters | Hash]
|
231
|
-
# The parameters of this query.
|
232
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::QueryParameters`
|
233
|
-
# can also be provided.
|
234
|
-
# @param output_audio_config [Google::Cloud::Dialogflow::V2::OutputAudioConfig | Hash]
|
235
|
-
# Instructs the speech synthesizer how to generate the output
|
236
|
-
# audio. If this field is not set and agent-level speech synthesizer is not
|
237
|
-
# configured, no output audio is generated.
|
238
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::OutputAudioConfig`
|
239
|
-
# can also be provided.
|
240
|
-
# @param output_audio_config_mask [Google::Protobuf::FieldMask | Hash]
|
241
|
-
# Mask for {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} indicating which settings in this
|
242
|
-
# request-level config should override speech synthesizer settings defined at
|
243
|
-
# agent-level.
|
244
|
-
#
|
245
|
-
# If unspecified or empty, {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} replaces the agent-level
|
246
|
-
# config in its entirety.
|
247
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
248
|
-
# can also be provided.
|
249
|
-
# @param input_audio [String]
|
250
|
-
# The natural language speech audio to be processed. This field
|
251
|
-
# should be populated iff `query_input` is set to an input audio config.
|
252
|
-
# A single request can contain up to 1 minute of speech audio data.
|
253
|
-
# @param options [Google::Gax::CallOptions]
|
254
|
-
# Overrides the default settings for this call, e.g, timeout,
|
255
|
-
# retries, etc.
|
256
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
257
|
-
# @yieldparam result [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
|
258
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
259
|
-
# @return [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
|
260
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
261
|
-
# @example
|
262
|
-
# require "google/cloud/dialogflow"
|
263
|
-
#
|
264
|
-
# sessions_client = Google::Cloud::Dialogflow::Sessions.new(version: :v2)
|
265
|
-
# formatted_session = Google::Cloud::Dialogflow::V2::SessionsClient.session_path("[PROJECT]", "[SESSION]")
|
266
|
-
#
|
267
|
-
# # TODO: Initialize `query_input`:
|
268
|
-
# query_input = {}
|
269
|
-
# response = sessions_client.detect_intent(formatted_session, query_input)
|
270
|
-
|
271
|
-
def detect_intent \
|
272
|
-
session,
|
273
|
-
query_input,
|
274
|
-
query_params: nil,
|
275
|
-
output_audio_config: nil,
|
276
|
-
output_audio_config_mask: nil,
|
277
|
-
input_audio: nil,
|
278
|
-
options: nil,
|
279
|
-
&block
|
280
|
-
req = {
|
281
|
-
session: session,
|
282
|
-
query_input: query_input,
|
283
|
-
query_params: query_params,
|
284
|
-
output_audio_config: output_audio_config,
|
285
|
-
output_audio_config_mask: output_audio_config_mask,
|
286
|
-
input_audio: input_audio
|
287
|
-
}.delete_if { |_, v| v.nil? }
|
288
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DetectIntentRequest)
|
289
|
-
@detect_intent.call(req, options, &block)
|
290
|
-
end
|
291
|
-
|
292
|
-
# Processes a natural language query in audio format in a streaming fashion
|
293
|
-
# and returns structured, actionable data as a result. This method is only
|
294
|
-
# available via the gRPC API (not REST).
|
295
|
-
#
|
296
|
-
# @param reqs [Enumerable<Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest>]
|
297
|
-
# The input requests.
|
298
|
-
# @param options [Google::Gax::CallOptions]
|
299
|
-
# Overrides the default settings for this call, e.g, timeout,
|
300
|
-
# retries, etc.
|
301
|
-
# @return [Enumerable<Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse>]
|
302
|
-
# An enumerable of Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse instances.
|
303
|
-
#
|
304
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
305
|
-
#
|
306
|
-
# @note
|
307
|
-
# EXPERIMENTAL:
|
308
|
-
# Streaming requests are still undergoing review.
|
309
|
-
# This method interface might change in the future.
|
310
|
-
#
|
311
|
-
# @example
|
312
|
-
# require "google/cloud/dialogflow"
|
313
|
-
#
|
314
|
-
# sessions_client = Google::Cloud::Dialogflow::Sessions.new(version: :v2)
|
315
|
-
#
|
316
|
-
# # TODO: Initialize `session`:
|
317
|
-
# session = ''
|
318
|
-
#
|
319
|
-
# # TODO: Initialize `query_input`:
|
320
|
-
# query_input = {}
|
321
|
-
# request = { session: session, query_input: query_input }
|
322
|
-
# requests = [request]
|
323
|
-
# sessions_client.streaming_detect_intent(requests).each do |element|
|
324
|
-
# # Process element.
|
325
|
-
# end
|
326
|
-
|
327
|
-
def streaming_detect_intent reqs, options: nil
|
328
|
-
request_protos = reqs.lazy.map do |req|
|
329
|
-
Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest)
|
330
|
-
end
|
331
|
-
@streaming_detect_intent.call(request_protos, options)
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|