Class: OpenAI::Resources::Uploads
- Inherits:
-
Object
- Object
- OpenAI::Resources::Uploads
- Defined in:
- lib/openai/resources/uploads.rb,
lib/openai/resources/uploads/parts.rb
Defined Under Namespace
Classes: Parts
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#cancel(upload_id, request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCancelParams for more details.
-
#complete(upload_id, part_ids: , md5: nil, request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCompleteParams for more details.
-
#create(bytes: , filename: , mime_type: , purpose: , request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCreateParams for more details.
-
#initialize(client:) ⇒ Uploads
constructor
private
A new instance of Uploads.
Constructor Details
#initialize(client:) ⇒ Uploads
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Uploads.
119 120 121 122 |
# File 'lib/openai/resources/uploads.rb', line 119 def initialize(client:) @client = client @parts = OpenAI::Resources::Uploads::Parts.new(client: client) end |
Instance Attribute Details
#parts ⇒ OpenAI::Resources::Uploads::Parts (readonly)
7 8 9 |
# File 'lib/openai/resources/uploads.rb', line 7 def parts @parts end |
Instance Method Details
#cancel(upload_id, request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCancelParams for more details.
Cancels the Upload. No Parts may be added after an Upload is cancelled.
66 67 68 69 70 71 72 73 |
# File 'lib/openai/resources/uploads.rb', line 66 def cancel(upload_id, params = {}) @client.request( method: :post, path: ["uploads/%1$s/cancel", upload_id], model: OpenAI::Upload, options: params[:request_options] ) end |
#complete(upload_id, part_ids: , md5: nil, request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCompleteParams for more details.
Completes the [Upload](platform.openai.com/docs/api-reference/uploads/object).
Within the returned Upload object, there is a nested [File](platform.openai.com/docs/api-reference/files/object) object that is ready to use in the rest of the platform.
You can specify the order of the Parts by passing in an ordered list of the Part IDs.
The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/openai/resources/uploads.rb', line 105 def complete(upload_id, params) parsed, = OpenAI::UploadCompleteParams.dump_request(params) @client.request( method: :post, path: ["uploads/%1$s/complete", upload_id], body: parsed, model: OpenAI::Upload, options: ) end |
#create(bytes: , filename: , mime_type: , purpose: , request_options: {}) ⇒ OpenAI::Models::Upload
Some parameter documentations has been truncated, see Models::UploadCreateParams for more details.
Creates an intermediate [Upload](platform.openai.com/docs/api-reference/uploads/object) object that you can add [Parts](platform.openai.com/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it.
Once you complete the Upload, we will create a [File](platform.openai.com/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object.
For certain ‘purpose` values, the correct `mime_type` must be specified. Please refer to documentation for the [supported MIME types for your use case](platform.openai.com/docs/assistants/tools/file-search#supported-files).
For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](platform.openai.com/docs/api-reference/files/create).
47 48 49 50 |
# File 'lib/openai/resources/uploads.rb', line 47 def create(params) parsed, = OpenAI::UploadCreateParams.dump_request(params) @client.request(method: :post, path: "uploads", body: parsed, model: OpenAI::Upload, options: ) end |