Class: Openai::Chat::Completions

Inherits:
Resource::Api show all
Defined in:
lib/openai/chat/completions.rb

Instance Attribute Summary

Attributes inherited from Resource::Api

#connection, #data, #path, #response

Instance Method Summary collapse

Constructor Details

#initializeCompletions

Returns a new instance of Completions.



6
7
8
9
# File 'lib/openai/chat/completions.rb', line 6

def initialize
  @path = "/v1/chat/completions"
  super()
end

Instance Method Details

#request(params) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/openai/chat/completions.rb', line 11

def request(params)
  @response = @connection.post(
    path: @path,
    body: ::Openai::Request::Chat::Completion.new(**params).to_json
  )
  @data = ::Openai::Mapper::Chat::Completions.from_json(@response.body)
end