google-cloud-discovery_engine-v1 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google/cloud/discovery_engine/v1/completion_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/control_service/client.rb +6 -6
- data/lib/google/cloud/discovery_engine/v1/control_service/rest/client.rb +6 -6
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +15 -12
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +15 -12
- data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +25 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/engine_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/client.rb +219 -3
- data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/paths.rb +85 -0
- data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/client.rb +126 -3
- data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/service_stub.rb +60 -0
- data/lib/google/cloud/discovery_engine/v1/project_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/rank_service/client.rb +1 -1
- data/lib/google/cloud/discovery_engine/v1/rank_service/rest/client.rb +1 -1
- data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +324 -1
- data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +316 -1
- data/lib/google/cloud/discovery_engine/v1/search_service/rest/service_stub.rb +76 -0
- data/lib/google/cloud/discovery_engine/v1/search_tuning_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/client.rb +5 -1
- data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/client.rb +5 -1
- data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +1 -1
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +1 -1
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +2 -2
- data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/answer_pb.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/common_pb.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/control_pb.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +2 -1
- data/lib/google/cloud/discoveryengine/v1/custom_tuning_model_pb.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/data_store_pb.rb +4 -1
- data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +2 -1
- data/lib/google/cloud/discoveryengine/v1/engine_pb.rb +1 -1
- data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_pb.rb +23 -1
- data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_services_pb.rb +4 -0
- data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +5 -1
- data/lib/google/cloud/discoveryengine/v1/search_service_services_pb.rb +14 -0
- data/lib/google/cloud/discoveryengine/v1/site_search_engine_service_pb.rb +1 -1
- data/proto_docs/google/api/client.rb +14 -0
- data/proto_docs/google/cloud/discoveryengine/v1/answer.rb +18 -2
- data/proto_docs/google/cloud/discoveryengine/v1/control.rb +9 -0
- data/proto_docs/google/cloud/discoveryengine/v1/control_service.rb +6 -6
- data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +59 -15
- data/proto_docs/google/cloud/discoveryengine/v1/custom_tuning_model.rb +8 -3
- data/proto_docs/google/cloud/discoveryengine/v1/data_store.rb +88 -0
- data/proto_docs/google/cloud/discoveryengine/v1/document_processing_config.rb +7 -5
- data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +19 -0
- data/proto_docs/google/cloud/discoveryengine/v1/engine.rb +5 -1
- data/proto_docs/google/cloud/discoveryengine/v1/grounded_generation_service.rb +383 -0
- data/proto_docs/google/cloud/discoveryengine/v1/project.rb +1 -1
- data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +1 -1
- data/proto_docs/google/cloud/discoveryengine/v1/rank_service.rb +1 -1
- data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +116 -0
- data/proto_docs/google/cloud/discoveryengine/v1/site_search_engine_service.rb +5 -0
- data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +1 -1
- metadata +3 -3
@@ -183,6 +183,208 @@ 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::V1::GenerateGroundedContentRequest, ::Hash>]
|
190
|
+
# An enumerable of {::Google::Cloud::DiscoveryEngine::V1::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::V1::GenerateGroundedContentResponse>]
|
196
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
197
|
+
#
|
198
|
+
# @return [::Enumerable<::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse>]
|
199
|
+
#
|
200
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
201
|
+
#
|
202
|
+
# @example Basic example
|
203
|
+
# require "google/cloud/discovery_engine/v1"
|
204
|
+
#
|
205
|
+
# # Create a client object. The client can be reused for multiple calls.
|
206
|
+
# client = Google::Cloud::DiscoveryEngine::V1::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::V1::GenerateGroundedContentRequest.new
|
217
|
+
# input << Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
|
218
|
+
# input.close
|
219
|
+
#
|
220
|
+
# # The returned object is a streamed enumerable yielding elements of type
|
221
|
+
# # ::Google::Cloud::DiscoveryEngine::V1::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::V1::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::V1::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::V1::GenerateGroundedContentRequest} or an equivalent Hash.
|
271
|
+
#
|
272
|
+
# @param request [::Google::Cloud::DiscoveryEngine::V1::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::V1::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::V1::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
|
+
#
|
299
|
+
# Only a single-turn query is supported currently.
|
300
|
+
# @param generation_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GenerationSpec, ::Hash]
|
301
|
+
# Content generation specification.
|
302
|
+
# @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GroundingSpec, ::Hash]
|
303
|
+
# Grounding specification.
|
304
|
+
# @param user_labels [::Hash{::String => ::String}]
|
305
|
+
# The user labels applied to a resource must meet the following requirements:
|
306
|
+
#
|
307
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
308
|
+
# * Each label must be a key-value pair.
|
309
|
+
# * Keys have a minimum length of 1 character and a maximum length of 63
|
310
|
+
# characters and cannot be empty. Values can be empty and have a maximum
|
311
|
+
# length of 63 characters.
|
312
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
313
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
314
|
+
# international characters are allowed.
|
315
|
+
# * The key portion of a label must be unique. However, you can use the same
|
316
|
+
# key with multiple resources.
|
317
|
+
# * Keys must start with a lowercase letter or international character.
|
318
|
+
#
|
319
|
+
# See [Google Cloud
|
320
|
+
# Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
|
321
|
+
# for more details.
|
322
|
+
#
|
323
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
324
|
+
# @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
|
325
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
326
|
+
#
|
327
|
+
# @return [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
|
328
|
+
#
|
329
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
330
|
+
#
|
331
|
+
# @example Basic example
|
332
|
+
# require "google/cloud/discovery_engine/v1"
|
333
|
+
#
|
334
|
+
# # Create a client object. The client can be reused for multiple calls.
|
335
|
+
# client = Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new
|
336
|
+
#
|
337
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
338
|
+
# request = Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
|
339
|
+
#
|
340
|
+
# # Call the generate_grounded_content method.
|
341
|
+
# result = client.generate_grounded_content request
|
342
|
+
#
|
343
|
+
# # The returned object is of type Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse.
|
344
|
+
# p result
|
345
|
+
#
|
346
|
+
def generate_grounded_content request, options = nil
|
347
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
348
|
+
|
349
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest
|
350
|
+
|
351
|
+
# Converts hash and nil to an options object
|
352
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
353
|
+
|
354
|
+
# Customize the options with defaults
|
355
|
+
metadata = @config.rpcs.generate_grounded_content.metadata.to_h
|
356
|
+
|
357
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
358
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
359
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
360
|
+
gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
|
361
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
362
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
363
|
+
|
364
|
+
header_params = {}
|
365
|
+
if request.location
|
366
|
+
header_params["location"] = request.location
|
367
|
+
end
|
368
|
+
|
369
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
370
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
371
|
+
|
372
|
+
options.apply_defaults timeout: @config.rpcs.generate_grounded_content.timeout,
|
373
|
+
metadata: metadata,
|
374
|
+
retry_policy: @config.rpcs.generate_grounded_content.retry_policy
|
375
|
+
|
376
|
+
options.apply_defaults timeout: @config.timeout,
|
377
|
+
metadata: @config.metadata,
|
378
|
+
retry_policy: @config.retry_policy
|
379
|
+
|
380
|
+
@grounded_generation_service_stub.call_rpc :generate_grounded_content, request, options: options do |response, operation|
|
381
|
+
yield response, operation if block_given?
|
382
|
+
return response
|
383
|
+
end
|
384
|
+
rescue ::GRPC::BadStatus => e
|
385
|
+
raise ::Google::Cloud::Error.from_error(e)
|
386
|
+
end
|
387
|
+
|
186
388
|
##
|
187
389
|
# Performs a grounding check.
|
188
390
|
#
|
@@ -311,17 +513,17 @@ module Google
|
|
311
513
|
# @example
|
312
514
|
#
|
313
515
|
# # Modify the global config, setting the timeout for
|
314
|
-
# #
|
516
|
+
# # stream_generate_grounded_content to 20 seconds,
|
315
517
|
# # and all remaining timeouts to 10 seconds.
|
316
518
|
# ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.configure do |config|
|
317
519
|
# config.timeout = 10.0
|
318
|
-
# config.rpcs.
|
520
|
+
# config.rpcs.stream_generate_grounded_content.timeout = 20.0
|
319
521
|
# end
|
320
522
|
#
|
321
523
|
# # Apply the above configuration only to a new client.
|
322
524
|
# client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new do |config|
|
323
525
|
# config.timeout = 10.0
|
324
|
-
# config.rpcs.
|
526
|
+
# config.rpcs.stream_generate_grounded_content.timeout = 20.0
|
325
527
|
# end
|
326
528
|
#
|
327
529
|
# @!attribute [rw] endpoint
|
@@ -448,6 +650,16 @@ module Google
|
|
448
650
|
# trigger a retry.
|
449
651
|
#
|
450
652
|
class Rpcs
|
653
|
+
##
|
654
|
+
# RPC-specific configuration for `stream_generate_grounded_content`
|
655
|
+
# @return [::Gapic::Config::Method]
|
656
|
+
#
|
657
|
+
attr_reader :stream_generate_grounded_content
|
658
|
+
##
|
659
|
+
# RPC-specific configuration for `generate_grounded_content`
|
660
|
+
# @return [::Gapic::Config::Method]
|
661
|
+
#
|
662
|
+
attr_reader :generate_grounded_content
|
451
663
|
##
|
452
664
|
# RPC-specific configuration for `check_grounding`
|
453
665
|
# @return [::Gapic::Config::Method]
|
@@ -456,6 +668,10 @@ module Google
|
|
456
668
|
|
457
669
|
# @private
|
458
670
|
def initialize parent_rpcs = nil
|
671
|
+
stream_generate_grounded_content_config = parent_rpcs.stream_generate_grounded_content if parent_rpcs.respond_to? :stream_generate_grounded_content
|
672
|
+
@stream_generate_grounded_content = ::Gapic::Config::Method.new stream_generate_grounded_content_config
|
673
|
+
generate_grounded_content_config = parent_rpcs.generate_grounded_content if parent_rpcs.respond_to? :generate_grounded_content
|
674
|
+
@generate_grounded_content = ::Gapic::Config::Method.new generate_grounded_content_config
|
459
675
|
check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
|
460
676
|
@check_grounding = ::Gapic::Config::Method.new check_grounding_config
|
461
677
|
|
@@ -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
|
@@ -176,6 +176,122 @@ 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::V1::GenerateGroundedContentRequest} or an equivalent Hash.
|
185
|
+
#
|
186
|
+
# @param request [::Google::Cloud::DiscoveryEngine::V1::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::V1::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::V1::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
|
+
#
|
213
|
+
# Only a single-turn query is supported currently.
|
214
|
+
# @param generation_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GenerationSpec, ::Hash]
|
215
|
+
# Content generation specification.
|
216
|
+
# @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GroundingSpec, ::Hash]
|
217
|
+
# Grounding specification.
|
218
|
+
# @param user_labels [::Hash{::String => ::String}]
|
219
|
+
# The user labels applied to a resource must meet the following requirements:
|
220
|
+
#
|
221
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
222
|
+
# * Each label must be a key-value pair.
|
223
|
+
# * Keys have a minimum length of 1 character and a maximum length of 63
|
224
|
+
# characters and cannot be empty. Values can be empty and have a maximum
|
225
|
+
# length of 63 characters.
|
226
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
227
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
228
|
+
# international characters are allowed.
|
229
|
+
# * The key portion of a label must be unique. However, you can use the same
|
230
|
+
# key with multiple resources.
|
231
|
+
# * Keys must start with a lowercase letter or international character.
|
232
|
+
#
|
233
|
+
# See [Google Cloud
|
234
|
+
# Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
|
235
|
+
# for more details.
|
236
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
237
|
+
# @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
|
238
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
239
|
+
#
|
240
|
+
# @return [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
|
241
|
+
#
|
242
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
243
|
+
#
|
244
|
+
# @example Basic example
|
245
|
+
# require "google/cloud/discovery_engine/v1"
|
246
|
+
#
|
247
|
+
# # Create a client object. The client can be reused for multiple calls.
|
248
|
+
# client = Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new
|
249
|
+
#
|
250
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
251
|
+
# request = Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
|
252
|
+
#
|
253
|
+
# # Call the generate_grounded_content method.
|
254
|
+
# result = client.generate_grounded_content request
|
255
|
+
#
|
256
|
+
# # The returned object is of type Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse.
|
257
|
+
# p result
|
258
|
+
#
|
259
|
+
def generate_grounded_content request, options = nil
|
260
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
261
|
+
|
262
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest
|
263
|
+
|
264
|
+
# Converts hash and nil to an options object
|
265
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
266
|
+
|
267
|
+
# Customize the options with defaults
|
268
|
+
call_metadata = @config.rpcs.generate_grounded_content.metadata.to_h
|
269
|
+
|
270
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
271
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
272
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
273
|
+
gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
|
274
|
+
transports_version_send: [:rest]
|
275
|
+
|
276
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
277
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
278
|
+
|
279
|
+
options.apply_defaults timeout: @config.rpcs.generate_grounded_content.timeout,
|
280
|
+
metadata: call_metadata,
|
281
|
+
retry_policy: @config.rpcs.generate_grounded_content.retry_policy
|
282
|
+
|
283
|
+
options.apply_defaults timeout: @config.timeout,
|
284
|
+
metadata: @config.metadata,
|
285
|
+
retry_policy: @config.retry_policy
|
286
|
+
|
287
|
+
@grounded_generation_service_stub.generate_grounded_content request, options do |result, operation|
|
288
|
+
yield result, operation if block_given?
|
289
|
+
return result
|
290
|
+
end
|
291
|
+
rescue ::Gapic::Rest::Error => e
|
292
|
+
raise ::Google::Cloud::Error.from_error(e)
|
293
|
+
end
|
294
|
+
|
179
295
|
##
|
180
296
|
# Performs a grounding check.
|
181
297
|
#
|
@@ -297,17 +413,17 @@ module Google
|
|
297
413
|
# @example
|
298
414
|
#
|
299
415
|
# # Modify the global config, setting the timeout for
|
300
|
-
# #
|
416
|
+
# # generate_grounded_content to 20 seconds,
|
301
417
|
# # and all remaining timeouts to 10 seconds.
|
302
418
|
# ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.configure do |config|
|
303
419
|
# config.timeout = 10.0
|
304
|
-
# config.rpcs.
|
420
|
+
# config.rpcs.generate_grounded_content.timeout = 20.0
|
305
421
|
# end
|
306
422
|
#
|
307
423
|
# # Apply the above configuration only to a new client.
|
308
424
|
# client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client.new do |config|
|
309
425
|
# config.timeout = 10.0
|
310
|
-
# config.rpcs.
|
426
|
+
# config.rpcs.generate_grounded_content.timeout = 20.0
|
311
427
|
# end
|
312
428
|
#
|
313
429
|
# @!attribute [rw] endpoint
|
@@ -414,6 +530,11 @@ module Google
|
|
414
530
|
# trigger a retry.
|
415
531
|
#
|
416
532
|
class Rpcs
|
533
|
+
##
|
534
|
+
# RPC-specific configuration for `generate_grounded_content`
|
535
|
+
# @return [::Gapic::Config::Method]
|
536
|
+
#
|
537
|
+
attr_reader :generate_grounded_content
|
417
538
|
##
|
418
539
|
# RPC-specific configuration for `check_grounding`
|
419
540
|
# @return [::Gapic::Config::Method]
|
@@ -422,6 +543,8 @@ module Google
|
|
422
543
|
|
423
544
|
# @private
|
424
545
|
def initialize parent_rpcs = nil
|
546
|
+
generate_grounded_content_config = parent_rpcs.generate_grounded_content if parent_rpcs.respond_to? :generate_grounded_content
|
547
|
+
@generate_grounded_content = ::Gapic::Config::Method.new generate_grounded_content_config
|
425
548
|
check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
|
426
549
|
@check_grounding = ::Gapic::Config::Method.new check_grounding_config
|
427
550
|
|
@@ -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::V1::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::V1::GenerateGroundedContentResponse]
|
74
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
75
|
+
#
|
76
|
+
# @return [::Google::Cloud::DiscoveryEngine::V1::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::V1::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::V1::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: "/v1/{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
|
#
|
@@ -915,7 +915,7 @@ module Google
|
|
915
915
|
uri_method: :get,
|
916
916
|
uri_template: "/v1/{name}/operations",
|
917
917
|
matches: [
|
918
|
-
["name", %r{^projects/[^/]+/locations/[^/]+/
|
918
|
+
["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/?$}, false]
|
919
919
|
]
|
920
920
|
)
|
921
921
|
.with_bindings(
|
@@ -1041,7 +1041,7 @@ module Google
|
|
1041
1041
|
uri_method: :get,
|
1042
1042
|
uri_template: "/v1/{name}",
|
1043
1043
|
matches: [
|
1044
|
-
["name", %r{^projects/[^/]+/locations/[^/]+/
|
1044
|
+
["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/operations/[^/]+/?$}, false]
|
1045
1045
|
]
|
1046
1046
|
)
|
1047
1047
|
.with_bindings(
|
@@ -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/{
|
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/{
|
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
|
#
|
@@ -915,7 +915,7 @@ module Google
|
|
915
915
|
uri_method: :get,
|
916
916
|
uri_template: "/v1/{name}/operations",
|
917
917
|
matches: [
|
918
|
-
["name", %r{^projects/[^/]+/locations/[^/]+/
|
918
|
+
["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/?$}, false]
|
919
919
|
]
|
920
920
|
)
|
921
921
|
.with_bindings(
|
@@ -1041,7 +1041,7 @@ module Google
|
|
1041
1041
|
uri_method: :get,
|
1042
1042
|
uri_template: "/v1/{name}",
|
1043
1043
|
matches: [
|
1044
|
-
["name", %r{^projects/[^/]+/locations/[^/]+/
|
1044
|
+
["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/operations/[^/]+/?$}, false]
|
1045
1045
|
]
|
1046
1046
|
)
|
1047
1047
|
.with_bindings(
|