Learn R Programming

chatRater (version 1.1.0)

generate_ratings: Generate Ratings for a Stimulus Using LLM APIs

Description

Generates ratings for a given stimulus by calling one of several LLM APIs.

Usage

generate_ratings(
  model = "gpt-3.5-turbo",
  stim = "kick the bucket",
  prompt = "You are a native English speaker.",
  question = "Please rate the following stim:",
  top_p = 1,
  temp = 0,
  n_iterations = 30,
  api_key = "",
  debug = FALSE
)

Value

A data frame containing the stimulus, the rating, and the iteration number.

Arguments

model

A character string specifying the LLM model (e.g., "gpt-3.5-turbo", "deepseek-chat").

stim

A character string representing the stimulus (e.g., an idiom).

prompt

A character string for the system prompt (e.g., "You are a native English speaker.").

question

A character string for the user prompt (e.g., "Please rate the following stim:").

top_p

Numeric value for the probability mass (default 1).

temp

Numeric value for the temperature (default 0).

n_iterations

An integer indicating how many times to query the API.

api_key

API key as a character string.

debug

Logical; if TRUE, debug information is printed.

Details

This function supports multiple APIs. Branching is based on the model parameter.

Examples

Run this code
if (FALSE) {
  ratings <- generate_ratings(
    model = "gpt-3.5-turbo",
    stim = "kick the bucket",
    prompt = "You are a native English speaker.",
    question = "Please rate the following stim:",
    n_iterations = 5,
    api_key = "your_api_key"
  )
  print(ratings)
}

Run the code above in your browser using DataLab