Class: OpenAI::Files
- Inherits:
-
Object
- Object
- OpenAI::Files
- Defined in:
- lib/openai/files.rb
Instance Method Summary collapse
- #content(id:) ⇒ Object
- #delete(id:) ⇒ Object
-
#initialize(client:) ⇒ Files
constructor
A new instance of Files.
- #list ⇒ Object
- #retrieve(id:) ⇒ Object
- #upload(parameters: {}) ⇒ Object
Constructor Details
#initialize(client:) ⇒ Files
Returns a new instance of Files.
3 4 5 |
# File 'lib/openai/files.rb', line 3 def initialize(client:) @client = client end |
Instance Method Details
#content(id:) ⇒ Object
24 25 26 |
# File 'lib/openai/files.rb', line 24 def content(id:) @client.get(path: "/files/#{id}/content") end |
#delete(id:) ⇒ Object
28 29 30 |
# File 'lib/openai/files.rb', line 28 def delete(id:) @client.delete(path: "/files/#{id}") end |
#list ⇒ Object
7 8 9 |
# File 'lib/openai/files.rb', line 7 def list @client.get(path: "/files") end |
#retrieve(id:) ⇒ Object
20 21 22 |
# File 'lib/openai/files.rb', line 20 def retrieve(id:) @client.get(path: "/files/#{id}") end |
#upload(parameters: {}) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/openai/files.rb', line 11 def upload(parameters: {}) validate(file: parameters[:file]) if parameters[:file].include?(".jsonl") @client.multipart_post( path: "/files", parameters: parameters.merge(file: File.open(parameters[:file])) ) end |