Class: LLM::Response::File

Inherits:
LLM::Response show all
Defined in:
lib/llm/response/file.rb

Overview

The LLM::Response::File class represents a file that has been uploaded to a provider. Its properties are delegated to the underlying response body, and vary by provider.

Instance Method Summary collapse

Methods inherited from LLM::Response

#initialize

Constructor Details

This class inherits a constructor from LLM::Response

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (private)



34
35
36
37
38
39
40
# File 'lib/llm/response/file.rb', line 34

def method_missing(m, *args, &block)
  if body.key?(m.to_s)
    body[m.to_s]
  else
    super
  end
end

Instance Method Details

#bodyHash

Returns a normalized response body

Returns:

  • (Hash)


12
13
14
15
16
17
18
# File 'lib/llm/response/file.rb', line 12

def body
  @_body ||= if super["file"]
    super["file"].transform_keys { snakecase(_1) }
  else
    super.transform_keys { snakecase(_1) }
  end
end

#inspectString

Returns:

  • (String)


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

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)} body=#{body}>"
end