Skip to contents

Upload batch file

Usage

file_upload(jsonl_path, purpose = "batch")

Arguments

jsonl_path

(chr) path to a file to upload

purpose

(chr, default = "batch") The intended purpose of the uploaded file. Use "assistants" for Assistants and Message files, "vision" for Assistants image file inputs, "batch" for Batch API, and "fine-tune" for Fine-tuning.

Value

(tibble) information about the uploaded file

Details

For more information, see

  • batch documentation.

  • file documentation.

    At the moment, 'gpteasyr' is tested on file upload for the batch API only (still it should work for the other also).

    Files for batch API Your input file must be formatted as a

    JSONL file.

    The file can contain up to 50,000 requests, can be up to 100 MB in size, and the size of all files uploaded by one organization can be up to 100 GB.

See also

Examples

 sys_prompt <- compose_sys_prompt("You are a funny assistant.")
 usr_prompt <- compose_usr_prompt(
   "Tell me a joke ending in:"
 )
 prompter <- create_usr_data_prompter(usr_prompt = usr_prompt)
 text <-  c(
   "deadly boring!",
   "A bit boring, but interesting",
   "How nice, I loved it!"
 )

 jsonl_text <- text |>
   purrr::map(
     \(x) {
       compose_prompt_api(
         sys_prompt = sys_prompt,
         usr_prompt = prompter(x)
       )
     }
   ) |>
   create_jsonl_records()
 out_jsonl_path <- write_jsonl_files(jsonl_text, tempdir())

uploaded_file_info <- file_upload(out_jsonl_path)
#> Error: API request failed [401]:
#> 
#> Invalid authorization header
file_delete(uploaded_file_info[["id"]])
#> Error: Failed to evaluate glue component {file_id}
#> Caused by error:
#> ! object 'uploaded_file_info' not found