Class: Google::Genai::Tokens
- Inherits:
-
Object
- Object
- Google::Genai::Tokens
- Defined in:
- lib/google/genai/tokens.rb
Instance Method Summary collapse
- #create(config: nil) ⇒ Object
-
#initialize(api_client) ⇒ Tokens
constructor
A new instance of Tokens.
Constructor Details
#initialize(api_client) ⇒ Tokens
Returns a new instance of Tokens.
8 9 10 |
# File 'lib/google/genai/tokens.rb', line 8 def initialize(api_client) @api_client = api_client end |
Instance Method Details
#create(config: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/google/genai/tokens.rb', line 12 def create(config: nil) raise "Tokens is only supported for Gemini API" if @api_client.vertexai # This is a simplified port of the Python SDK's logic. # The full logic for field masks is complex and will be implemented later. body = {} body[:expireTime] = config[:expire_time] if config&.key?(:expire_time) body[:uses] = config[:uses] if config&.key?(:uses) if config&.key?(:live_connect_constraints) # This part of the conversion is complex and will require more detailed mapping. # For now, we'll pass a simplified version. body[:bidiGenerateContentSetup] = { setup: { model: config[:live_connect_constraints][:model] } } if config[:live_connect_constraints][:config] body[:bidiGenerateContentSetup][:setup][:generationConfig] = config[:live_connect_constraints][:config] end end response = @api_client.request(:post, "v1alpha/authTokens", body: body) Types::AuthToken.new(JSON.parse(response.body)) end |