Class: OpenAI::Files
- Inherits:
-
Object
- Object
- OpenAI::Files
- Defined in:
- lib/openai/files.rb
Constant Summary collapse
- PURPOSES =
%w[ assistants batch fine-tune vision ].freeze
Instance Method Summary collapse
- #content(id:) ⇒ Object
- #delete(id:) ⇒ Object
-
#initialize(client:) ⇒ Files
constructor
A new instance of Files.
- #list(parameters: {}) ⇒ Object
- #retrieve(id:) ⇒ Object
- #upload(parameters: {}) ⇒ Object
Constructor Details
#initialize(client:) ⇒ Files
Returns a new instance of Files.
10 11 12 |
# File 'lib/openai/files.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#content(id:) ⇒ Object
36 37 38 |
# File 'lib/openai/files.rb', line 36 def content(id:) @client.get(path: "/files/#{id}/content") end |
#delete(id:) ⇒ Object
40 41 42 |
# File 'lib/openai/files.rb', line 40 def delete(id:) @client.delete(path: "/files/#{id}") end |
#list(parameters: {}) ⇒ Object
14 15 16 |
# File 'lib/openai/files.rb', line 14 def list(parameters: {}) @client.get(path: "/files", parameters: parameters) end |
#retrieve(id:) ⇒ Object
32 33 34 |
# File 'lib/openai/files.rb', line 32 def retrieve(id:) @client.get(path: "/files/#{id}") end |
#upload(parameters: {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/openai/files.rb', line 18 def upload(parameters: {}) file_input = parameters[:file] file = prepare_file_input(file_input: file_input) validate(file: file, purpose: parameters[:purpose], file_input: file_input) @client.multipart_post( path: "/files", parameters: parameters.merge(file: file) ) ensure file.close if file.is_a?(File) end |