Class: Geminize::Models::Model
- Inherits:
-
Object
- Object
- Geminize::Models::Model
- Defined in:
- lib/geminize/models/model.rb
Overview
Represents an AI model from the Gemini API.
Instance Attribute Summary collapse
-
#base_model_id ⇒ String
readonly
The base model ID.
-
#description ⇒ String
readonly
The model description.
-
#display_name ⇒ String
readonly
The display name of the model.
-
#input_token_limit ⇒ Integer
readonly
Maximum number of input tokens allowed.
-
#max_temperature ⇒ Float
readonly
Maximum allowed temperature.
-
#name ⇒ String
readonly
The resource name of the model.
-
#output_token_limit ⇒ Integer
readonly
Maximum number of output tokens available.
-
#raw_data ⇒ Hash
readonly
Raw model data from the API.
-
#supported_generation_methods ⇒ Array<String>
readonly
Supported generation methods.
-
#temperature ⇒ Float
readonly
Default temperature.
-
#top_k ⇒ Integer
readonly
Default top_k value for sampling.
-
#top_p ⇒ Float
readonly
Default top_p value for nucleus sampling.
-
#version ⇒ String
readonly
The model version.
Class Method Summary collapse
-
.from_api_data(data) ⇒ Model
Create a Model from API response data.
Instance Method Summary collapse
-
#id ⇒ String
Shorthand accessor for the model ID (last part of the name path).
-
#initialize(attributes = {}) ⇒ Model
constructor
Create a new Model instance.
-
#supports_content_generation? ⇒ Boolean
Check if model supports content generation.
-
#supports_embedding? ⇒ Boolean
Check if model supports embedding generation.
-
#supports_message_generation? ⇒ Boolean
Check if model supports message generation (chat).
-
#supports_method?(method) ⇒ Boolean
Check if model supports a specific generation method.
-
#supports_streaming? ⇒ Boolean
Check if model supports streaming content generation.
-
#to_h ⇒ Hash
Convert model to a hash representation.
-
#to_json(*args) ⇒ String
Convert model to JSON string.
Constructor Details
#initialize(attributes = {}) ⇒ Model
Create a new Model instance
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/geminize/models/model.rb', line 61 def initialize(attributes = {}) @name = attributes[:name] @base_model_id = attributes[:base_model_id] @version = attributes[:version] @display_name = attributes[:display_name] @description = attributes[:description] @input_token_limit = attributes[:input_token_limit] @output_token_limit = attributes[:output_token_limit] @supported_generation_methods = attributes[:supported_generation_methods] || [] @temperature = attributes[:temperature] @max_temperature = attributes[:max_temperature] @top_p = attributes[:top_p] @top_k = attributes[:top_k] @raw_data = attributes[:raw_data] || {} end |
Instance Attribute Details
#base_model_id ⇒ String (readonly)
Returns The base model ID.
11 12 13 |
# File 'lib/geminize/models/model.rb', line 11 def base_model_id @base_model_id end |
#description ⇒ String (readonly)
Returns The model description.
20 21 22 |
# File 'lib/geminize/models/model.rb', line 20 def description @description end |
#display_name ⇒ String (readonly)
Returns The display name of the model.
17 18 19 |
# File 'lib/geminize/models/model.rb', line 17 def display_name @display_name end |
#input_token_limit ⇒ Integer (readonly)
Returns Maximum number of input tokens allowed.
23 24 25 |
# File 'lib/geminize/models/model.rb', line 23 def input_token_limit @input_token_limit end |
#max_temperature ⇒ Float (readonly)
Returns Maximum allowed temperature.
35 36 37 |
# File 'lib/geminize/models/model.rb', line 35 def max_temperature @max_temperature end |
#name ⇒ String (readonly)
Returns The resource name of the model.
8 9 10 |
# File 'lib/geminize/models/model.rb', line 8 def name @name end |
#output_token_limit ⇒ Integer (readonly)
Returns Maximum number of output tokens available.
26 27 28 |
# File 'lib/geminize/models/model.rb', line 26 def output_token_limit @output_token_limit end |
#raw_data ⇒ Hash (readonly)
Returns Raw model data from the API.
44 45 46 |
# File 'lib/geminize/models/model.rb', line 44 def raw_data @raw_data end |
#supported_generation_methods ⇒ Array<String> (readonly)
Returns Supported generation methods.
29 30 31 |
# File 'lib/geminize/models/model.rb', line 29 def supported_generation_methods @supported_generation_methods end |
#temperature ⇒ Float (readonly)
Returns Default temperature.
32 33 34 |
# File 'lib/geminize/models/model.rb', line 32 def temperature @temperature end |
#top_k ⇒ Integer (readonly)
Returns Default top_k value for sampling.
41 42 43 |
# File 'lib/geminize/models/model.rb', line 41 def top_k @top_k end |
#top_p ⇒ Float (readonly)
Returns Default top_p value for nucleus sampling.
38 39 40 |
# File 'lib/geminize/models/model.rb', line 38 def top_p @top_p end |
#version ⇒ String (readonly)
Returns The model version.
14 15 16 |
# File 'lib/geminize/models/model.rb', line 14 def version @version end |
Class Method Details
.from_api_data(data) ⇒ Model
Create a Model from API response data
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/geminize/models/model.rb', line 144 def self.from_api_data(data) new( name: data["name"], base_model_id: data["baseModelId"], version: data["version"], display_name: data["displayName"], description: data["description"], input_token_limit: data["inputTokenLimit"], output_token_limit: data["outputTokenLimit"], supported_generation_methods: data["supportedGenerationMethods"] || [], temperature: data["temperature"], max_temperature: data["maxTemperature"], top_p: data["topP"], top_k: data["topK"], raw_data: data ) end |
Instance Method Details
#id ⇒ String
Shorthand accessor for the model ID (last part of the name path)
79 80 81 82 |
# File 'lib/geminize/models/model.rb', line 79 def id return nil unless @name @name.split("/").last end |
#supports_content_generation? ⇒ Boolean
Check if model supports content generation
93 94 95 |
# File 'lib/geminize/models/model.rb', line 93 def supports_content_generation? supports_method?("generateContent") end |
#supports_embedding? ⇒ Boolean
Check if model supports embedding generation
105 106 107 |
# File 'lib/geminize/models/model.rb', line 105 def supports_method?("embedContent") end |
#supports_message_generation? ⇒ Boolean
Check if model supports message generation (chat)
99 100 101 |
# File 'lib/geminize/models/model.rb', line 99 def supports_method?("generateMessage") end |
#supports_method?(method) ⇒ Boolean
Check if model supports a specific generation method
87 88 89 |
# File 'lib/geminize/models/model.rb', line 87 def supports_method?(method) supported_generation_methods.include?(method.to_s) end |
#supports_streaming? ⇒ Boolean
Check if model supports streaming content generation
111 112 113 |
# File 'lib/geminize/models/model.rb', line 111 def supports_streaming? supports_method?("streamGenerateContent") end |
#to_h ⇒ Hash
Convert model to a hash representation
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/geminize/models/model.rb', line 117 def to_h { name: name, id: id, base_model_id: base_model_id, version: version, display_name: display_name, description: description, input_token_limit: input_token_limit, output_token_limit: output_token_limit, supported_generation_methods: supported_generation_methods, temperature: temperature, max_temperature: max_temperature, top_p: top_p, top_k: top_k } end |
#to_json(*args) ⇒ String
Convert model to JSON string
137 138 139 |
# File 'lib/geminize/models/model.rb', line 137 def to_json(*args) to_h.to_json(*args) end |