Skip to content

feat(r): Added prompt_path argument to R package #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

oacar
Copy link

@oacar oacar commented Jun 18, 2025

I wanted to have more control over default behavior of the system so I added prompt_path argument to querychat_init and querychat_system_prompt to allow user to provide completely custom system prompt.

…mpt to allow user to provide completely custom system prompt.
@oacar oacar changed the title Added prompt_path argument feat(r): Added prompt_path argument to R package Jun 18, 2025
@chendaniely
Copy link
Contributor

Hi @oacar, thanks for submitting a PR.

I'm trying to understand what you are trying to do. Currently querychat_init() allows you to provide your completely own custom prompt, by directly passing in the string you want for the system_prompt argument.

The default behavior of calling querychat_system_promt() is a helper function to generate the string for the system prompt. If you wanted to do something custom you do not need to use this function.

If you provide your own custom system_prompt to querychat_init() you could read in your own file as text and pass it in there.

@oacar
Copy link
Author

oacar commented Jun 26, 2025

Hi @chendaniely, thank you for answering!

Good points. Correct me if I am wrong but if you provide full system prompt yourself, you also need to pass the dataframe schema yourself then also figure out the templating. Since the df_to_schema function is not exported from the package, that means I would need to write a separate function to do it. So I wanted to keep that functionality but also use a different system prompt with the same templating variables.

In my use case, I took your system prompt file and removed the filtering related functionality and kept the rest same. I thought the easiest way to use this prompt without changing anything else was to provide a prompt_path argument.

@schloerke
Copy link
Contributor

Updates:

  • R
    • Rearranged init parameters to be ... to pass through to system_prompt(table_name, ...)
    • Renamed parameter name and tbl_name to table_name
    • Added check to compare init table_name and the prompt table_name
    • Exported df_to_schema()
  • Python
    • Added prompt_path to python init and system prompt methods
    • Note: Did not export DataSource for parallel exposure of a "data frame to schema" object. Will wait for another day.

@schloerke
Copy link
Contributor

@oacar Does this look good to you?

@oacar
Copy link
Author

oacar commented Jun 27, 2025

@schloerke looks great! Thanks for all the additional stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants