From dcff55a6d859693cdee447e8f7084406415046ae Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Sat, 9 Mar 2024 11:33:49 +0100 Subject: [PATCH] stream(dry_run) --- R/stream.R | 9 +++++++-- man/stream.Rd | 10 +++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/R/stream.R b/R/stream.R index 0524af2..aaf793b 100644 --- a/R/stream.R +++ b/R/stream.R @@ -1,11 +1,16 @@ #' stream #' #' @inheritParams chat +#' #' @export -stream <- function(text, model = "mistral-tiny", ..., error_call = current_env()) { +stream <- function(text, model = "mistral-tiny", dry_run = FALSE, ..., error_call = current_env()) { check_model(model, error_call = error_call) - req <- req_chat(text, model, stream = TRUE, error_call = error_call) + req <- req_chat(text, model, stream = TRUE, error_call = error_call, dry_run = dry_run) + if (is_true(dry_run)) { + return(req) + } + resp <- req_perform_stream(req, callback = stream_callback, round = "line", diff --git a/man/stream.Rd b/man/stream.Rd index a5db2af..7e7ae64 100644 --- a/man/stream.Rd +++ b/man/stream.Rd @@ -4,13 +4,21 @@ \alias{stream} \title{stream} \usage{ -stream(text, model = "mistral-tiny", ..., error_call = current_env()) +stream( + text, + model = "mistral-tiny", + dry_run = FALSE, + ..., + error_call = current_env() +) } \arguments{ \item{text}{some text} \item{model}{which model to use. See \code{\link[=models]{models()}} for more information about which models are available} +\item{dry_run}{if TRUE the request is not performed} + \item{...}{ignored} \item{error_call}{The execution environment of a currently