Class: LLM::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/response.rb

Defined Under Namespace

Classes: Audio, AudioTranscription, AudioTranslation, Completion, DownloadFile, Embedding, File, FileList, Image, ModelList, Output

Instance Method Summary collapse

Constructor Details

#initialize(res) ⇒ LLM::Response

Returns an instance of LLM::Response

Parameters:

  • res (Net::HTTPResponse)

    HTTP response

[View source]

23
24
25
# File 'lib/llm/response.rb', line 23

def initialize(res)
  @res = res
end

Instance Method Details

#bodyHash, String

Returns the response body

Returns:

  • (Hash, String)
[View source]

30
31
32
33
34
35
# File 'lib/llm/response.rb', line 30

def body
  @body ||= case @res["content-type"]
  when %r|\Aapplication/json\s*| then JSON.parse(@res.body)
  else @res.body
  end
end