| Title: | RStudio addin to create prompt from code or text files in a project directory |
|---|---|
| Description: | Can be customized using TOML based specifications. |
| Authors: | Sebastian Kranz |
| Maintainer: | Sebastian Kranz <[email protected]> |
| License: | MIT |
| Version: | 0.1.0 |
| Built: | 2026-06-05 06:22:05 UTC |
| Source: | https://github.com/skranz/files2prompt |
Reads a TOML specification in the collects the matching files and returns the assembled prompt that can be parsed to a LLM
files2prompt( config_file, root_dir = NULL, open = "{", close = "}", cfg = NULL, verbose = 1 )files2prompt( config_file, root_dir = NULL, open = "{", close = "}", cfg = NULL, verbose = 1 )
config_file |
Path to the TOML config file. |
root_dir |
Override the 'root_dir' declared in the TOML. Use 'NULL' (default) to respect the spec. |
open, close
|
Delimiters used in templates (default ' … '). |
A character vector of length 1 containing the final prompt.
Parse a TOML confifugration file
fp_parse_config(config_file)fp_parse_config(config_file)
config_file |
Path to the TOML config file. |
Very rough estimate: _1 token ≈ 'bytes_per_token' bytes_. Useful when the Python *tiktoken* library is not available.
guess_token_num(txt, bytes_per_token = 4)guess_token_num(txt, bytes_per_token = 4)
bytes_per_token |
Average bytes per token (default 4 — conservative). |
text |
Character string to measure. |
Integer token count.
Replaces whiskers in a template string
tpl_replace_whisker( txt, values, open = "{{", close = "}}", require_all_value = FALSE )tpl_replace_whisker( txt, values, open = "{{", close = "}}", require_all_value = FALSE )
txt |
the tpl as a string |
values |
named list of values |