Skip to content

Commit

Permalink
Shiny app bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielKaiserQFin committed Aug 26, 2024
1 parent 8257153 commit d46be0a
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 254 deletions.
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.0.1
Date: 2024-08-24 11:24:26.702203 UTC
SHA: d4af40595f6f09da6ccd15d82f2f3db284779d0c
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(codeConverter)
export(coder)
export(debug)
export(nameIt)
export(on_startup)
export(optimizer)
export(rewriter)
export(roxy)
Expand Down Expand Up @@ -33,6 +34,7 @@ importFrom(shiny,observeEvent)
importFrom(shiny,onStop)
importFrom(shiny,runGadget)
importFrom(shiny,selectInput)
importFrom(shiny,shinyApp)
importFrom(shiny,showNotification)
importFrom(shiny,sliderInput)
importFrom(shiny,splitLayout)
Expand Down
9 changes: 0 additions & 9 deletions R/groqR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,3 @@
############# Important: #############
######################################## .
# set R_LIBS_USER and R_PROFILE_USER as enviromental user variable

# Set params if necessary
if (any(Sys.getenv(c(
"GROQ_model", "GROQ_systemRole", "GROQ_API_KEY",
"GROQ_maxTokens", "GROQ_temperature", "GROQ_top_p",
"GROQ_returnType"
)) == "")) {
shiny::shinyApp(ui = ui, server = server)
}
48 changes: 46 additions & 2 deletions R/SupportFcts.R → R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
######## Set Model Parameters ########
######################################## .

.onAttach <- function(libname, pkgname) {
packageStartupMessage("Welcome to groqR!")
on_startup()
}



#'
#' User Interface
#'
Expand Down Expand Up @@ -36,7 +43,7 @@ ui <- fluidPage( # Define UI
#' @importFrom shinyWidgets inputSweetAlert
#'
#'
server <- function(input, session) {
server <- function(input, output, session) {
# Define server logic
observeEvent(input$btn_set_params, {
# Input for GROQ_API_KEY
Expand Down Expand Up @@ -194,7 +201,7 @@ Update.Renviron <- function(my_list, renviron_path =
}

# Create lines to write from the list
new_lines <- vapply(names(my_list), function(name) {
new_lines <- sapply(names(my_list), function(name) {
paste0(name, " = ", my_list[[name]])
})

Expand All @@ -217,3 +224,40 @@ Update.Renviron <- function(my_list, renviron_path =
cat("The following environment variables were added to .Renviron:\n")
cat(new_lines, sep = "\n")
}


#' Function to Handle Package Startup Logic
#'
#' The `on_startup` function is designed to execute certain actions when the package is loaded.
#' Specifically, it checks for the presence of required environment variables related to the GROQ system.
#' If any of these variables are missing, it will launch a Shiny application.
#'
#' @details
#' The function checks the following environment variables:
#' - `GROQ_model`
#' - `GROQ_systemRole`
#' - `GROQ_API_KEY`
#' - `GROQ_maxTokens`
#' - `GROQ_temperature`
#' - `GROQ_top_p`
#' - `GROQ_returnType`
#'
#' If any of these variables are not set (i.e., are empty strings), the function triggers the
#' launch of a Shiny application defined by the `ui` and `server` components.
#'
#' @seealso
#' `shiny::shinyApp`
#'
#' @importFrom shiny shinyApp
#'
#' @export
on_startup <- function() {
# Set params if necessary
if (any(Sys.getenv(c(
"GROQ_model", "GROQ_systemRole", "GROQ_API_KEY",
"GROQ_maxTokens", "GROQ_temperature", "GROQ_top_p",
"GROQ_returnType"
)) == "")) {
shinyApp(ui = ui, server = server)
}
}
470 changes: 235 additions & 235 deletions README.md

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion man/Update.Renviron.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/dot-onAttach.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions man/on_startup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions man/server.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions man/ui.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d46be0a

Please sign in to comment.