Creates a retrieval-enabled ellmer chat, asks the query, parses structured output, and optionally writes answer artifacts.
Usage
ask_rag_store(
query,
store_location = RAG_STORE_LOCATION,
prompt_file = NULL,
output_instructions_file = NULL,
topic = "custom_rag",
top_k = 12L,
save_outputs = TRUE,
output_dir = RESULTS_DIR,
output_prefix = paste0(make_store_identifier(topic), "_answer"),
system_prompt = NULL,
system_prompt_file = NULL,
use_saved_system_prompt = TRUE,
output_instructions = NULL,
echo = FALSE,
...
)Arguments
- query
User query or task.
- store_location
Path to the ragnar store.
- prompt_file
Optional path to a Markdown/text system prompt file.
- output_instructions_file
Optional path to Markdown/text output instructions.
- topic
Topic label used in the retrieval tool description and output prefix.
- top_k
Number of chunks retrieved by the RAG retrieval tool.
- save_outputs
Logical; save outputs to disk.
- output_dir
Output directory.
- output_prefix
Output file prefix.
- system_prompt
Optional character scalar system prompt. Ignored when
prompt_fileis supplied.- system_prompt_file
Deprecated alias for
prompt_file.- use_saved_system_prompt
Logical; whether to use
system_prompt.txtbeside the store when neitherprompt_filenorsystem_promptis supplied.- output_instructions
Optional character scalar output instructions. Ignored when
output_instructions_fileis supplied.- echo
Logical; print query, prompt-file paths, saved-output paths, and the answer to the console.
- ...
Additional arguments passed to
make_rag_chat(), such asmodel,endpoint, orparams.
Value
A list with query, answer, summary, structured, saved,
prompt_file, and output_instructions_file.
Details
ask_rag_store() is the preferred user-facing API for querying an existing
ragcat/ragnar DuckDB store. Use prompt_file for the system prompt and
output_instructions_file for the expected response format.
Examples
if (FALSE) { # \dontrun{
answer <- ask_rag_store(
query = "What evidence is available for the project question?",
store_location = file.path("data", "example_rag_store", "rag_store.duckdb"),
prompt_file = file.path("prompts", "system_prompt.md"),
output_instructions_file = file.path("prompts", "output_instructions.md"),
top_k = 12
)
} # }
