library(openai) library(palmerpenguins) library(tidymodels) # OpenAI API 키 설정 Sys.setenv(OPENAI_API_KEY = "sk-proj-*****) # 지시문 작성 penguins_classification_instruction <- " Build sex classification machine learning model with the Palmer penguin dataset Use the palmer penguins data package for the dataset Use the tidymodels framework Use a random forest model Include evaluation metrics including accuracy, precision, recall " # API 호출을 통해 코드 생성 response <- openai::create_completion( model = "gpt-3.5-turbo-instruct", prompt = penguins_classification_instruction, max_tokens = 2000, n = 1, stop = NULL ) # 생성된 코드를 가져오기 generated_code <- response$choices$text[1] # 생성된 코드 출력 cat(generated_code)