clear_cache: Clear cached LLM scores for a project

View source: R/project.R

clear_cacheR Documentation

Clear cached LLM scores for a project

Description

Removes score-cache files under a project's cache directory. Use this when a model returned garbage during a ranking run and you want to re-score with fresh calls; the cache would otherwise be hit on the next rank_records() invocation.

Usage

clear_cache(project, model = NULL, delete_ranked = TRUE)

Arguments

project

Project name.

model

Optional Ollama tag. When NULL (default), clears every cached score in the project. When supplied, only cached scores whose stored ⁠$model⁠ field matches are removed. Reading each cache file is O(n_files) but each file is tiny (~1 KB).

delete_ranked

If TRUE (default), also removes the project's ranked.rds artefact so a re-run starts from a clean slate.

Details

By default clears every cached score (the most conservative "start over" behaviour). Pass model = "..." to clear only that model's cached scores across all records / replicates. Optionally also deletes the persisted ranked artefact (delete_ranked = TRUE) so a stale ranking doesn't linger.

Value

Invisibly, the number of cache files removed.

Examples


# Operate against a throwaway data directory so the example never
# touches your real projects.
withr::with_envvar(c(R_USER_DATA_DIR = tempfile("screenllm-")), {
  # Clear one model's cached scores (a no-op on an empty project):
  clear_cache("demo-project", model = "mistral:7b")
  # Clear everything for the project:
  clear_cache("demo-project")
})


screenllm documentation built on Sept. 24, 2026, 5:11 p.m.