dfalbel commited on
Commit
55d99af
·
unverified ·
1 Parent(s): b73694e

Better message when failure.

Browse files
Files changed (1) hide show
  1. app.R +10 -14
app.R CHANGED
@@ -4,7 +4,8 @@ library(minhub)
4
  library(magrittr)
5
  source("model-session.R")
6
 
7
- repo <- "stabilityai/stablelm-tuned-alpha-3b"
 
8
  sess <- model_session$new()
9
  model_loaded <- sess$load_model(repo)
10
 
@@ -86,19 +87,14 @@ server <- function(input, output, session) {
86
  # Observer used at app startup time to allow using the 'Send' button once the
87
  # model has been loaded.
88
  observe({
89
- ready <- sess$sess$poll_process(1) == "ready"
90
- send <- isolate(input$send)
91
-
92
- if (send == 0 && !ready) {
93
- invalidateLater(1000, session)
94
- }
95
-
96
- if (ready) {
97
- shinyjs::enable("send")
98
- updateActionButton(inputId = "send", label = "Send")
99
- } else {
100
- shinyjs::disable("send")
101
- }
102
  })
103
  }
104
 
 
4
  library(magrittr)
5
  source("model-session.R")
6
 
7
+ #repo <- "stabilityai/stablelm-tuned-alpha-3b"
8
+ repo <- "EleutherAI/pythia-70m"
9
  sess <- model_session$new()
10
  model_loaded <- sess$load_model(repo)
11
 
 
87
  # Observer used at app startup time to allow using the 'Send' button once the
88
  # model has been loaded.
89
  observe({
90
+ model_loaded %>%
91
+ promises::then(onFulfilled = function(x) {
92
+ shinyjs::enable("send")
93
+ updateActionButton(inputId = "send", label = "Send")
94
+ }, onRejected = function(x) {
95
+ shinyjs::disable("send")
96
+ insert_message(paste0("😭 Error loading the model:\n", as.character(x)))
97
+ })
 
 
 
 
 
98
  })
99
  }
100