Learn R Programming

sdcMicro (version 5.8.0)

query_llm_for_roles: #' Query LLM to Classify Variable Roles

Description

Sends a prompt to the OpenAI API to classify dataset variables into anonymization roles for use with the sdcMicro package. If the API key is not provided or set via `Sys.getenv("OPENAI_API_KEY")`, the function will prompt for it interactively.

Usage

query_llm_for_roles(prompt, model = "gpt-4", api_key = NULL)

Value

A named list with fields `keyVars`, `pramVars`, `numVars`, `weightVar`, `strataVar`, `hhId`. Fields are either character vectors (possibly empty) or NULL.

Arguments

prompt

A character string prompt for the LLM.

model

The OpenAI model to use (e.g., "gpt-4").

api_key

Optional. If not provided, defaults to environment variable OPENAI_API_KEY.

Author

Matthias Templ