Class: OpenAI::Resources::Files
- Inherits:
-
Object
- Object
- OpenAI::Resources::Files
- Defined in:
- lib/openai/resources/files.rb
Instance Method Summary collapse
-
#content(file_id, request_options: {}) ⇒ StringIO
Returns the contents of the specified file.
-
#create(file: , purpose: , request_options: {}) ⇒ OpenAI::Models::FileObject
Some parameter documentations has been truncated, see Models::FileCreateParams for more details.
-
#delete(file_id, request_options: {}) ⇒ OpenAI::Models::FileDeleted
Delete a file.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::FileObject>
Some parameter documentations has been truncated, see Models::FileListParams for more details.
-
#retrieve(file_id, request_options: {}) ⇒ OpenAI::Models::FileObject
Returns information about a specific file.
Constructor Details
#initialize(client:) ⇒ Files
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 Files.
150 151 152 |
# File 'lib/openai/resources/files.rb', line 150 def initialize(client:) @client = client end |
Instance Method Details
#content(file_id, request_options: {}) ⇒ StringIO
Returns the contents of the specified file.
137 138 139 140 141 142 143 144 145 |
# File 'lib/openai/resources/files.rb', line 137 def content(file_id, params = {}) @client.request( method: :get, path: ["files/%1$s/content", file_id], headers: {"accept" => "application/binary"}, model: StringIO, options: params[:request_options] ) end |
#create(file: , purpose: , request_options: {}) ⇒ OpenAI::Models::FileObject
Some parameter documentations has been truncated, see Models::FileCreateParams for more details.
Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.
The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](platform.openai.com/docs/assistants/tools) for details.
The Fine-tuning API only supports ‘.jsonl` files. The input also has certain required formats for fine-tuning [chat](platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.
The Batch API only supports ‘.jsonl` files up to 200 MB in size. The input also has a specific required [format](platform.openai.com/docs/api-reference/batch/request-input).
Please [contact us](help.openai.com/) if you need to increase these storage limits.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openai/resources/files.rb', line 42 def create(params) parsed, = OpenAI::FileCreateParams.dump_request(params) @client.request( method: :post, path: "files", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: OpenAI::FileObject, options: ) end |
#delete(file_id, request_options: {}) ⇒ OpenAI::Models::FileDeleted
Delete a file.
117 118 119 120 121 122 123 124 |
# File 'lib/openai/resources/files.rb', line 117 def delete(file_id, params = {}) @client.request( method: :delete, path: ["files/%1$s", file_id], model: OpenAI::FileDeleted, options: params[:request_options] ) end |
#list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::FileObject>
Some parameter documentations has been truncated, see Models::FileListParams for more details.
Returns a list of files.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/openai/resources/files.rb', line 94 def list(params = {}) parsed, = OpenAI::FileListParams.dump_request(params) @client.request( method: :get, path: "files", query: parsed, page: OpenAI::Internal::CursorPage, model: OpenAI::FileObject, options: ) end |
#retrieve(file_id, request_options: {}) ⇒ OpenAI::Models::FileObject
Returns information about a specific file.
65 66 67 68 69 70 71 72 |
# File 'lib/openai/resources/files.rb', line 65 def retrieve(file_id, params = {}) @client.request( method: :get, path: ["files/%1$s", file_id], model: OpenAI::FileObject, options: params[:request_options] ) end |