llm() stores each structured or free-text response and replays it on
identical later calls, so asking the same question again does not re-issue
(or re-bill) the LLM request. Because llm() runs at temperature 0 the
replayed answer matches a fresh call. Cached entries are keyed by model,
system prompt, input text, type spec, and params; changing any of these
produces a fresh call.
Details
By default the responses are kept only in the R session's temporary folder,
which R removes when the session ends. With llm_cache(TRUE) they are kept
between sessions, in the folder .metacheck_llm_cache in the working
directory, or under the folder set with options(metacheck.cache.dir = ) or
the METACHECK_LLM_CACHE_DIR environment variable. With llm_cache(FALSE)
no response is stored or replayed, so every call asks the model again;
options(metacheck.llm.cache = NULL) returns to the default. Use
llm_cache_clear() to remove the stored responses.
Examples
llm_cache() # are responses kept between sessions? (FALSE by default)
#> [1] FALSE
llm_cache(TRUE) # keep responses between sessions
llm_cache(FALSE) # no cache: every call asks the model again
options(metacheck.llm.cache = NULL) # back to the default: this session only
