Skip to contents

Generate text completions using HuggingFace's API

Usage

create_completion_huggingface(
  prompt,
  history = NULL,
  model = "tiiuae/falcon-7b-instruct",
  token = Sys.getenv("HF_API_KEY"),
  max_new_tokens = 250
)

Arguments

prompt

The prompt for generating completions

history

A list of the previous chat responses

model

The model to use for generating text

token

The API key for accessing HuggingFace's API. By default, the function will try to use the HF_API_KEY environment variable.

max_new_tokens

Maximum number of tokens to generate, defaults to 250

Value

A list with the generated completions and other information returned by the API.

Examples

if (FALSE) { # \dontrun{
create_completion_huggingface(
  model = "gpt2",
  prompt = "Hello world!"
)
} # }