Register a 'retrieve' tool with ellmer
Usage
ragnar_register_tool_retrieve(
chat,
store,
store_description = "the knowledge store",
...,
name = NULL,
title = NULL
)Arguments
- chat
a
ellmer:::Chatobject.- store
a string of a store location, or a
RagnarStoreobject.- store_description
Optional string, used for composing the tool description.
- ...
arguments passed on to
ragnar_retrieve().- name, title
Optional tool function name and title. By default,
store@nameandstore@titlewill be used if present. The toolnamemust be a valid R function name and should be unique with the tools registered with the ellmer::Chat object.titleis used for user-friendly display.
Examples
if (FALSE) { # (file.exists("r4ds.ragnar.duckdb") && Sys.getenv("OPENAI_API_KEY") != "")
system_prompt <- stringr::str_squish("
You are an expert assistant in R programming.
When responding, you first quote relevant material from books or documentation,
provide links to the sources, and then add your own context and interpretation.
")
chat <- ellmer::chat_openai(system_prompt, model = "gpt-4.1")
store <- ragnar_store_connect("r4ds.ragnar.duckdb")
ragnar_register_tool_retrieve(chat, store)
chat$chat("How can I subset a dataframe?")
}
