Advice on chatgpt package

I've been trying to use the chatgpt package to learn more about chat gpt. I think I don't understand how to pass in my api key. After installing the package and library(chatgpt) I gave the command

explain_code("a <- 1;a=1")

and for told

Error in gpt_get_completions(prompt) : `OPENAI_API_KEY` not provided.

So I'm not sure how to pass in the OPENAI_API_KEY. When I tried using the function gpt_get_completions() I get told "could not find function "gpt_get_completions"

I'm sure this is user error on my end. Any guidance appreciated.

Just a guess: Try a statement in your code like

api_key = "mykey"

If you were assigned other codes, include them too, such as

access_token = "mytoken"

Worth a try, but nope...

ETA:

But

Sys.setenv(OPENAI_API_KEY = "put your key here")

does work. Proving once again how helpful @fcas80 is!

Just to follow-up. I fed a 200 line program into chatgpt through find_issues_in_code(). Some of the reports back were shockingly insightful. Others were just plain wrong, like saying a loop was missing a closing bracket when it wasn't.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.