File size: 616 Bytes
f9e7b9c
 
 
 
a59174a
1dd1e45
 
 
 
f9e7b9c
 
f23dbdb
 
1dd1e45
f23dbdb
f9e7b9c
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

library(httr2)
library(jsonlite)

base_url <- "http://localhost:7860"
bearer_token <- trimws(Sys.getenv("ASA_API_BEARER_TOKEN", unset = ""))
if (!nzchar(bearer_token)) {
  stop("Set ASA_API_BEARER_TOKEN before running this example.", call. = FALSE)
}

resp <- request(paste0(base_url, "/v1/run")) |>
  req_headers(
    `Content-Type` = "application/json",
    Authorization = sprintf("Bearer %s", bearer_token)
  ) |>
  req_body_json(list(prompt = "Return the single word OK."), auto_unbox = TRUE) |>
  req_perform()

result <- resp_body_json(resp, simplifyVector = TRUE)
print(result$status)
print(result$message)