google-cloud-discovery_engine-v1beta 0.14.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1beta/completion_service/client.rb +155 -0
  3. data/lib/google/cloud/discovery_engine/v1beta/completion_service/paths.rb +62 -0
  4. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/client.rb +148 -0
  5. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/service_stub.rb +76 -0
  6. data/lib/google/cloud/discovery_engine/v1beta/control_service/client.rb +6 -6
  7. data/lib/google/cloud/discovery_engine/v1beta/control_service/rest/client.rb +6 -6
  8. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/client.rb +18 -13
  9. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/client.rb +18 -13
  10. data/lib/google/cloud/discovery_engine/v1beta/document_service/client.rb +109 -1
  11. data/lib/google/cloud/discovery_engine/v1beta/document_service/paths.rb +25 -0
  12. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb +102 -1
  13. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/service_stub.rb +66 -0
  14. data/lib/google/cloud/discovery_engine/v1beta/engine_service/client.rb +3 -3
  15. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/client.rb +3 -3
  16. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/client.rb +218 -4
  17. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/paths.rb +85 -0
  18. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/client.rb +125 -4
  19. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/service_stub.rb +60 -0
  20. data/lib/google/cloud/discovery_engine/v1beta/rank_service/client.rb +1 -1
  21. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/client.rb +1 -1
  22. data/lib/google/cloud/discovery_engine/v1beta/search_service/client.rb +410 -4
  23. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/client.rb +402 -4
  24. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/service_stub.rb +76 -0
  25. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/client.rb +2 -2
  26. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/rest/client.rb +2 -2
  27. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/client.rb +324 -1
  28. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/paths.rb +49 -0
  29. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/rest/client.rb +303 -1
  30. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/rest/service_stub.rb +193 -0
  31. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/client.rb +1 -1
  32. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/client.rb +1 -1
  33. data/lib/google/cloud/discovery_engine/v1beta/version.rb +1 -1
  34. data/lib/google/cloud/discoveryengine/v1beta/answer_pb.rb +2 -1
  35. data/lib/google/cloud/discoveryengine/v1beta/common_pb.rb +1 -1
  36. data/lib/google/cloud/discoveryengine/v1beta/completion_service_pb.rb +18 -1
  37. data/lib/google/cloud/discoveryengine/v1beta/completion_service_services_pb.rb +2 -0
  38. data/lib/google/cloud/discoveryengine/v1beta/control_pb.rb +1 -1
  39. data/lib/google/cloud/discoveryengine/v1beta/conversational_search_service_pb.rb +4 -1
  40. data/lib/google/cloud/discoveryengine/v1beta/custom_tuning_model_pb.rb +1 -1
  41. data/lib/google/cloud/discoveryengine/v1beta/data_store_pb.rb +7 -1
  42. data/lib/google/cloud/discoveryengine/v1beta/document_pb.rb +4 -1
  43. data/lib/google/cloud/discoveryengine/v1beta/document_service_pb.rb +11 -1
  44. data/lib/google/cloud/discoveryengine/v1beta/document_service_services_pb.rb +4 -0
  45. data/lib/google/cloud/discoveryengine/v1beta/engine_pb.rb +1 -1
  46. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_pb.rb +24 -1
  47. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_services_pb.rb +4 -0
  48. data/lib/google/cloud/discoveryengine/v1beta/grounding_pb.rb +2 -1
  49. data/lib/google/cloud/discoveryengine/v1beta/import_config_pb.rb +1 -1
  50. data/lib/google/cloud/discoveryengine/v1beta/purge_config_pb.rb +5 -1
  51. data/lib/google/cloud/discoveryengine/v1beta/search_service_pb.rb +6 -1
  52. data/lib/google/cloud/discoveryengine/v1beta/search_service_services_pb.rb +14 -0
  53. data/lib/google/cloud/discoveryengine/v1beta/serving_config_pb.rb +2 -2
  54. data/lib/google/cloud/discoveryengine/v1beta/site_search_engine_pb.rb +2 -1
  55. data/lib/google/cloud/discoveryengine/v1beta/site_search_engine_service_pb.rb +10 -1
  56. data/lib/google/cloud/discoveryengine/v1beta/site_search_engine_service_services_pb.rb +7 -0
  57. data/lib/google/cloud/discoveryengine/v1beta/user_event_pb.rb +1 -1
  58. data/proto_docs/google/api/client.rb +20 -0
  59. data/proto_docs/google/cloud/discoveryengine/v1beta/answer.rb +68 -8
  60. data/proto_docs/google/cloud/discoveryengine/v1beta/completion_service.rb +268 -0
  61. data/proto_docs/google/cloud/discoveryengine/v1beta/control.rb +10 -1
  62. data/proto_docs/google/cloud/discoveryengine/v1beta/control_service.rb +6 -6
  63. data/proto_docs/google/cloud/discoveryengine/v1beta/conversational_search_service.rb +98 -15
  64. data/proto_docs/google/cloud/discoveryengine/v1beta/custom_tuning_model.rb +11 -3
  65. data/proto_docs/google/cloud/discoveryengine/v1beta/data_store.rb +131 -0
  66. data/proto_docs/google/cloud/discoveryengine/v1beta/document.rb +22 -0
  67. data/proto_docs/google/cloud/discoveryengine/v1beta/document_processing_config.rb +9 -5
  68. data/proto_docs/google/cloud/discoveryengine/v1beta/document_service.rb +123 -0
  69. data/proto_docs/google/cloud/discoveryengine/v1beta/engine.rb +5 -1
  70. data/proto_docs/google/cloud/discoveryengine/v1beta/engine_service.rb +4 -4
  71. data/proto_docs/google/cloud/discoveryengine/v1beta/grounded_generation_service.rb +398 -2
  72. data/proto_docs/google/cloud/discoveryengine/v1beta/grounding.rb +10 -0
  73. data/proto_docs/google/cloud/discoveryengine/v1beta/import_config.rb +13 -7
  74. data/proto_docs/google/cloud/discoveryengine/v1beta/project.rb +1 -1
  75. data/proto_docs/google/cloud/discoveryengine/v1beta/purge_config.rb +39 -1
  76. data/proto_docs/google/cloud/discoveryengine/v1beta/rank_service.rb +1 -1
  77. data/proto_docs/google/cloud/discoveryengine/v1beta/search_service.rb +175 -6
  78. data/proto_docs/google/cloud/discoveryengine/v1beta/serving_config.rb +16 -0
  79. data/proto_docs/google/cloud/discoveryengine/v1beta/serving_config_service.rb +2 -2
  80. data/proto_docs/google/cloud/discoveryengine/v1beta/site_search_engine.rb +17 -0
  81. data/proto_docs/google/cloud/discoveryengine/v1beta/site_search_engine_service.rb +147 -1
  82. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event.rb +13 -1
  83. metadata +3 -3
@@ -176,6 +176,120 @@ module Google
176
176
 
177
177
  # Service calls
178
178
 
179
+ ##
180
+ # Generates grounded content.
181
+ #
182
+ # @overload generate_grounded_content(request, options = nil)
183
+ # Pass arguments to `generate_grounded_content` via a request object, either of type
184
+ # {::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest} or an equivalent Hash.
185
+ #
186
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest, ::Hash]
187
+ # A request object representing the call parameters. Required. To specify no
188
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
189
+ # @param options [::Gapic::CallOptions, ::Hash]
190
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
191
+ #
192
+ # @overload generate_grounded_content(location: nil, system_instruction: nil, contents: nil, generation_spec: nil, grounding_spec: nil, user_labels: nil)
193
+ # Pass arguments to `generate_grounded_content` via keyword arguments. Note that at
194
+ # least one keyword argument is required. To specify no parameters, or to keep all
195
+ # the default parameter values, pass an empty Hash as a request object (see above).
196
+ #
197
+ # @param location [::String]
198
+ # Required. Location resource.
199
+ #
200
+ # Format: `projects/{project}/locations/{location}`.
201
+ # @param system_instruction [::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationContent, ::Hash]
202
+ # Content of the system instruction for the current API.
203
+ #
204
+ # These instructions will take priority over any other prompt instructions
205
+ # if the selected model is supporting them.
206
+ # @param contents [::Array<::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationContent, ::Hash>]
207
+ # Content of the current conversation with the model.
208
+ #
209
+ # For single-turn queries, this is a single instance. For multi-turn queries,
210
+ # this is a repeated field that contains conversation history + latest
211
+ # request.
212
+ # @param generation_spec [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest::GenerationSpec, ::Hash]
213
+ # Content generation specification.
214
+ # @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest::GroundingSpec, ::Hash]
215
+ # Grounding specification.
216
+ # @param user_labels [::Hash{::String => ::String}]
217
+ # The user labels applied to a resource must meet the following requirements:
218
+ #
219
+ # * Each resource can have multiple labels, up to a maximum of 64.
220
+ # * Each label must be a key-value pair.
221
+ # * Keys have a minimum length of 1 character and a maximum length of 63
222
+ # characters and cannot be empty. Values can be empty and have a maximum
223
+ # length of 63 characters.
224
+ # * Keys and values can contain only lowercase letters, numeric characters,
225
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
226
+ # international characters are allowed.
227
+ # * The key portion of a label must be unique. However, you can use the same
228
+ # key with multiple resources.
229
+ # * Keys must start with a lowercase letter or international character.
230
+ #
231
+ # See [Google Cloud
232
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
233
+ # for more details.
234
+ # @yield [result, operation] Access the result along with the TransportOperation object
235
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
236
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
237
+ #
238
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
239
+ #
240
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
241
+ #
242
+ # @example Basic example
243
+ # require "google/cloud/discovery_engine/v1beta"
244
+ #
245
+ # # Create a client object. The client can be reused for multiple calls.
246
+ # client = Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Rest::Client.new
247
+ #
248
+ # # Create a request. To set request fields, pass in keyword arguments.
249
+ # request = Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest.new
250
+ #
251
+ # # Call the generate_grounded_content method.
252
+ # result = client.generate_grounded_content request
253
+ #
254
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse.
255
+ # p result
256
+ #
257
+ def generate_grounded_content request, options = nil
258
+ raise ::ArgumentError, "request must be provided" if request.nil?
259
+
260
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest
261
+
262
+ # Converts hash and nil to an options object
263
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
264
+
265
+ # Customize the options with defaults
266
+ call_metadata = @config.rpcs.generate_grounded_content.metadata.to_h
267
+
268
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
269
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
270
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
271
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION,
272
+ transports_version_send: [:rest]
273
+
274
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
275
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
276
+
277
+ options.apply_defaults timeout: @config.rpcs.generate_grounded_content.timeout,
278
+ metadata: call_metadata,
279
+ retry_policy: @config.rpcs.generate_grounded_content.retry_policy
280
+
281
+ options.apply_defaults timeout: @config.timeout,
282
+ metadata: @config.metadata,
283
+ retry_policy: @config.retry_policy
284
+
285
+ @grounded_generation_service_stub.generate_grounded_content request, options do |result, operation|
286
+ yield result, operation if block_given?
287
+ return result
288
+ end
289
+ rescue ::Gapic::Rest::Error => e
290
+ raise ::Google::Cloud::Error.from_error(e)
291
+ end
292
+
179
293
  ##
180
294
  # Performs a grounding check.
181
295
  #
@@ -198,7 +312,7 @@ module Google
198
312
  # Required. The resource name of the grounding config, such as
199
313
  # `projects/*/locations/global/groundingConfigs/default_grounding_config`.
200
314
  # @param answer_candidate [::String]
201
- # Answer candidate to check. Can have a maximum length of 1024 characters.
315
+ # Answer candidate to check. It can have a maximum length of 4096 tokens.
202
316
  # @param facts [::Array<::Google::Cloud::DiscoveryEngine::V1beta::GroundingFact, ::Hash>]
203
317
  # List of facts for the grounding check.
204
318
  # We support up to 200 facts.
@@ -297,17 +411,17 @@ module Google
297
411
  # @example
298
412
  #
299
413
  # # Modify the global config, setting the timeout for
300
- # # check_grounding to 20 seconds,
414
+ # # generate_grounded_content to 20 seconds,
301
415
  # # and all remaining timeouts to 10 seconds.
302
416
  # ::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Rest::Client.configure do |config|
303
417
  # config.timeout = 10.0
304
- # config.rpcs.check_grounding.timeout = 20.0
418
+ # config.rpcs.generate_grounded_content.timeout = 20.0
305
419
  # end
306
420
  #
307
421
  # # Apply the above configuration only to a new client.
308
422
  # client = ::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Rest::Client.new do |config|
309
423
  # config.timeout = 10.0
310
- # config.rpcs.check_grounding.timeout = 20.0
424
+ # config.rpcs.generate_grounded_content.timeout = 20.0
311
425
  # end
312
426
  #
313
427
  # @!attribute [rw] endpoint
@@ -414,6 +528,11 @@ module Google
414
528
  # trigger a retry.
415
529
  #
416
530
  class Rpcs
531
+ ##
532
+ # RPC-specific configuration for `generate_grounded_content`
533
+ # @return [::Gapic::Config::Method]
534
+ #
535
+ attr_reader :generate_grounded_content
417
536
  ##
418
537
  # RPC-specific configuration for `check_grounding`
419
538
  # @return [::Gapic::Config::Method]
@@ -422,6 +541,8 @@ module Google
422
541
 
423
542
  # @private
424
543
  def initialize parent_rpcs = nil
544
+ generate_grounded_content_config = parent_rpcs.generate_grounded_content if parent_rpcs.respond_to? :generate_grounded_content
545
+ @generate_grounded_content = ::Gapic::Config::Method.new generate_grounded_content_config
425
546
  check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
426
547
  @check_grounding = ::Gapic::Config::Method.new check_grounding_config
427
548
 
@@ -61,6 +61,44 @@ module Google
61
61
  @client_stub.endpoint
62
62
  end
63
63
 
64
+ ##
65
+ # Baseline implementation for the generate_grounded_content REST call
66
+ #
67
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest]
68
+ # A request object representing the call parameters. Required.
69
+ # @param options [::Gapic::CallOptions]
70
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
71
+ #
72
+ # @yield [result, operation] Access the result along with the TransportOperation object
73
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
74
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
75
+ #
76
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
77
+ # A result object deserialized from the server's reply
78
+ def generate_grounded_content request_pb, options = nil
79
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
80
+
81
+ verb, uri, query_string_params, body = ServiceStub.transcode_generate_grounded_content_request request_pb
82
+ query_string_params = if query_string_params.any?
83
+ query_string_params.to_h { |p| p.split "=", 2 }
84
+ else
85
+ {}
86
+ end
87
+
88
+ response = @client_stub.make_http_request(
89
+ verb,
90
+ uri: uri,
91
+ body: body || "",
92
+ params: query_string_params,
93
+ options: options
94
+ )
95
+ operation = ::Gapic::Rest::TransportOperation.new response
96
+ result = ::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse.decode_json response.body, ignore_unknown_fields: true
97
+
98
+ yield result, operation if block_given?
99
+ result
100
+ end
101
+
64
102
  ##
65
103
  # Baseline implementation for the check_grounding REST call
66
104
  #
@@ -99,6 +137,28 @@ module Google
99
137
  result
100
138
  end
101
139
 
140
+ ##
141
+ # @private
142
+ #
143
+ # GRPC transcoding helper method for the generate_grounded_content REST call
144
+ #
145
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest]
146
+ # A request object representing the call parameters. Required.
147
+ # @return [Array(String, [String, nil], Hash{String => String})]
148
+ # Uri, Body, Query string parameters
149
+ def self.transcode_generate_grounded_content_request request_pb
150
+ transcoder = Gapic::Rest::GrpcTranscoder.new
151
+ .with_bindings(
152
+ uri_method: :post,
153
+ uri_template: "/v1beta/{location}:generateGroundedContent",
154
+ body: "*",
155
+ matches: [
156
+ ["location", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
157
+ ]
158
+ )
159
+ transcoder.transcode request_pb
160
+ end
161
+
102
162
  ##
103
163
  # @private
104
164
  #
@@ -203,7 +203,7 @@ module Google
203
203
  #
204
204
  # @param ranking_config [::String]
205
205
  # Required. The resource name of the rank service config, such as
206
- # `projects/{project_num}/locations/{location_id}/rankingConfigs/default_ranking_config`.
206
+ # `projects/{project_num}/locations/{location}/rankingConfigs/default_ranking_config`.
207
207
  # @param model [::String]
208
208
  # The identifier of the model to use. It is one of:
209
209
  #
@@ -196,7 +196,7 @@ module Google
196
196
  #
197
197
  # @param ranking_config [::String]
198
198
  # Required. The resource name of the rank service config, such as
199
- # `projects/{project_num}/locations/{location_id}/rankingConfigs/default_ranking_config`.
199
+ # `projects/{project_num}/locations/{location}/rankingConfigs/default_ranking_config`.
200
200
  # @param model [::String]
201
201
  # The identifier of the model to use. It is one of:
202
202
  #