Learn R Programming

openaiRtools (version 0.2.2)

add_upload_part: Upload a File Part (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and uploads one part of a multipart upload. Call this repeatedly for each chunk of your file.

Usage

add_upload_part(upload_id, data)

Value

An upload part object with $id — save all part IDs to use in complete_upload().

Arguments

upload_id

Character. Required. The upload session ID returned by create_upload().

data

Raw. Required. The binary chunk to upload. Read from file with readBin(con, "raw", n = chunk_size).

Examples

Run this code
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")

chunk <- readBin("large_file.jsonl", "raw", n = 64 * 1024 * 1024)
part <- add_upload_part(upload_id = upload$id, data = chunk)
cat("Part ID:", part$id)
}

Run the code above in your browser using DataLab