Package 'air'

Title: AI Assistant to Write and Understand R Code
Description: An R console utility that lets you ask R related questions to the 'OpenAI' large language model. It can answer 'how-to()' questions by providing code, and 'whatis()' questions by explaining what given code does. You must provision your own key for the 'OpenAI' API <https://platform.openai.com/docs/api-reference>.
Authors: Soumya Ray [aut, cre, cph]
Maintainer: Soumya Ray <[email protected]>
License: MIT + file LICENSE
Version: 0.2.2
Built: 2024-11-20 05:05:28 UTC
Source: https://github.com/soumyaray/air

Help Index


Deletes your securely stored OpenAI API key and preferred model from your OS keyring.

Description

Deletes your securely stored OpenAI API key and preferred model from your OS keyring.

Usage

delete_keyring_credentials()

Value

result list of success or failure class with:

status

A character string of operation status.

value

A character string of descriptive message of status.

Examples

# CAREFUL: Deletes OpenAI API key and preferred model from your OS keyring
## Not run: 
delete_keyring_credentials()

## End(Not run)

Ask OpenAI to write R code for a problem. The answer is written to console and returned as a string.

Description

Ask OpenAI to write R code for a problem. The answer is written to console and returned as a string.

Usage

howto(do, call_api = call_openai)

Arguments

do

Character string of what you want to do

call_api

Optional function to call another API

Value

Invisible character string of R code

Examples

# You must provision an OpenAI API key before using this function.
## Not run: 
howto("read a csv file")
howto("get last element of a vector")

## End(Not run)

Securely stores your your OpenAI API key to your OS keyring.

Description

Securely stores your your OpenAI API key to your OS keyring.

Usage

set_key(key = NULL)

Arguments

key

Optional string of your OpenAI API key; if not provided, a popup will ask you to enter it (safer).

Value

No return value; only side-effect and message printed to console

Examples

# CAREFUL: Changes your OpenAI API key in your OS keyring
## Not run: 
set_key("sk-my-api-key") # sets the key directly (will show in .Rhistory)
set_key()                # opens a system popup for secure entry

## End(Not run)

Securely stores your your OpenAI API key to your OS keyring.

Description

Securely stores your your OpenAI API key to your OS keyring.

Usage

set_model(model = "gpt-4")

Arguments

model

String of your preferred model; defaults to 'gpt-4'.

Value

No return value; only side-effect and message printed to console

Examples

# CAREFUL: Changes your OpenAI API model in your OS keyring
## Not run: 
set_model("gpt-4-1106-preview")
set_model() # use default

## End(Not run)

Ask OpenAI to explain what given R code does. The answer is written to console and returned as a string.

Description

Ask OpenAI to explain what given R code does. The answer is written to console and returned as a string.

Usage

whatis(this, call_api = call_openai)

Arguments

this

Character string of code to be explained

call_api

Optional function to call another API

Value

Invisible character string of explanation

Examples

# You must provision an OpenAI API key before using this function.
## Not run: 
whatis("paste0(vector1, vector2)")
whatis("length(x) %% 2 == 1 ? x[(length(x) + 1) / 2] : NA")

## End(Not run)