Class: Rasti::AI::OpenAI::Client

Inherits:
Client
  • Object
show all
Defined in:
lib/rasti/ai/open_ai/client.rb

Constant Summary

Constants inherited from Client

Client::RETRYABLE_STATUS_CODES

Instance Method Summary collapse

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from Rasti::AI::Client

Instance Method Details

#chat_completions(messages:, model: nil, tools: [], response_format: nil, reasoning_effort: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rasti/ai/open_ai/client.rb', line 6

def chat_completions(messages:, model:nil, tools:[], response_format:nil, reasoning_effort:nil)
  body = {
    model: model || Rasti::AI.openai_default_model,
    messages: messages,
    tools: tools,
    tool_choice: tools.empty? ? 'none' : 'auto'
  }

  body[:response_format]   = response_format   unless response_format.nil?
  body[:reasoning_effort]  = reasoning_effort  if reasoning_effort

  post '/chat/completions', body
end