Sha256: d19c950ea7ea73dd7690c6e71383e1cb73e5ddac9205b4fbe2f8bdf7798b8f03
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
module OpenAI class Files include HTTParty base_uri "https://api.openai.com" def initialize(access_token: nil) @access_token = access_token || ENV["OPENAI_ACCESS_TOKEN"] end def list(version: default_version) self.class.get( "/#{version}/files", headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@access_token}" } ) end def upload(version: default_version, parameters: {}) self.class.post( "/#{version}/files", headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@access_token}" }, body: parameters.merge(file: File.open(parameters[:file])) ) end def retrieve(id:, version: default_version) self.class.get( "/#{version}/files/#{id}", headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@access_token}" } ) end def delete(id:, version: default_version) self.class.delete( "/#{version}/files/#{id}", headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@access_token}" } ) end private def default_version "v1".freeze end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-openai-1.2.0 | lib/ruby/openai/files.rb |
ruby-openai-1.1.0 | lib/ruby/openai/files.rb |