Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
UI working
Browse files Browse the repository at this point in the history
  • Loading branch information
reisner committed Jul 4, 2023
1 parent 3bbd1e7 commit b5d1c78
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions search_results_table_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ searchResultsTable <- function(input, output, session,
# str_replace_all("\n", "<br />") %>%
# HTML()

# shinyWidgets::sendSweetAlert(
shinyWidgets::confirmSweetAlert(
shinyWidgets::confirmSweetAlert( # confirmSweetAlert allows us to track when the "OK" button is clicked
session = session,
inputId = session$ns("doc_info"),
title = "Matching Document Information",
Expand All @@ -256,8 +255,8 @@ searchResultsTable <- function(input, output, session,
),
# Only turn on summaries if we've specified an API Host,
# and this is a long piece of text:
# TODO: Remove multiple spaces
if (!is.null(get_configs()$embedding_api_host) & (row$num_chars > 1000)) {
# TODO: Nicer button
actionButton(session$ns("summary_button"), "Summarize Text")
} else {
""
Expand All @@ -269,7 +268,6 @@ searchResultsTable <- function(input, output, session,
)

observeEvent(input$doc_info, {
# TODO: Needed?
output$summary_section = renderText({""})
})

Expand All @@ -278,16 +276,17 @@ searchResultsTable <- function(input, output, session,
observeEvent(input$summary_button, {
req(input$summary_button)
req(input$summary_button != 0)
# TODO: Do we need isolate? https://github.com/rstudio/shiny/issues/167
isolate({
shinycssloaders::showPageSpinner(caption = "🤖 Processing... 🤖")
shinycssloaders::showPageSpinner(caption = "🤖 Reading Text... 🤖")
shinyjs::hide("summary_button")
# shinyjs::show("summary_section")
configs = get_configs()
summary = get_document_summary(doc$text,
configs$embedding_api_host,
configs$embedding_api_user,
configs$embedding_api_password,
configs$embedding_api_version)
summary = get_document_summary(display_text,
configs$embedding_api_host,
configs$embedding_api_user,
configs$embedding_api_password,
configs$embedding_api_version)
# TODO: Clean up this output
output$summary_section = renderUI({
tagList(
strong("AI-generated Text Summary"),
Expand All @@ -297,7 +296,7 @@ searchResultsTable <- function(input, output, session,
})
shinycssloaders::hidePageSpinner()
})
}, ignoreInit = TRUE, once = TRUE)
}, ignoreInit = TRUE, once = TRUE) # https://community.rstudio.com/t/issue-with-r-shiny-modal-dialog-and-observe-event-on-action-button/9501
})

}

0 comments on commit b5d1c78

Please sign in to comment.