Package 'files2prompt'

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

Help Index


Build a prompt from text files

Description

Reads a TOML specification in the collects the matching files and returns the assembled prompt that can be parsed to a LLM

Usage

files2prompt(
  config_file,
  root_dir = NULL,
  open = "{",
  close = "}",
  cfg = NULL,
  verbose = 1
)

Arguments

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 ' … ').

Value

A character vector of length 1 containing the final prompt.


Parse a TOML confifugration file

Description

Parse a TOML confifugration file

Usage

fp_parse_config(config_file)

Arguments

config_file

Path to the TOML config file.


Heuristic token counter

Description

Very rough estimate: _1 token ≈ 'bytes_per_token' bytes_. Useful when the Python *tiktoken* library is not available.

Usage

guess_token_num(txt, bytes_per_token = 4)

Arguments

bytes_per_token

Average bytes per token (default 4 — conservative).

text

Character string to measure.

Value

Integer token count.


Hello, World!

Description

Prints 'Hello, world!'.

Usage

hello()

Examples

hello()

Replaces whiskers in a template string

Description

Replaces whiskers in a template string

Usage

tpl_replace_whisker(
  txt,
  values,
  open = "{{",
  close = "}}",
  require_all_value = FALSE
)

Arguments

txt

the tpl as a string

values

named list of values