Class: OpenApiOpenAIClient::FilesApi
- Inherits:
-
Object
- Object
- OpenApiOpenAIClient::FilesApi
- Defined in:
- lib/openapi_openai/api/files_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_file(file, purpose, opts = {}) ⇒ OpenAIFile
Upload a file that can be used across various endpoints.
-
#create_file_with_http_info(file, purpose, opts = {}) ⇒ Array<(OpenAIFile, Integer, Hash)>
Upload a file that can be used across various endpoints.
-
#delete_file(file_id, opts = {}) ⇒ DeleteFileResponse
Delete a file.
-
#delete_file_with_http_info(file_id, opts = {}) ⇒ Array<(DeleteFileResponse, Integer, Hash)>
Delete a file.
-
#download_file(file_id, opts = {}) ⇒ String
Returns the contents of the specified file.
-
#download_file_with_http_info(file_id, opts = {}) ⇒ Array<(String, Integer, Hash)>
Returns the contents of the specified file.
-
#initialize(api_client = ApiClient.default) ⇒ FilesApi
constructor
A new instance of FilesApi.
-
#list_files(opts = {}) ⇒ ListFilesResponse
Returns a list of files that belong to the user’s organization.
-
#list_files_with_http_info(opts = {}) ⇒ Array<(ListFilesResponse, Integer, Hash)>
Returns a list of files that belong to the user's organization.
-
#retrieve_file(file_id, opts = {}) ⇒ OpenAIFile
Returns information about a specific file.
-
#retrieve_file_with_http_info(file_id, opts = {}) ⇒ Array<(OpenAIFile, Integer, Hash)>
Returns information about a specific file.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/openapi_openai/api/files_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_file(file, purpose, opts = {}) ⇒ OpenAIFile
Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports ‘.jsonl` files. Please [contact us](help.openai.com/) if you need to increase these storage limits.
27 28 29 30 |
# File 'lib/openapi_openai/api/files_api.rb', line 27 def create_file(file, purpose, opts = {}) data, _status_code, _headers = create_file_with_http_info(file, purpose, opts) data end |
#create_file_with_http_info(file, purpose, opts = {}) ⇒ Array<(OpenAIFile, Integer, Hash)>
Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files. Please [contact us](help.openai.com/) if you need to increase these storage limits.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/openapi_openai/api/files_api.rb', line 37 def create_file_with_http_info(file, purpose, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FilesApi.create_file ...' end # verify the required parameter 'file' is set if @api_client.config.client_side_validation && file.nil? fail ArgumentError, "Missing the required parameter 'file' when calling FilesApi.create_file" end # verify the required parameter 'purpose' is set if @api_client.config.client_side_validation && purpose.nil? fail ArgumentError, "Missing the required parameter 'purpose' when calling FilesApi.create_file" end # verify enum value allowable_values = ["fine-tune", "assistants"] if @api_client.config.client_side_validation && !allowable_values.include?(purpose) fail ArgumentError, "invalid value for \"purpose\", must be one of #{allowable_values}" end # resource path local_var_path = '/files' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['file'] = file form_params['purpose'] = purpose # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OpenAIFile' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"FilesApi.create_file", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FilesApi#create_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#delete_file(file_id, opts = {}) ⇒ DeleteFileResponse
Delete a file.
105 106 107 108 |
# File 'lib/openapi_openai/api/files_api.rb', line 105 def delete_file(file_id, opts = {}) data, _status_code, _headers = delete_file_with_http_info(file_id, opts) data end |
#delete_file_with_http_info(file_id, opts = {}) ⇒ Array<(DeleteFileResponse, Integer, Hash)>
Delete a file.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/openapi_openai/api/files_api.rb', line 114 def delete_file_with_http_info(file_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FilesApi.delete_file ...' end # verify the required parameter 'file_id' is set if @api_client.config.client_side_validation && file_id.nil? fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.delete_file" end # resource path local_var_path = '/files/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'DeleteFileResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"FilesApi.delete_file", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FilesApi#delete_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#download_file(file_id, opts = {}) ⇒ String
Returns the contents of the specified file.
166 167 168 169 |
# File 'lib/openapi_openai/api/files_api.rb', line 166 def download_file(file_id, opts = {}) data, _status_code, _headers = download_file_with_http_info(file_id, opts) data end |
#download_file_with_http_info(file_id, opts = {}) ⇒ Array<(String, Integer, Hash)>
Returns the contents of the specified file.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/openapi_openai/api/files_api.rb', line 175 def download_file_with_http_info(file_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FilesApi.download_file ...' end # verify the required parameter 'file_id' is set if @api_client.config.client_side_validation && file_id.nil? fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.download_file" end # resource path local_var_path = '/files/{file_id}/content'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'String' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"FilesApi.download_file", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FilesApi#download_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_files(opts = {}) ⇒ ListFilesResponse
Returns a list of files that belong to the user’s organization.
227 228 229 230 |
# File 'lib/openapi_openai/api/files_api.rb', line 227 def list_files(opts = {}) data, _status_code, _headers = list_files_with_http_info(opts) data end |
#list_files_with_http_info(opts = {}) ⇒ Array<(ListFilesResponse, Integer, Hash)>
Returns a list of files that belong to the user's organization.
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/openapi_openai/api/files_api.rb', line 236 def list_files_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FilesApi.list_files ...' end # resource path local_var_path = '/files' # query parameters query_params = opts[:query_params] || {} query_params[:'purpose'] = opts[:'purpose'] if !opts[:'purpose'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ListFilesResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"FilesApi.list_files", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FilesApi#list_files\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#retrieve_file(file_id, opts = {}) ⇒ OpenAIFile
Returns information about a specific file.
285 286 287 288 |
# File 'lib/openapi_openai/api/files_api.rb', line 285 def retrieve_file(file_id, opts = {}) data, _status_code, _headers = retrieve_file_with_http_info(file_id, opts) data end |
#retrieve_file_with_http_info(file_id, opts = {}) ⇒ Array<(OpenAIFile, Integer, Hash)>
Returns information about a specific file.
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/openapi_openai/api/files_api.rb', line 294 def retrieve_file_with_http_info(file_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FilesApi.retrieve_file ...' end # verify the required parameter 'file_id' is set if @api_client.config.client_side_validation && file_id.nil? fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.retrieve_file" end # resource path local_var_path = '/files/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'OpenAIFile' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"FilesApi.retrieve_file", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FilesApi#retrieve_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |