chat4R_history: chat4R_history: Use chat history for interacting with GPT.

View source: R/chat4R_history.R

chat4R_historyR Documentation

chat4R_history: Use chat history for interacting with GPT.

Description

This function use the chat history with the the specified GPT model, and chat the AI model.

Usage

chat4R_history(
  history,
  api_key = Sys.getenv("OPENAI_API_KEY"),
  Model = "gpt-4o-mini",
  temperature = 1
)

Arguments

history

A list of message objects. Each object should have a 'role' that can be 'system', 'user', or 'assistant', and 'content' which is the content of the message from that role.

api_key

A string. Input your OpenAI API key. Defaults to the value of the environment variable "OPENAI_API_KEY".

Model

A string. The model to use for the chat completion. Default is "gpt-4o-mini".

temperature

The temperature to use for the chat completion. Default is 1.

Details

Chat History for R

Value

A data frame containing the parsed response from the Web API server.

Author(s)

Satoshi Kume

Examples

## Not run: 
Sys.setenv(OPENAI_API_KEY = "Your API key")

history <- list(list('role' = 'system', 'content' = 'You are a helpful assistant.'),
                list('role' = 'user', 'content' = 'Who won the world series in 2020?'))

chat4R_history(history)

## End(Not run)


chatAI4R documentation built on April 4, 2025, 1:06 a.m.