Makes a chat completion request to OpenAI's API.
Usage
call_openai_chat(
system_prompt,
user_prompt,
model = "gpt-3.5-turbo",
temperature = 0,
max_tokens = 150,
api_key
)Arguments
- system_prompt
Character string with system instructions
- user_prompt
Character string with user message
- model
Character string specifying the model (default: "gpt-3.5-turbo")
- temperature
Numeric temperature for response randomness (default: 0)
- max_tokens
Maximum number of tokens to generate (default: 150)
- api_key
Character string with OpenAI API key
Examples
if (FALSE) { # \dontrun{
response <- call_openai_chat(
system_prompt = "You are a helpful assistant.",
user_prompt = "Generate a topic label for: education, student, learning",
api_key = Sys.getenv("OPENAI_API_KEY")
)
} # }
