Class: Genai::Model
- Inherits:
-
Object
- Object
- Genai::Model
- Defined in:
- lib/genai/model.rb
Constant Summary collapse
- OPENAI_ROLES =
{ "model" => "assistant", "assistant" => "assistant", "user" => "user", "system" => "system", "developer" => "developer", "tool" => "tool" }.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#model_id ⇒ Object
readonly
Returns the value of attribute model_id.
Instance Method Summary collapse
- #generate_content(contents:, tools: nil, config: nil, grounding: nil, **options) ⇒ Object
-
#initialize(client, model_id) ⇒ Model
constructor
A new instance of Model.
Constructor Details
#initialize(client, model_id) ⇒ Model
Returns a new instance of Model.
18 19 20 21 |
# File 'lib/genai/model.rb', line 18 def initialize(client, model_id) @client = client @model_id = model_id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/genai/model.rb', line 7 def client @client end |
#model_id ⇒ Object (readonly)
Returns the value of attribute model_id.
7 8 9 |
# File 'lib/genai/model.rb', line 7 def model_id @model_id end |
Instance Method Details
#generate_content(contents:, tools: nil, config: nil, grounding: nil, **options) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/genai/model.rb', line 23 def generate_content(contents:, tools: nil, config: nil, grounding: nil, **) raise Error, "grounding is not supported by OpenAI-compatible chat completions." if grounding request_body = build_request_body(contents: contents, tools: tools, config: config, **) response = make_request(request_body) parse_response(response) end |