Learn R Programming

deliberr (version 0.1.0)

get_dri_llm_response: Get DRI LLM Response

Description

get_dri_llm_response uses https://openrouter.ai to generate artificial LLM responses to DRI survey questions

Usage

get_dri_llm_response(
  model_id,
  survey_info = list(type = NA_character_, order = NA_integer_, statement =
    NA_character_, name = NA_character_, scale_max = NA_integer_, q_method = NA),
  api_key = Sys.getenv("OPENROUTER_API_KEY"),
  role_info = list(uid = NA_character_, role = NA_character_, description =
    NA_character_),
  n = 1,
  request_log_path = NA_character_
)

Value

a dataframe with n survey responses by model_id, including a unique identifier, uuid, a creation timestamp, created_at_utc, the time it took to generate the response, time_s, the estimated cost in USD, est_cost_usd, whether the response is valid, is_valid, and the reason it is not, invalid_reason

Arguments

model_id

a model_id string from openrounter.ai

survey_info

a list with survey question information, including type, order, statement, name, scale_max, and q_method

api_key

the API key generated by OpenRouter

role_info

a named list with basic data of a role (i.e., uid, role, description)

n

the number of responses requested (default = 1)

request_log_path

an optional path to a file where the request texts are saved

See Also

get_model_ids() for all currently available model ids from openrouter.ai

Other LLM methods: get_model_ids(), make_dri_llm_prompts()

Examples

Run this code

# get DRI survey
survey_info <- surveys[surveys$name == "acp",]

# select a model from openrouter
model_id <- "google/gemini-2.5-flash-lite"

# send request to openrouter API
if (FALSE) {
llm_data <- get_dri_llm_response(model_id, survey_info)}

Run the code above in your browser using DataLab