The general function ask() could take a context argument, which is a nested list with named elements.
A context object, once flattened into a string, is a natural language representation of structured data that describes the context.
A simple example :
context <- list(
"File: R/file1.R" = readLines("R/file1.R"),
"File: R/file1.R" = readLines("R/file1.R")
)
flatten_context(context)
#> # File: R/file1.R ---
#> a <- 1
#> b <- a + 1
#>
#> # File: R/file2.R ---
#> c <- 3
# a helper
context_files <- function(paths) {
out <- lapply(paths, readLines)
names(out) <- paste("File:", paths, "---")
}
I think we need a concept of nested contexts.
The general function
ask()
could take a context argument, which is a nested list with named elements. A context object, once flattened into a string, is a natural language representation of structured data that describes the context.A simple example :
Then we can use it in a bigger context :
The formatting of nested items depend of the depth, so now we would have :
Maybe some delimitation formats would be more effective than others ?
chatgpt itself suggests delimiters that vary with depth: