You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/chat.r
+100
Original file line number
Diff line number
Diff line change
@@ -275,3 +275,103 @@ new_chat <- function() {
275
275
the$responses<-NULL
276
276
the$prompts<-NULL
277
277
}
278
+
279
+
280
+
281
+
#' Generate and format queries for a language model
282
+
#'
283
+
#' `make_query` generates structured input for a language model, including system messages, user messages, and optional examples.
284
+
#'
285
+
#' @details The function supports the inclusion of examples, which are dynamically added to the structured input. Each example follows the same format as the primary user query.
286
+
#'
287
+
#' @param text A character vector of primary texts (queries) for which the input will be formatted.
288
+
#' @param prompt A string defining the main task or question to be passed to the language model.
289
+
#' @param user_template A string template for formatting user queries, containing placeholders like `{text}`, `{prompt_pre}`, and `{prompt_suff}`.
290
+
#' @param systemprompt An optional string to specify a system-level instruction or context.
291
+
#' @param prompt_pre A prefix string to prepend to each user query.
292
+
#' @param prompt_suff A suffix string to append to each user query.
293
+
#' @param examples A `tibble` with columns `text` and `answer`, representing example user messages and corresponding assistant responses.
294
+
#'
295
+
#' @return A list of tibbles, one for each input `text`, containing structured rows for system messages, user messages, and assistant responses.
0 commit comments