dfalbel commited on
Commit
a25e028
·
unverified ·
1 Parent(s): 7186403

Use later for polling the process.

Browse files
Files changed (2) hide show
  1. app.R +6 -8
  2. model-session.R +5 -0
app.R CHANGED
@@ -8,6 +8,12 @@ repo <- "EleutherAI/pythia-70m"
8
  repo <- Sys.getenv("MODEL_REPO", unset = repo)
9
  sess <- model_session$new()
10
 
 
 
 
 
 
 
11
  max_n_tokens <- 100
12
  system_prompt = "<|SYSTEM|># StableLM Tuned (Alpha version)
13
  - StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
@@ -84,14 +90,6 @@ server <- function(input, output, session) {
84
  })
85
  })
86
 
87
- observe({
88
- # an observer that makes sure tasks are resolved during the shiny loop
89
- invalidateLater(100, session)
90
- cat("Invalidating to poll session\n")
91
- if (!is.null(sess$sess))
92
- sess$sess$poll_process(1)
93
- })
94
-
95
  # Observer used at app startup time to allow using the 'Send' button once the
96
  # model has been loaded.
97
  model_loaded <- reactiveVal()
 
8
  repo <- Sys.getenv("MODEL_REPO", unset = repo)
9
  sess <- model_session$new()
10
 
11
+ poll_process <- function() {
12
+ sess$poll_process(1)
13
+ later::later(func = poll_process, delay = 0.5)
14
+ }
15
+ poll_process()
16
+
17
  max_n_tokens <- 100
18
  system_prompt = "<|SYSTEM|># StableLM Tuned (Alpha version)
19
  - StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
 
90
  })
91
  })
92
 
 
 
 
 
 
 
 
 
93
  # Observer used at app startup time to allow using the 'Send' button once the
94
  # model has been loaded.
95
  model_loaded <- reactiveVal()
model-session.R CHANGED
@@ -11,6 +11,11 @@ model_session <- R6::R6Class(
11
  self$top_k <- 50
12
  self$is_loaded <- NULL
13
  },
 
 
 
 
 
14
  load_model = function(repo) {
15
  if (!is.null(self$sess)) {
16
  cat("Model is already loaded.", "\n")
 
11
  self$top_k <- 50
12
  self$is_loaded <- NULL
13
  },
14
+ poll_process = function(timeout = 1) {
15
+ if (!is.null(self$sess)) {
16
+ self$sess$poll_process(timeout)
17
+ }
18
+ },
19
  load_model = function(repo) {
20
  if (!is.null(self$sess)) {
21
  cat("Model is already loaded.", "\n")