llm_api_call: Base LLM API Call Wrapper

View source: R/chatRater.R

llm_api_callR Documentation

Base LLM API Call Wrapper

Description

Sends a prompt (with background academic definitions) to an LLM API (defaulting to 'OpenAI') and returns the LLM response.

Usage

llm_api_call(
  prompt_text,
  model = "gpt-3.5-turbo",
  api_key = "",
  top_p = 1,
  temp = 0
)

Arguments

prompt_text

A character string containing the user prompt.

model

A character string specifying the LLM model (default "gpt-3.5-turbo").

api_key

API key as a character string.

top_p

Numeric value for the probability mass (default 1).

temp

Numeric value for the sampling temperature (default 0).

Details

The system prompt includes academic definitions for word frequency, lexical coverage, Zipf's law, Levenshtein distance, and semantic transparency.

Value

A character string containing the LLM's response.

Examples

## Not run: 
  response <- llm_api_call("Please provide a rating for the stimulus 'apple'.")
  cat(response)

## End(Not run)

chatRater documentation built on April 4, 2025, 1:03 a.m.