if (FALSE) {
Sys.setenv(Replicate_API_KEY = "Your API key")
input <- list(
input = list(
prompt = "What is the capital of France?",
max_tokens = 1024,
top_k = 50,
top_p = 0.9,
min_tokens = 0,
temperature = 0.6,
system_prompt = "You are a helpful assistant.",
presence_penalty = 0,
frequency_penalty = 0
)
)
model_url <- "/models/meta/meta-llama-3.1-405b-instruct/predictions"
# Default: collapse_tokens = TRUE (returns single string)
response <- replicatellmAPI4R(input, model_url, fetch_stream = TRUE)
print(response)
# [1] "The capital of France is Paris."
# Keep tokens separated
response_tokens <- replicatellmAPI4R(input, model_url, fetch_stream = TRUE,
collapse_tokens = FALSE)
print(response_tokens)
# [1] "The" " capital" " of" " France" " is" " Paris" "."
}
Run the code above in your browser using DataLab