Class: CoachZed::Clients::RubyOpenAI

Inherits:
Object
  • Object
show all
Defined in:
lib/coach_zed/clients/ruby_openai.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, model: "gpt-4.1") ⇒ RubyOpenAI

Returns a new instance of RubyOpenAI.



8
9
10
11
# File 'lib/coach_zed/clients/ruby_openai.rb', line 8

def initialize(client:, model: "gpt-4.1")
  @client = client
  @model = model
end

Instance Method Details

#generate(prompt:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coach_zed/clients/ruby_openai.rb', line 13

def generate(prompt:)
  response = client.chat(parameters: {
    model: model,
    messages: [{role: "user", content: prompt}],
    response_format: {
      type: "json_schema",
      json_schema: {
        name: "coach_zed_schedule",
        schema: CoachZed::ScheduleSchema.to_h,
        strict: true
      }
    }
  })
  extract_content(response)
end