conversation4R: Conversation Interface for R

View source: R/conversation4R.R

conversation4RR Documentation

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
)

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.

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.

Value

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

Author(s)

Satoshi Kume

Examples

## Not run: 
conversation4R(message = "Hello, OpenAI!",
               api_key = "your_api_key_here",
               language = "English",
               initialization = TRUE)

## End(Not run)

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