google-cloud-ai_platform-v1 0.34.0 → 0.35.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb52548f5d070c67fa9b16c58f2d65cefb1059cd0edc93c8272f32c320f0018f
4
- data.tar.gz: f9923f1d5b4d903cf2517cf2a9cb89c081550d0bcb459401883feb270cda29ed
3
+ metadata.gz: fcb7c0638bbbcec0d81c576378862c6531005fd0f067378e55c86db49172310f
4
+ data.tar.gz: 29f33bd3e971a27297ea8df831935c48fd9db6428464434ef5ef35cc6702a95a
5
5
  SHA512:
6
- metadata.gz: d0dc9e95af82684f6357b43b3bb57675703b8accc2594a089f8fd732ff04a5bdfb8f5dc439ba2a681da16c7b29ec48d711c8c6e16cdfc6434d6b4b253b334955
7
- data.tar.gz: 339a7a84d83d3a68d02c1585c5e5d4a7b5186fa2f48518100d6bca9d19384ae3e7a470ec053088a11b660d0f302b616999c490896b3a9bf97c1b4dc52bb9e7b3
6
+ metadata.gz: 360db9b95f78ab5d25878828f40f18798d19d6a8756d2dc901152fdd00df57d3f7faa2294869c480be77f5e4df82d9694042aefa7a3a318aeb0abfcc0b52b0df
7
+ data.tar.gz: 35e6d36c41fa67cf120019af21e1a66e9420583b96164fb1837d0bd5e14005be63c1cbfa1443be4f59978ac4102dede0cff24920eb981d080ba4f61fa3dad7e4
@@ -0,0 +1,528 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/aiplatform/v1/llm_utility_service_pb"
21
+ require "google/cloud/location"
22
+ require "google/iam/v1"
23
+
24
+ module Google
25
+ module Cloud
26
+ module AIPlatform
27
+ module V1
28
+ module LlmUtilityService
29
+ ##
30
+ # Client for the LlmUtilityService service.
31
+ #
32
+ # Service for LLM related utility functions.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :llm_utility_service_stub
39
+
40
+ ##
41
+ # Configure the LlmUtilityService Client class.
42
+ #
43
+ # See {::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all LlmUtilityService clients
49
+ # ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "AIPlatform", "V1"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config
70
+ end
71
+ yield @configure if block_given?
72
+ @configure
73
+ end
74
+
75
+ ##
76
+ # Configure the LlmUtilityService Client instance.
77
+ #
78
+ # The configuration is set to the derived mode, meaning that values can be changed,
79
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
80
+ # should be made on {Client.configure}.
81
+ #
82
+ # See {::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client::Configuration}
83
+ # for a description of the configuration fields.
84
+ #
85
+ # @yield [config] Configure the Client client.
86
+ # @yieldparam config [Client::Configuration]
87
+ #
88
+ # @return [Client::Configuration]
89
+ #
90
+ def configure
91
+ yield @config if block_given?
92
+ @config
93
+ end
94
+
95
+ ##
96
+ # Create a new LlmUtilityService client object.
97
+ #
98
+ # @example
99
+ #
100
+ # # Create a client using the default configuration
101
+ # client = ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.new
102
+ #
103
+ # # Create a client using a custom configuration
104
+ # client = ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.new do |config|
105
+ # config.timeout = 10.0
106
+ # end
107
+ #
108
+ # @yield [config] Configure the LlmUtilityService client.
109
+ # @yieldparam config [Client::Configuration]
110
+ #
111
+ def initialize
112
+ # These require statements are intentionally placed here to initialize
113
+ # the gRPC module only when it's required.
114
+ # See https://github.com/googleapis/toolkit/issues/446
115
+ require "gapic/grpc"
116
+ require "google/cloud/aiplatform/v1/llm_utility_service_services_pb"
117
+
118
+ # Create the configuration object
119
+ @config = Configuration.new Client.configure
120
+
121
+ # Yield the configuration if needed
122
+ yield @config if block_given?
123
+
124
+ # Create credentials
125
+ credentials = @config.credentials
126
+ # Use self-signed JWT if the endpoint is unchanged from default,
127
+ # but only if the default endpoint does not have a region prefix.
128
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
129
+ !@config.endpoint.split(".").first.include?("-")
130
+ credentials ||= Credentials.default scope: @config.scope,
131
+ enable_self_signed_jwt: enable_self_signed_jwt
132
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+ @quota_project_id = @config.quota_project
136
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
137
+
138
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
139
+ config.credentials = credentials
140
+ config.quota_project = @quota_project_id
141
+ config.endpoint = @config.endpoint
142
+ end
143
+
144
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
145
+ config.credentials = credentials
146
+ config.quota_project = @quota_project_id
147
+ config.endpoint = @config.endpoint
148
+ end
149
+
150
+ @llm_utility_service_stub = ::Gapic::ServiceStub.new(
151
+ ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Stub,
152
+ credentials: credentials,
153
+ endpoint: @config.endpoint,
154
+ channel_args: @config.channel_args,
155
+ interceptors: @config.interceptors,
156
+ channel_pool_config: @config.channel_pool
157
+ )
158
+ end
159
+
160
+ ##
161
+ # Get the associated client for mix-in of the Locations.
162
+ #
163
+ # @return [Google::Cloud::Location::Locations::Client]
164
+ #
165
+ attr_reader :location_client
166
+
167
+ ##
168
+ # Get the associated client for mix-in of the IAMPolicy.
169
+ #
170
+ # @return [Google::Iam::V1::IAMPolicy::Client]
171
+ #
172
+ attr_reader :iam_policy_client
173
+
174
+ # Service calls
175
+
176
+ ##
177
+ # Perform a token counting.
178
+ #
179
+ # @overload count_tokens(request, options = nil)
180
+ # Pass arguments to `count_tokens` via a request object, either of type
181
+ # {::Google::Cloud::AIPlatform::V1::CountTokensRequest} or an equivalent Hash.
182
+ #
183
+ # @param request [::Google::Cloud::AIPlatform::V1::CountTokensRequest, ::Hash]
184
+ # A request object representing the call parameters. Required. To specify no
185
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
186
+ # @param options [::Gapic::CallOptions, ::Hash]
187
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
188
+ #
189
+ # @overload count_tokens(endpoint: nil, instances: nil)
190
+ # Pass arguments to `count_tokens` via keyword arguments. Note that at
191
+ # least one keyword argument is required. To specify no parameters, or to keep all
192
+ # the default parameter values, pass an empty Hash as a request object (see above).
193
+ #
194
+ # @param endpoint [::String]
195
+ # Required. The name of the Endpoint requested to perform token counting.
196
+ # Format:
197
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
198
+ # @param instances [::Array<::Google::Protobuf::Value, ::Hash>]
199
+ # Required. The instances that are the input to token counting call.
200
+ # Schema is identical to the prediction schema of the underlying model.
201
+ #
202
+ # @yield [response, operation] Access the result along with the RPC operation
203
+ # @yieldparam response [::Google::Cloud::AIPlatform::V1::CountTokensResponse]
204
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
205
+ #
206
+ # @return [::Google::Cloud::AIPlatform::V1::CountTokensResponse]
207
+ #
208
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
209
+ #
210
+ # @example Basic example
211
+ # require "google/cloud/ai_platform/v1"
212
+ #
213
+ # # Create a client object. The client can be reused for multiple calls.
214
+ # client = Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.new
215
+ #
216
+ # # Create a request. To set request fields, pass in keyword arguments.
217
+ # request = Google::Cloud::AIPlatform::V1::CountTokensRequest.new
218
+ #
219
+ # # Call the count_tokens method.
220
+ # result = client.count_tokens request
221
+ #
222
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::CountTokensResponse.
223
+ # p result
224
+ #
225
+ def count_tokens request, options = nil
226
+ raise ::ArgumentError, "request must be provided" if request.nil?
227
+
228
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::CountTokensRequest
229
+
230
+ # Converts hash and nil to an options object
231
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
232
+
233
+ # Customize the options with defaults
234
+ metadata = @config.rpcs.count_tokens.metadata.to_h
235
+
236
+ # Set x-goog-api-client and x-goog-user-project headers
237
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
238
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
239
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION
240
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
241
+
242
+ header_params = {}
243
+ if request.endpoint
244
+ header_params["endpoint"] = request.endpoint
245
+ end
246
+
247
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
248
+ metadata[:"x-goog-request-params"] ||= request_params_header
249
+
250
+ options.apply_defaults timeout: @config.rpcs.count_tokens.timeout,
251
+ metadata: metadata,
252
+ retry_policy: @config.rpcs.count_tokens.retry_policy
253
+
254
+ options.apply_defaults timeout: @config.timeout,
255
+ metadata: @config.metadata,
256
+ retry_policy: @config.retry_policy
257
+
258
+ @llm_utility_service_stub.call_rpc :count_tokens, request, options: options do |response, operation|
259
+ yield response, operation if block_given?
260
+ return response
261
+ end
262
+ rescue ::GRPC::BadStatus => e
263
+ raise ::Google::Cloud::Error.from_error(e)
264
+ end
265
+
266
+ ##
267
+ # Return a list of tokens based on the input text.
268
+ #
269
+ # @overload compute_tokens(request, options = nil)
270
+ # Pass arguments to `compute_tokens` via a request object, either of type
271
+ # {::Google::Cloud::AIPlatform::V1::ComputeTokensRequest} or an equivalent Hash.
272
+ #
273
+ # @param request [::Google::Cloud::AIPlatform::V1::ComputeTokensRequest, ::Hash]
274
+ # A request object representing the call parameters. Required. To specify no
275
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
276
+ # @param options [::Gapic::CallOptions, ::Hash]
277
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
278
+ #
279
+ # @overload compute_tokens(endpoint: nil, instances: nil)
280
+ # Pass arguments to `compute_tokens` via keyword arguments. Note that at
281
+ # least one keyword argument is required. To specify no parameters, or to keep all
282
+ # the default parameter values, pass an empty Hash as a request object (see above).
283
+ #
284
+ # @param endpoint [::String]
285
+ # Required. The name of the Endpoint requested to get lists of tokens and
286
+ # token ids.
287
+ # @param instances [::Array<::Google::Protobuf::Value, ::Hash>]
288
+ # Required. The instances that are the input to token computing API call.
289
+ # Schema is identical to the prediction schema of the text model, even for
290
+ # the non-text models, like chat models, or Codey models.
291
+ #
292
+ # @yield [response, operation] Access the result along with the RPC operation
293
+ # @yieldparam response [::Google::Cloud::AIPlatform::V1::ComputeTokensResponse]
294
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
295
+ #
296
+ # @return [::Google::Cloud::AIPlatform::V1::ComputeTokensResponse]
297
+ #
298
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
299
+ #
300
+ # @example Basic example
301
+ # require "google/cloud/ai_platform/v1"
302
+ #
303
+ # # Create a client object. The client can be reused for multiple calls.
304
+ # client = Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.new
305
+ #
306
+ # # Create a request. To set request fields, pass in keyword arguments.
307
+ # request = Google::Cloud::AIPlatform::V1::ComputeTokensRequest.new
308
+ #
309
+ # # Call the compute_tokens method.
310
+ # result = client.compute_tokens request
311
+ #
312
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::ComputeTokensResponse.
313
+ # p result
314
+ #
315
+ def compute_tokens request, options = nil
316
+ raise ::ArgumentError, "request must be provided" if request.nil?
317
+
318
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::ComputeTokensRequest
319
+
320
+ # Converts hash and nil to an options object
321
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
322
+
323
+ # Customize the options with defaults
324
+ metadata = @config.rpcs.compute_tokens.metadata.to_h
325
+
326
+ # Set x-goog-api-client and x-goog-user-project headers
327
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
328
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
329
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION
330
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
331
+
332
+ header_params = {}
333
+ if request.endpoint
334
+ header_params["endpoint"] = request.endpoint
335
+ end
336
+
337
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
338
+ metadata[:"x-goog-request-params"] ||= request_params_header
339
+
340
+ options.apply_defaults timeout: @config.rpcs.compute_tokens.timeout,
341
+ metadata: metadata,
342
+ retry_policy: @config.rpcs.compute_tokens.retry_policy
343
+
344
+ options.apply_defaults timeout: @config.timeout,
345
+ metadata: @config.metadata,
346
+ retry_policy: @config.retry_policy
347
+
348
+ @llm_utility_service_stub.call_rpc :compute_tokens, request, options: options do |response, operation|
349
+ yield response, operation if block_given?
350
+ return response
351
+ end
352
+ rescue ::GRPC::BadStatus => e
353
+ raise ::Google::Cloud::Error.from_error(e)
354
+ end
355
+
356
+ ##
357
+ # Configuration class for the LlmUtilityService API.
358
+ #
359
+ # This class represents the configuration for LlmUtilityService,
360
+ # providing control over timeouts, retry behavior, logging, transport
361
+ # parameters, and other low-level controls. Certain parameters can also be
362
+ # applied individually to specific RPCs. See
363
+ # {::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client::Configuration::Rpcs}
364
+ # for a list of RPCs that can be configured independently.
365
+ #
366
+ # Configuration can be applied globally to all clients, or to a single client
367
+ # on construction.
368
+ #
369
+ # @example
370
+ #
371
+ # # Modify the global config, setting the timeout for
372
+ # # count_tokens to 20 seconds,
373
+ # # and all remaining timeouts to 10 seconds.
374
+ # ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.configure do |config|
375
+ # config.timeout = 10.0
376
+ # config.rpcs.count_tokens.timeout = 20.0
377
+ # end
378
+ #
379
+ # # Apply the above configuration only to a new client.
380
+ # client = ::Google::Cloud::AIPlatform::V1::LlmUtilityService::Client.new do |config|
381
+ # config.timeout = 10.0
382
+ # config.rpcs.count_tokens.timeout = 20.0
383
+ # end
384
+ #
385
+ # @!attribute [rw] endpoint
386
+ # The hostname or hostname:port of the service endpoint.
387
+ # Defaults to `"aiplatform.googleapis.com"`.
388
+ # @return [::String]
389
+ # @!attribute [rw] credentials
390
+ # Credentials to send with calls. You may provide any of the following types:
391
+ # * (`String`) The path to a service account key file in JSON format
392
+ # * (`Hash`) A service account key as a Hash
393
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
394
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
395
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
396
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
397
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
398
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
399
+ # * (`nil`) indicating no credentials
400
+ # @return [::Object]
401
+ # @!attribute [rw] scope
402
+ # The OAuth scopes
403
+ # @return [::Array<::String>]
404
+ # @!attribute [rw] lib_name
405
+ # The library name as recorded in instrumentation and logging
406
+ # @return [::String]
407
+ # @!attribute [rw] lib_version
408
+ # The library version as recorded in instrumentation and logging
409
+ # @return [::String]
410
+ # @!attribute [rw] channel_args
411
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
412
+ # `GRPC::Core::Channel` object is provided as the credential.
413
+ # @return [::Hash]
414
+ # @!attribute [rw] interceptors
415
+ # An array of interceptors that are run before calls are executed.
416
+ # @return [::Array<::GRPC::ClientInterceptor>]
417
+ # @!attribute [rw] timeout
418
+ # The call timeout in seconds.
419
+ # @return [::Numeric]
420
+ # @!attribute [rw] metadata
421
+ # Additional gRPC headers to be sent with the call.
422
+ # @return [::Hash{::Symbol=>::String}]
423
+ # @!attribute [rw] retry_policy
424
+ # The retry policy. The value is a hash with the following keys:
425
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
426
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
427
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
428
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
429
+ # trigger a retry.
430
+ # @return [::Hash]
431
+ # @!attribute [rw] quota_project
432
+ # A separate project against which to charge quota.
433
+ # @return [::String]
434
+ #
435
+ class Configuration
436
+ extend ::Gapic::Config
437
+
438
+ DEFAULT_ENDPOINT = "aiplatform.googleapis.com"
439
+
440
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
441
+ config_attr :credentials, nil do |value|
442
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
443
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
444
+ allowed.any? { |klass| klass === value }
445
+ end
446
+ config_attr :scope, nil, ::String, ::Array, nil
447
+ config_attr :lib_name, nil, ::String, nil
448
+ config_attr :lib_version, nil, ::String, nil
449
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
450
+ config_attr :interceptors, nil, ::Array, nil
451
+ config_attr :timeout, nil, ::Numeric, nil
452
+ config_attr :metadata, nil, ::Hash, nil
453
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
454
+ config_attr :quota_project, nil, ::String, nil
455
+
456
+ # @private
457
+ def initialize parent_config = nil
458
+ @parent_config = parent_config unless parent_config.nil?
459
+
460
+ yield self if block_given?
461
+ end
462
+
463
+ ##
464
+ # Configurations for individual RPCs
465
+ # @return [Rpcs]
466
+ #
467
+ def rpcs
468
+ @rpcs ||= begin
469
+ parent_rpcs = nil
470
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
471
+ Rpcs.new parent_rpcs
472
+ end
473
+ end
474
+
475
+ ##
476
+ # Configuration for the channel pool
477
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
478
+ #
479
+ def channel_pool
480
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
481
+ end
482
+
483
+ ##
484
+ # Configuration RPC class for the LlmUtilityService API.
485
+ #
486
+ # Includes fields providing the configuration for each RPC in this service.
487
+ # Each configuration object is of type `Gapic::Config::Method` and includes
488
+ # the following configuration fields:
489
+ #
490
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
491
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
492
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
493
+ # include the following keys:
494
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
495
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
496
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
497
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
498
+ # trigger a retry.
499
+ #
500
+ class Rpcs
501
+ ##
502
+ # RPC-specific configuration for `count_tokens`
503
+ # @return [::Gapic::Config::Method]
504
+ #
505
+ attr_reader :count_tokens
506
+ ##
507
+ # RPC-specific configuration for `compute_tokens`
508
+ # @return [::Gapic::Config::Method]
509
+ #
510
+ attr_reader :compute_tokens
511
+
512
+ # @private
513
+ def initialize parent_rpcs = nil
514
+ count_tokens_config = parent_rpcs.count_tokens if parent_rpcs.respond_to? :count_tokens
515
+ @count_tokens = ::Gapic::Config::Method.new count_tokens_config
516
+ compute_tokens_config = parent_rpcs.compute_tokens if parent_rpcs.respond_to? :compute_tokens
517
+ @compute_tokens = ::Gapic::Config::Method.new compute_tokens_config
518
+
519
+ yield self if block_given?
520
+ end
521
+ end
522
+ end
523
+ end
524
+ end
525
+ end
526
+ end
527
+ end
528
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module AIPlatform
24
+ module V1
25
+ module LlmUtilityService
26
+ # Credentials for the LlmUtilityService API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "GOOGLE_CLOUD_CREDENTIALS",
33
+ "GOOGLE_CLOUD_KEYFILE",
34
+ "GCLOUD_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
36
+ "GOOGLE_CLOUD_KEYFILE_JSON",
37
+ "GCLOUD_KEYFILE_JSON"
38
+ ]
39
+ self.paths = [
40
+ "~/.config/google_cloud/application_default_credentials.json"
41
+ ]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module AIPlatform
23
+ module V1
24
+ module LlmUtilityService
25
+ # Path helper methods for the LlmUtilityService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Endpoint resource string.
29
+ #
30
+ # @overload endpoint_path(project:, location:, endpoint:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
34
+ #
35
+ # @param project [String]
36
+ # @param location [String]
37
+ # @param endpoint [String]
38
+ #
39
+ # @overload endpoint_path(project:, location:, publisher:, model:)
40
+ # The resource will be in the following format:
41
+ #
42
+ # `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`
43
+ #
44
+ # @param project [String]
45
+ # @param location [String]
46
+ # @param publisher [String]
47
+ # @param model [String]
48
+ #
49
+ # @return [::String]
50
+ def endpoint_path **args
51
+ resources = {
52
+ "endpoint:location:project" => (proc do |project:, location:, endpoint:|
53
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
54
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
55
+
56
+ "projects/#{project}/locations/#{location}/endpoints/#{endpoint}"
57
+ end),
58
+ "location:model:project:publisher" => (proc do |project:, location:, publisher:, model:|
59
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
60
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
61
+ raise ::ArgumentError, "publisher cannot contain /" if publisher.to_s.include? "/"
62
+
63
+ "projects/#{project}/locations/#{location}/publishers/#{publisher}/models/#{model}"
64
+ end)
65
+ }
66
+
67
+ resource = resources[args.keys.sort.join(":")]
68
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
69
+ resource.call(**args)
70
+ end
71
+
72
+ extend self
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end