Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions gems/google-cloud-ai_platform-v1/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This configuration inherits from /.rubocop.yml.
# You can configure RBS style of this gem.
# This file is used on CI. It is configured to automatically
# make rubocop suggestions on pull requests for this gem.
# If you do not like the style enforcement, you should remove this file.
inherit_from: ../../.rubocop.yml

##
# If you want to customize the style, please consult with the gem reviewers.
# You can see the list of cops at https://github.com/ksss/rubocop-on-rbs/blob/main/docs/modules/ROOT/pages/cops.adoc

RBS/Layout:
Enabled: true

RBS/Lint:
Enabled: true

RBS/Style:
Enabled: true
4 changes: 4 additions & 0 deletions gems/google-cloud-ai_platform-v1/1.15/_test/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# If the test needs gem's RBS files, declare them here.
#
# additional_gems:
# - GEM_NAME
38 changes: 38 additions & 0 deletions gems/google-cloud-ai_platform-v1/1.15/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

require "google-cloud-ai_platform-v1"

client = Google::Cloud::AIPlatform::V1::PredictionService::Client.new

Google::Cloud::AIPlatform::V1::PredictionService::Client.new do |config|
config.endpoint = "aiplatform.googleapis.com"
config.timeout = 30.0
end

response = client.generate_content({
model: "projects/my-project/locations/us-central1/publishers/google/models/gemini-pro",
contents: [{ role: "USER", parts: [{ text: "Hello" }] }]
})

request = Google::Cloud::AIPlatform::V1::GenerateContentRequest.new
request.model = "projects/my-project/locations/us-central1/publishers/google/models/gemini-pro"
request.contents = []
response2 = client.generate_content(request)

candidates = response.candidates
candidates2 = response2.candidates

candidate = candidates.first
if candidate
content = candidate.content
_finish_reason = candidate.finish_reason

_role = content.role
parts = content.parts

part = parts.first
_text = part.text if part
end

candidate2 = candidates2.first
_content2 = candidate2.content if candidate2
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module Google
module Cloud
module AIPlatform
module V1
class Part
attr_accessor text: ::String
end

class Content
attr_accessor role: ::String

attr_accessor parts: ::Array[Part]
end

class Candidate
def content: () -> Content

def finish_reason: () -> ::Integer
end

class GenerateContentResponse
def candidates: () -> ::Array[Candidate]
end

class GenerateContentRequest
attr_accessor model: ::String

attr_accessor contents: ::Array[Content]
end

module PredictionService
class Client
class Configuration
attr_accessor endpoint: ::String?

attr_accessor timeout: ::Numeric?
end

def initialize: () -> void
| () { (Configuration) -> void } -> void

def generate_content: (::Hash[untyped, untyped] request) -> GenerateContentResponse
| (GenerateContentRequest request) -> GenerateContentResponse
end
end
end
end
end
end