Class: Rasti::AI::OpenAI::Client
- Inherits:
-
Object
- Object
- Rasti::AI::OpenAI::Client
- Defined in:
- lib/rasti/ai/open_ai/client.rb
Constant Summary collapse
- BASE_URL =
'https://api.openai.com/v1'.freeze
Instance Method Summary collapse
- #chat_completions(messages:, model: nil, tools: [], response_format: nil) ⇒ Object
-
#initialize(api_key: nil, logger: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
Instance Method Details
#chat_completions(messages:, model: nil, tools: [], response_format: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rasti/ai/open_ai/client.rb', line 13 def chat_completions(messages:, model:nil, tools:[], response_format: nil) body = { model: model || Rasti::AI.openai_default_model, messages: , tools: tools, tool_choice: tools.empty? ? 'none' : 'auto' } body[:response_format] = response_format unless response_format.nil? post '/chat/completions', body end |