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
@@ -327,6 +327,44 @@ module Google
327
327
  result
328
328
  end
329
329
 
330
+ ##
331
+ # Baseline implementation for the batch_get_documents_metadata REST call
332
+ #
333
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::BatchGetDocumentsMetadataRequest]
334
+ # A request object representing the call parameters. Required.
335
+ # @param options [::Gapic::CallOptions]
336
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
337
+ #
338
+ # @yield [result, operation] Access the result along with the TransportOperation object
339
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::BatchGetDocumentsMetadataResponse]
340
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
341
+ #
342
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::BatchGetDocumentsMetadataResponse]
343
+ # A result object deserialized from the server's reply
344
+ def batch_get_documents_metadata request_pb, options = nil
345
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
346
+
347
+ verb, uri, query_string_params, body = ServiceStub.transcode_batch_get_documents_metadata_request request_pb
348
+ query_string_params = if query_string_params.any?
349
+ query_string_params.to_h { |p| p.split "=", 2 }
350
+ else
351
+ {}
352
+ end
353
+
354
+ response = @client_stub.make_http_request(
355
+ verb,
356
+ uri: uri,
357
+ body: body || "",
358
+ params: query_string_params,
359
+ options: options
360
+ )
361
+ operation = ::Gapic::Rest::TransportOperation.new response
362
+ result = ::Google::Cloud::DiscoveryEngine::V1beta::BatchGetDocumentsMetadataResponse.decode_json response.body, ignore_unknown_fields: true
363
+
364
+ yield result, operation if block_given?
365
+ result
366
+ end
367
+
330
368
  ##
331
369
  # @private
332
370
  #
@@ -530,6 +568,34 @@ module Google
530
568
  )
531
569
  transcoder.transcode request_pb
532
570
  end
571
+
572
+ ##
573
+ # @private
574
+ #
575
+ # GRPC transcoding helper method for the batch_get_documents_metadata REST call
576
+ #
577
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::BatchGetDocumentsMetadataRequest]
578
+ # A request object representing the call parameters. Required.
579
+ # @return [Array(String, [String, nil], Hash{String => String})]
580
+ # Uri, Body, Query string parameters
581
+ def self.transcode_batch_get_documents_metadata_request request_pb
582
+ transcoder = Gapic::Rest::GrpcTranscoder.new
583
+ .with_bindings(
584
+ uri_method: :get,
585
+ uri_template: "/v1beta/{parent}/batchGetDocumentsMetadata",
586
+ matches: [
587
+ ["parent", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/branches/[^/]+/?$}, false]
588
+ ]
589
+ )
590
+ .with_bindings(
591
+ uri_method: :get,
592
+ uri_template: "/v1beta/{parent}/batchGetDocumentsMetadata",
593
+ matches: [
594
+ ["parent", %r{^projects/[^/]+/locations/[^/]+/collections/[^/]+/dataStores/[^/]+/branches/[^/]+/?$}, false]
595
+ ]
596
+ )
597
+ transcoder.transcode request_pb
598
+ end
533
599
  end
534
600
  end
535
601
  end
@@ -714,7 +714,7 @@ module Google
714
714
  # @param name [::String]
715
715
  # Required. The name of the engine to pause.
716
716
  # Format:
717
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
717
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
718
718
  #
719
719
  # @yield [response, operation] Access the result along with the RPC operation
720
720
  # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1beta::Engine]
@@ -804,7 +804,7 @@ module Google
804
804
  # @param name [::String]
805
805
  # Required. The name of the engine to resume.
806
806
  # Format:
807
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
807
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
808
808
  #
809
809
  # @yield [response, operation] Access the result along with the RPC operation
810
810
  # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1beta::Engine]
@@ -894,7 +894,7 @@ module Google
894
894
  # @param name [::String]
895
895
  # Required. The resource name of the engine to tune.
896
896
  # Format:
897
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
897
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
898
898
  #
899
899
  # @yield [response, operation] Access the result along with the RPC operation
900
900
  # @yieldparam response [::Gapic::Operation]
@@ -672,7 +672,7 @@ module Google
672
672
  # @param name [::String]
673
673
  # Required. The name of the engine to pause.
674
674
  # Format:
675
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
675
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
676
676
  # @yield [result, operation] Access the result along with the TransportOperation object
677
677
  # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::Engine]
678
678
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -755,7 +755,7 @@ module Google
755
755
  # @param name [::String]
756
756
  # Required. The name of the engine to resume.
757
757
  # Format:
758
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
758
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
759
759
  # @yield [result, operation] Access the result along with the TransportOperation object
760
760
  # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::Engine]
761
761
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -838,7 +838,7 @@ module Google
838
838
  # @param name [::String]
839
839
  # Required. The resource name of the engine to tune.
840
840
  # Format:
841
- # `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`
841
+ # `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`
842
842
  # @yield [result, operation] Access the result along with the TransportOperation object
843
843
  # @yieldparam result [::Gapic::Operation]
844
844
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -183,6 +183,206 @@ module Google
183
183
 
184
184
  # Service calls
185
185
 
186
+ ##
187
+ # Generates grounded content in a streaming fashion.
188
+ #
189
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest, ::Hash>]
190
+ # An enumerable of {::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest} instances.
191
+ # @param options [::Gapic::CallOptions, ::Hash]
192
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
193
+ #
194
+ # @yield [response, operation] Access the result along with the RPC operation
195
+ # @yieldparam response [::Enumerable<::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse>]
196
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
197
+ #
198
+ # @return [::Enumerable<::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse>]
199
+ #
200
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
201
+ #
202
+ # @example Basic example
203
+ # require "google/cloud/discovery_engine/v1beta"
204
+ #
205
+ # # Create a client object. The client can be reused for multiple calls.
206
+ # client = Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Client.new
207
+ #
208
+ # # Create an input stream.
209
+ # input = Gapic::StreamInput.new
210
+ #
211
+ # # Call the stream_generate_grounded_content method to start streaming.
212
+ # output = client.stream_generate_grounded_content input
213
+ #
214
+ # # Send requests on the stream. For each request object, set fields by
215
+ # # passing keyword arguments. Be sure to close the stream when done.
216
+ # input << Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest.new
217
+ # input << Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest.new
218
+ # input.close
219
+ #
220
+ # # The returned object is a streamed enumerable yielding elements of type
221
+ # # ::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse
222
+ # output.each do |current_response|
223
+ # p current_response
224
+ # end
225
+ #
226
+ def stream_generate_grounded_content request, options = nil
227
+ unless request.is_a? ::Enumerable
228
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
229
+ request = request.to_enum
230
+ end
231
+
232
+ request = request.lazy.map do |req|
233
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest
234
+ end
235
+
236
+ # Converts hash and nil to an options object
237
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
238
+
239
+ # Customize the options with defaults
240
+ metadata = @config.rpcs.stream_generate_grounded_content.metadata.to_h
241
+
242
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
243
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
244
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
245
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
246
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
247
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
248
+
249
+ options.apply_defaults timeout: @config.rpcs.stream_generate_grounded_content.timeout,
250
+ metadata: metadata,
251
+ retry_policy: @config.rpcs.stream_generate_grounded_content.retry_policy
252
+
253
+ options.apply_defaults timeout: @config.timeout,
254
+ metadata: @config.metadata,
255
+ retry_policy: @config.retry_policy
256
+
257
+ @grounded_generation_service_stub.call_rpc :stream_generate_grounded_content, request, options: options do |response, operation|
258
+ yield response, operation if block_given?
259
+ return response
260
+ end
261
+ rescue ::GRPC::BadStatus => e
262
+ raise ::Google::Cloud::Error.from_error(e)
263
+ end
264
+
265
+ ##
266
+ # Generates grounded content.
267
+ #
268
+ # @overload generate_grounded_content(request, options = nil)
269
+ # Pass arguments to `generate_grounded_content` via a request object, either of type
270
+ # {::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest} or an equivalent Hash.
271
+ #
272
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest, ::Hash]
273
+ # A request object representing the call parameters. Required. To specify no
274
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
275
+ # @param options [::Gapic::CallOptions, ::Hash]
276
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
277
+ #
278
+ # @overload generate_grounded_content(location: nil, system_instruction: nil, contents: nil, generation_spec: nil, grounding_spec: nil, user_labels: nil)
279
+ # Pass arguments to `generate_grounded_content` via keyword arguments. Note that at
280
+ # least one keyword argument is required. To specify no parameters, or to keep all
281
+ # the default parameter values, pass an empty Hash as a request object (see above).
282
+ #
283
+ # @param location [::String]
284
+ # Required. Location resource.
285
+ #
286
+ # Format: `projects/{project}/locations/{location}`.
287
+ # @param system_instruction [::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationContent, ::Hash]
288
+ # Content of the system instruction for the current API.
289
+ #
290
+ # These instructions will take priority over any other prompt instructions
291
+ # if the selected model is supporting them.
292
+ # @param contents [::Array<::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationContent, ::Hash>]
293
+ # Content of the current conversation with the model.
294
+ #
295
+ # For single-turn queries, this is a single instance. For multi-turn queries,
296
+ # this is a repeated field that contains conversation history + latest
297
+ # request.
298
+ # @param generation_spec [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest::GenerationSpec, ::Hash]
299
+ # Content generation specification.
300
+ # @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest::GroundingSpec, ::Hash]
301
+ # Grounding specification.
302
+ # @param user_labels [::Hash{::String => ::String}]
303
+ # The user labels applied to a resource must meet the following requirements:
304
+ #
305
+ # * Each resource can have multiple labels, up to a maximum of 64.
306
+ # * Each label must be a key-value pair.
307
+ # * Keys have a minimum length of 1 character and a maximum length of 63
308
+ # characters and cannot be empty. Values can be empty and have a maximum
309
+ # length of 63 characters.
310
+ # * Keys and values can contain only lowercase letters, numeric characters,
311
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
312
+ # international characters are allowed.
313
+ # * The key portion of a label must be unique. However, you can use the same
314
+ # key with multiple resources.
315
+ # * Keys must start with a lowercase letter or international character.
316
+ #
317
+ # See [Google Cloud
318
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
319
+ # for more details.
320
+ #
321
+ # @yield [response, operation] Access the result along with the RPC operation
322
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
323
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
324
+ #
325
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse]
326
+ #
327
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
328
+ #
329
+ # @example Basic example
330
+ # require "google/cloud/discovery_engine/v1beta"
331
+ #
332
+ # # Create a client object. The client can be reused for multiple calls.
333
+ # client = Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Client.new
334
+ #
335
+ # # Create a request. To set request fields, pass in keyword arguments.
336
+ # request = Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest.new
337
+ #
338
+ # # Call the generate_grounded_content method.
339
+ # result = client.generate_grounded_content request
340
+ #
341
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentResponse.
342
+ # p result
343
+ #
344
+ def generate_grounded_content request, options = nil
345
+ raise ::ArgumentError, "request must be provided" if request.nil?
346
+
347
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::GenerateGroundedContentRequest
348
+
349
+ # Converts hash and nil to an options object
350
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
351
+
352
+ # Customize the options with defaults
353
+ metadata = @config.rpcs.generate_grounded_content.metadata.to_h
354
+
355
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
356
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
357
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
358
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
359
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
360
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
361
+
362
+ header_params = {}
363
+ if request.location
364
+ header_params["location"] = request.location
365
+ end
366
+
367
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
368
+ metadata[:"x-goog-request-params"] ||= request_params_header
369
+
370
+ options.apply_defaults timeout: @config.rpcs.generate_grounded_content.timeout,
371
+ metadata: metadata,
372
+ retry_policy: @config.rpcs.generate_grounded_content.retry_policy
373
+
374
+ options.apply_defaults timeout: @config.timeout,
375
+ metadata: @config.metadata,
376
+ retry_policy: @config.retry_policy
377
+
378
+ @grounded_generation_service_stub.call_rpc :generate_grounded_content, request, options: options do |response, operation|
379
+ yield response, operation if block_given?
380
+ return response
381
+ end
382
+ rescue ::GRPC::BadStatus => e
383
+ raise ::Google::Cloud::Error.from_error(e)
384
+ end
385
+
186
386
  ##
187
387
  # Performs a grounding check.
188
388
  #
@@ -205,7 +405,7 @@ module Google
205
405
  # Required. The resource name of the grounding config, such as
206
406
  # `projects/*/locations/global/groundingConfigs/default_grounding_config`.
207
407
  # @param answer_candidate [::String]
208
- # Answer candidate to check. Can have a maximum length of 1024 characters.
408
+ # Answer candidate to check. It can have a maximum length of 4096 tokens.
209
409
  # @param facts [::Array<::Google::Cloud::DiscoveryEngine::V1beta::GroundingFact, ::Hash>]
210
410
  # List of facts for the grounding check.
211
411
  # We support up to 200 facts.
@@ -311,17 +511,17 @@ module Google
311
511
  # @example
312
512
  #
313
513
  # # Modify the global config, setting the timeout for
314
- # # check_grounding to 20 seconds,
514
+ # # stream_generate_grounded_content to 20 seconds,
315
515
  # # and all remaining timeouts to 10 seconds.
316
516
  # ::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Client.configure do |config|
317
517
  # config.timeout = 10.0
318
- # config.rpcs.check_grounding.timeout = 20.0
518
+ # config.rpcs.stream_generate_grounded_content.timeout = 20.0
319
519
  # end
320
520
  #
321
521
  # # Apply the above configuration only to a new client.
322
522
  # client = ::Google::Cloud::DiscoveryEngine::V1beta::GroundedGenerationService::Client.new do |config|
323
523
  # config.timeout = 10.0
324
- # config.rpcs.check_grounding.timeout = 20.0
524
+ # config.rpcs.stream_generate_grounded_content.timeout = 20.0
325
525
  # end
326
526
  #
327
527
  # @!attribute [rw] endpoint
@@ -448,6 +648,16 @@ module Google
448
648
  # trigger a retry.
449
649
  #
450
650
  class Rpcs
651
+ ##
652
+ # RPC-specific configuration for `stream_generate_grounded_content`
653
+ # @return [::Gapic::Config::Method]
654
+ #
655
+ attr_reader :stream_generate_grounded_content
656
+ ##
657
+ # RPC-specific configuration for `generate_grounded_content`
658
+ # @return [::Gapic::Config::Method]
659
+ #
660
+ attr_reader :generate_grounded_content
451
661
  ##
452
662
  # RPC-specific configuration for `check_grounding`
453
663
  # @return [::Gapic::Config::Method]
@@ -456,6 +666,10 @@ module Google
456
666
 
457
667
  # @private
458
668
  def initialize parent_rpcs = nil
669
+ stream_generate_grounded_content_config = parent_rpcs.stream_generate_grounded_content if parent_rpcs.respond_to? :stream_generate_grounded_content
670
+ @stream_generate_grounded_content = ::Gapic::Config::Method.new stream_generate_grounded_content_config
671
+ generate_grounded_content_config = parent_rpcs.generate_grounded_content if parent_rpcs.respond_to? :generate_grounded_content
672
+ @generate_grounded_content = ::Gapic::Config::Method.new generate_grounded_content_config
459
673
  check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
460
674
  @check_grounding = ::Gapic::Config::Method.new check_grounding_config
461
675
 
@@ -43,6 +43,91 @@ module Google
43
43
  "projects/#{project}/locations/#{location}/groundingConfigs/#{grounding_config}"
44
44
  end
45
45
 
46
+ ##
47
+ # Create a fully-qualified Location resource string.
48
+ #
49
+ # The resource will be in the following format:
50
+ #
51
+ # `projects/{project}/locations/{location}`
52
+ #
53
+ # @param project [String]
54
+ # @param location [String]
55
+ #
56
+ # @return [::String]
57
+ def location_path project:, location:
58
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59
+
60
+ "projects/#{project}/locations/#{location}"
61
+ end
62
+
63
+ ##
64
+ # Create a fully-qualified ServingConfig resource string.
65
+ #
66
+ # @overload serving_config_path(project:, location:, data_store:, serving_config:)
67
+ # The resource will be in the following format:
68
+ #
69
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}`
70
+ #
71
+ # @param project [String]
72
+ # @param location [String]
73
+ # @param data_store [String]
74
+ # @param serving_config [String]
75
+ #
76
+ # @overload serving_config_path(project:, location:, collection:, data_store:, serving_config:)
77
+ # The resource will be in the following format:
78
+ #
79
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}`
80
+ #
81
+ # @param project [String]
82
+ # @param location [String]
83
+ # @param collection [String]
84
+ # @param data_store [String]
85
+ # @param serving_config [String]
86
+ #
87
+ # @overload serving_config_path(project:, location:, collection:, engine:, serving_config:)
88
+ # The resource will be in the following format:
89
+ #
90
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/servingConfigs/{serving_config}`
91
+ #
92
+ # @param project [String]
93
+ # @param location [String]
94
+ # @param collection [String]
95
+ # @param engine [String]
96
+ # @param serving_config [String]
97
+ #
98
+ # @return [::String]
99
+ def serving_config_path **args
100
+ resources = {
101
+ "data_store:location:project:serving_config" => (proc do |project:, location:, data_store:, serving_config:|
102
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
103
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
104
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
105
+
106
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
107
+ end),
108
+ "collection:data_store:location:project:serving_config" => (proc do |project:, location:, collection:, data_store:, serving_config:|
109
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
110
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
111
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
112
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
113
+
114
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
115
+ end),
116
+ "collection:engine:location:project:serving_config" => (proc do |project:, location:, collection:, engine:, serving_config:|
117
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
118
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
119
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
120
+ raise ::ArgumentError, "engine cannot contain /" if engine.to_s.include? "/"
121
+
122
+ "projects/#{project}/locations/#{location}/collections/#{collection}/engines/#{engine}/servingConfigs/#{serving_config}"
123
+ end)
124
+ }
125
+
126
+ resource = resources[args.keys.sort.join(":")]
127
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
128
+ resource.call(**args)
129
+ end
130
+
46
131
  extend self
47
132
  end
48
133
  end