Call this once outside of any server function
querychat_init.RdThis will perform one-time initialization that can then be shared by all Shiny sessions in the R process.
Usage
querychat_init(
df,
tbl_name = deparse(substitute(df)),
greeting = NULL,
data_description = NULL,
extra_instructions = NULL,
create_chat_func = purrr::partial(ellmer::chat_openai, model = "gpt-4o"),
system_prompt = querychat_system_prompt(df, tbl_name, data_description =
data_description, extra_instructions = extra_instructions)
)Arguments
- df
A data frame.
- tbl_name
A string containing a valid table name for the data frame, that will appear in SQL queries. Ensure that it begins with a letter, and contains only letters, numbers, and underscores. By default, querychat will try to infer a table name using the name of the
dfargument.- greeting
A string in Markdown format, containing the initial message to display to the user upon first loading the chatbot. If not provided, the LLM will be invoked at the start of the conversation to generate one.
- data_description
A string in plain text or Markdown format, containing a description of the data frame or any additional context that might be helpful in understanding the data. This will be included in the system prompt for the chat model. If a
system_promptargument is provided, thedata_descriptionargument will be ignored.- extra_instructions
A string in plain text or Markdown format, containing any additional instructions for the chat model. These will be appended at the end of the system prompt. If a
system_promptargument is provided, theextra_instructionsargument will be ignored.- create_chat_func
A function that takes a system prompt and returns a chat object. The default uses
ellmer::chat_openai().- system_prompt
A string containing the system prompt for the chat model. The default uses
querychat_system_prompt()to generate a generic prompt, which you can enhance via thedata_descriptionandextra_instructionsarguments.
Value
An object that can be passed to querychat_server() as the
querychat_config argument. By convention, this object should be named
querychat_config.