Learn R Programming

chatAI4R (version 0.3.6)

conversation4R: Conversation Interface for R

Description

Interface to communicate with OpenAI's models using R, maintaining a conversation history and allowing for initialization of a new conversation.

Usage

conversation4R(
  message,
  api_key = Sys.getenv("OPENAI_API_KEY"),
  system_set = "",
  ConversationBufferWindowMemory_k = 2,
  Model = "gpt-4o-mini",
  language = "English",
  initialization = FALSE,
  verbose = TRUE
)

Value

Prints the conversation if verbose is TRUE. No return value.

Arguments

message

A string containing the message to be sent to the model.

api_key

A string containing the OpenAI API key. Default is retrieved from the system environment variable "OPENAI_API_KEY".

system_set

A string containing the system_set for the conversation. Default is an empty string.

ConversationBufferWindowMemory_k

An integer representing the conversation buffer window memory. Default is 2.

Model

A string representing the model to be used. Default is "gpt-4o-mini".

language

A string representing the language to be used in the conversation. Default is "English".

initialization

A logical flag to initialize a new conversation. Default is FALSE.

verbose

A logical flag to print the conversation. Default is TRUE.

Author

Satoshi Kume

Details

Conversation Interface for R with OpenAI

This function provides an interface to communicate with OpenAI's models using R. It maintains a conversation history and allows for initialization of a new conversation.

Examples

Run this code
if (FALSE) {
conversation4R(message = "Hello, OpenAI!",
               api_key = "your_api_key_here",
               language = "English",
               initialization = TRUE)
}

Run the code above in your browser using DataLab