This function constructs a detailed prompt with specific IDPs, Outcomes, Domains, scoring principles, and desired output format, then queries an LLM (Groq or OpenRouter) to generate a complete plausibility table.

generate_plausibility_table_direct(
  backend = c("groq", "openrouter"),
  model = NULL,
  api_key_env = NULL,
  max_retries = 5,
  retry_delay_base = 1,
  temperature = 0.01,
  verbose = TRUE,
  return_prompt = FALSE,
  custom_system_prompt = NULL,
  custom_idps = NULL,
  custom_outcomes = NULL,
  custom_domains = NULL
)

Arguments

backend

Character string, specifies which API backend to use: "groq" or "openrouter".

model

Character string, model name for the chosen backend. Defaults to "llama3-70b-8192" for Groq and "openai/gpt-4o" for OpenRouter.

api_key_env

Character string, name of the environment variable storing the API key.

max_retries

Integer, maximum number of retries in case of API errors or malformed responses.

retry_delay_base

Numeric, base delay in seconds for exponential backoff between retries.

temperature

Numeric, sampling temperature for the LLM. A very low value (e.g., 0.01) is recommended for deterministic, instruction-following behavior.

verbose

Logical, if TRUE, prints progress and debugging information.

return_prompt

Logical, if TRUE, returns the constructed system and user prompts as a list without calling the LLM. Useful for debugging prompts.

custom_system_prompt

Character string, an optional custom system prompt to use. If NULL, the default detailed system prompt (acting as a neuroscientist) is used.

custom_idps

Character vector, an optional custom list of IDPs to use. If NULL, the globally defined 'idps' list is used.

custom_outcomes

Character vector, an optional custom list of Outcomes to use. If NULL, the globally defined 'outcomes' list is used.

custom_domains

Character vector, an optional custom list of Domains to use. If NULL, the globally defined 'domains' list is used.

Value

A list containing:

  • dataframe: A data.frame with IDPs as rows, Outcomes as columns, and plausibility scores as values.

  • raw_json: The raw JSON string received from the LLM.

If return_prompt is TRUE, returns a list with system_prompt and user_prompt.