Skip to content

Using the LLM functionality in assertHE

Robert Smith edited this page Jul 23, 2024 · 1 revision

LLM summary

assertHE includes the ability to generate a LLM generated function summary of a specific function. This can be achieved by clicking on the Robot Icon on the function node in the project visualiser.

Setting System Variables

The package currently uses OpenAI's GPT-3.5 API, which requires an account to be set up with OpenAI.

To use this, you must have two system environment variables on your machine. One for the API URL and another for the API KEY. If you want to do this as a one-off they can be created like this:

Sys.setenv(LLM_API_URL = "https://api.openai.com/v1/chat/completions")
Sys.setenv(LLM_API_KEY = <INSERT KEY HERE>)

To get the KEY, create an OpenAI account or sign in. Next, navigate to the API key page and "Create new secret key", optionally naming the key. Make sure to save this somewhere safe and do not share it with anyone.

However, if you want R to always have access to these system environment variables you'll want to follow this guide.

Personally, I have a .Renviron file stored in my Documents folder that contains among other things, OPENAIKEY = <MY KEY>. This is loaded every time I open RStudio so I can always access those environment variables.