Skip to contents

Retrieve file content

Usage

file_retrieve(file_id, convert_json = FALSE)

Arguments

file_id

(chr) The id of the file to retrieve.

convert_json

(lgl) If TRUE, convert the response to JSON.

Value

(chr) The content of the file.

See also

Other files: file_delete(), file_info(), file_list(), file_upload()

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_content <- file_retrieve(uploaded_file_info[["id"]])
#> Error: Failed to evaluate glue component {file_id}
#> Caused by error:
#> ! object 'uploaded_file_info' not found
file_delete(uploaded_file_info[["id"]])
#> Error: Failed to evaluate glue component {file_id}
#> Caused by error:
#> ! object 'uploaded_file_info' not found