Class: Compose::AIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/compose/ai_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ AIClient

Returns a new instance of AIClient.



9
10
11
# File 'lib/compose/ai_client.rb', line 9

def initialize(model)
  @model = model
end

Instance Method Details

#chat(system_prompt, user_prompt, temperature: 0) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/compose/ai_client.rb', line 13

def chat(system_prompt, user_prompt, temperature: 0)
  case @model[:provider]
  when 'anthropic'
    response = anthropic_chat(system_prompt, user_prompt, temperature: temperature)
    response.dig('content', 0, 'text')
  when 'openai'
    response = openai_chat(system_prompt, user_prompt, temperature: temperature)
    response
  else
    raise "Unsupported model: #{@model[:name]}"
  end
end