Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when restarting query execution after early interruption #25

Open
textspur opened this issue Nov 26, 2024 · 3 comments
Open

Error when restarting query execution after early interruption #25

textspur opened this issue Nov 26, 2024 · 3 comments

Comments

@textspur
Copy link
Collaborator

When running the following code, everything works as expected:

movie_reviews$annotation <- query(queries, screen = FALSE, output = "text")

However, if I start and stop the query prematurely (likely before Ollama starts), and then attempt to run it again, I encounter the following error:

> query(queries, screen = TRUE, output = "text")
Error in cli::cli_progress_update(..., id = id) : 
  Cannot find progress bar `cli-12431-1916`
Error in cli::cli_progress_update(..., id = id) : 
  Cannot find progress bar `cli-12431-1916`

Running a single query from the list works fine:

> query(queries[[1]], screen = TRUE, output = "text")
                       
── Answer from llama3.1 ────────────────────────────────────────────────────────────────────────────────────────────
positive

Steps to Reproduce:

  1. Run query(queries, screen = TRUE, output = "text").
  2. Interrupt the execution early (e.g., before Ollama is taking over).
  3. Attempt to run the query again.

Environment:
sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0

locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8
[5] LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] openxlsx_4.2.6.1 irr_0.84.1 lpSolve_5.6.22 caret_6.0-94 lattice_0.22-5
[6] ggplot2_3.5.1 rollama_0.1.0.9000 dplyr_1.1.4 readxl_1.4.3

loaded via a namespace (and not attached):
[1] gtable_0.3.5 httr2_1.0.6 recipes_1.1.0 processx_3.8.4 callr_3.7.6
[6] ps_1.8.1 vctrs_0.6.5 tools_4.4.2 generics_0.1.3 stats4_4.4.2
[11] curl_6.0.1 parallel_4.4.2 proxy_0.4-27 tibble_3.2.1 fansi_1.0.6
[16] pkgconfig_2.0.3 ModelMetrics_1.2.2.2 Matrix_1.7-1 data.table_1.15.4 lifecycle_1.0.4
[21] compiler_4.4.2 stringr_1.5.1 munsell_0.5.1 codetools_0.2-20 class_7.3-22
[26] prodlim_2024.06.25 pillar_1.9.0 MASS_7.3-61 gower_1.0.1 iterators_1.0.14
[31] rpart_4.1.23 foreach_1.5.2 nlme_3.1-165 parallelly_1.38.0 lava_1.8.0
[36] zip_2.3.1 tidyselect_1.2.1 digest_0.6.35 stringi_1.8.4 future_1.34.0
[41] reshape2_1.4.4 purrr_1.0.2 listenv_0.9.1 splines_4.4.2 grid_4.4.2
[46] colorspace_2.1-0 cli_3.6.3 magrittr_2.0.3 survival_3.7-0 utf8_1.2.4
[51] e1071_1.7-14 future.apply_1.11.2 withr_3.0.2 scales_1.3.0 rappdirs_0.3.3
[56] lubridate_1.9.3 timechange_0.3.0 globals_0.16.3 nnet_7.3-19 timeDate_4032.109
[61] cellranger_1.1.0 hardhat_1.4.0 rlang_1.1.4 Rcpp_1.0.12 glue_1.8.0
[66] pROC_1.18.5 ipred_0.9-15 rstudioapi_0.16.0 jsonlite_1.8.9 R6_2.5.1
[71] plyr_1.8.9

@textspur
Copy link
Collaborator Author

Minimal example using the make_query branch


library(rollama)
ping_ollama()

# Create an example dataframe with 5 movie reviews
movie_reviews <- tibble::tibble(
  review_id = 1:5,
  review = c("A stunning visual spectacle with a gripping storyline.",
             "The plot was predictable, but the acting was superb.",
             "An overrated film with underwhelming performances.",
             "A beautiful tale of love and adventure, beautifully shot.",
             "The movie lacked depth, but the special effects were incredible.")
)


# Define examples as a tibble
examples <- tibble::tribble(
  ~text, ~answer,
  "This movie was amazing, with great acting and story.", "positive",
  "The film was okay, but not particularly memorable.", "neutral",
  "I found this movie boring and poorly made.", "negative"
)

# Call the make_query function
queries <- make_query(
  user_template = "{prompt_pre}{text}\n{prompt}\n{prompt_suff}",
  text = movie_reviews$review,
  prompt = "Classify the sentiment with one of these categories: positive, neutral, negative.",
  systemprompt = "Classify the sentiment of the movie review.",
  prompt_pre = "Text to classify: ",
  prompt_suff = "Answer with just the correct category.",
  examples = examples
)

# Print the queries
print(queries)

# run
movie_reviews$annotation <- query(queries, screen = FALSE, output = "text")

query(queries[[1]], screen = TRUE, output = "text")

@JBGruber
Copy link
Owner

Looks like this is a httr2 issue. Here is a more minimal example:

library(httr2)
reqs <- list(
  request(example_url()) |>
    req_url_path("/delay") |> 
    req_url_path_append(sample(1:10, 1))
) |>
  rep(100)

resps <- req_perform_parallel(reqs, progress = TRUE)

# stop with Esc ##
resps <- req_perform_parallel(reqs, progress = TRUE)
#> Error in cli::cli_progress_update(..., id = id) : 
#>   Cannot find progress bar `cli-25573-7`
#> Error in cli::cli_progress_update(..., id = id) : 
#>   Cannot find progress bar `cli-25573-7`
``

@JBGruber
Copy link
Owner

I posted it over there as well: r-lib/httr2#594

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants