-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from JamesHWade/back-from-leave-cleanup
major cleanup
- Loading branch information
Showing
94 changed files
with
2,246 additions
and
1,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: gpttools | ||
Title: Extensions and Tools for gptstudio | ||
Version: 0.0.7 | ||
Version: 0.0.8 | ||
Authors@R: | ||
person("James", "Wade", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-9740-1905")) | ||
|
@@ -17,30 +17,23 @@ Depends: | |
R (>= 4.1) | ||
Imports: | ||
arrow, | ||
assertthat, | ||
bslib (>= 0.5), | ||
callr, | ||
cli, | ||
dplyr, | ||
furrr, | ||
future, | ||
glue, | ||
gptstudio (>= 0.2.0), | ||
httr, | ||
httr2, | ||
janitor, | ||
jsonlite, | ||
lsa, | ||
lubridate, | ||
miniUI, | ||
pdftools, | ||
purrr (>= 1.0.0), | ||
R.utils, | ||
readr, | ||
rlang (>= 0.4.11), | ||
rstudioapi (>= 0.12), | ||
rvest, | ||
scales, | ||
shiny, | ||
skimr, | ||
stats, | ||
|
@@ -49,14 +42,16 @@ Imports: | |
tidyr, | ||
tokenizers, | ||
tools, | ||
tuneR, | ||
urltools, | ||
usethis, | ||
xml2 | ||
xml2, | ||
yaml | ||
Suggests: | ||
bslib, | ||
bsicons, | ||
covr, | ||
htmltools, | ||
httr, | ||
knitr, | ||
later, | ||
mockr, | ||
|
@@ -69,6 +64,7 @@ Suggests: | |
testthat (>= 3.0.0), | ||
tidymodels, | ||
tidyverse, | ||
tuneR, | ||
uuid, | ||
waiter, | ||
withr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(add_roxygen_addin) | ||
export(addin_run_retriever) | ||
export(addin_run_scrape_pkgs) | ||
export(addin_run_select_pkgs) | ||
export(chat_with_context) | ||
export(chat_with_context_azure) | ||
export(chat_with_retrieval) | ||
export(collect_dataframes) | ||
export(crawl) | ||
export(create_index_from_audio) | ||
export(create_index_from_pdf) | ||
export(create_transcript) | ||
export(delete_history) | ||
export(delete_index) | ||
export(document_data) | ||
export(get_selection) | ||
export(get_transformer_model) | ||
export(gpt_sitrep) | ||
export(ingest_pdf) | ||
export(insert_text) | ||
export(install_sentence_transformers) | ||
export(list_index) | ||
export(load_index) | ||
export(prep_data_prompt) | ||
export(query_index) | ||
export(read_history) | ||
export(remove_lines_and_spaces) | ||
export(run_document_data) | ||
export(run_select_pkgs_app) | ||
export(save_user_config) | ||
export(scrape_pkg_sites) | ||
export(scrape_url) | ||
export(script_to_function_addin) | ||
export(set_user_config) | ||
export(suggest_unit_test_addin) | ||
export(transcribe_audio) | ||
import(cli) | ||
import(rlang) | ||
importFrom(glue,glue) | ||
importFrom(graphics,text) | ||
importFrom(utils,globalVariables) | ||
importFrom(utils,head) | ||
importFrom(utils,installed.packages) | ||
importFrom(utils,old.packages) | ||
importFrom(utils,packageDescription) | ||
importFrom(utils,packageVersion) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#' Run Package Selector App | ||
#' | ||
#' Run the package selector shiny app | ||
#' | ||
#' @export | ||
#' | ||
#' @return This function has no return value. | ||
#' | ||
addin_run_select_pkgs <- function() { | ||
run_select_pkgs_app() | ||
} | ||
|
||
#' Addin to scrape installed packages | ||
#' | ||
#' Invokes RStudio addin functionality to scrape select installed packages and | ||
#' create indices for use in the "Chat with Retrieval" application. | ||
#' | ||
#' @export | ||
#' @return No return value, called for side effects only. | ||
#' | ||
#' @examplesIf rlang::is_interactive() | ||
#' # This function is typically run within RStudio as an Addin. | ||
#' # It would not be called directly in the code. | ||
#' addin_scrape_pkgs() | ||
#' | ||
#' @note This addin requires RStudio to be available and will stop with an | ||
#' error message if RStudio API is not accessible. | ||
#' | ||
addin_run_scrape_pkgs <- function() { | ||
# Check if RStudio API is available | ||
if (!rstudioapi::isAvailable()) { | ||
cli::cli_abort("The rstudioapi is not available.") | ||
} | ||
# Get user feedback with rstudioapi | ||
proceed <- | ||
rstudioapi::showQuestion( | ||
title = "Scrape Packages", | ||
message = "This will scrape installed packages and create indices to use | ||
with the \"Chat with Retrieval\" app. Would you like to proceed?" | ||
) | ||
|
||
# Proceed with scraping if the user agrees | ||
if (proceed) { | ||
cli::cli_alert_info("Scraping packages as a background job.") | ||
# Run the scrape packages script as a background job | ||
rstudioapi::jobRunScript( | ||
path = system.file("scripts/scrape_pkgs.R", | ||
package = "gpttools" | ||
), | ||
name = "Scraping Pacakges" | ||
) | ||
} else { | ||
cli::cli_alert_info("Scraping cancelled.") | ||
} | ||
} | ||
|
||
#' Run a Shiny App to Select and Save Installed Packages | ||
#' | ||
#' This function launches a Shiny application that allows users to select from a | ||
#' list of installed packages and save their selections. | ||
#' | ||
#' @return None The function is used for its side effect of launching a Shiny app and doesn't return anything. | ||
#' | ||
#' @details | ||
#' The application provides a sidebar for package selection and an action button to | ||
#' save the selected packages. It displays the selected packages in a data table. | ||
#' | ||
#' @export | ||
#' | ||
#' @examplesIf rlang::is_interactive() | ||
#' run_select_pkgs_app() | ||
run_select_pkgs_app <- function() { | ||
installed_packages <- | ||
installed.packages() |> | ||
tibble::as_tibble() |> | ||
dplyr::select("Package", "Version", "License", "Built") | ||
|
||
ui <- bslib::page_sidebar( | ||
title = "Package Selector", | ||
theme = bslib::bs_theme(version = 5, bootswatch = "litera"), | ||
sidebar = bslib::sidebar( | ||
width = 400, | ||
shiny::selectInput( | ||
"selected_pkg", | ||
"Select packages:", | ||
choices = installed_packages$Package, | ||
multiple = TRUE, | ||
selected = use_default_pkgs() | ||
) | ||
), | ||
shiny::actionButton("save_pkgs", "Save Selected Packages", | ||
icon = shiny::icon("save", class = "ms-auto"), | ||
class = "btn-primary" | ||
), | ||
shiny::dataTableOutput("table_packages") | ||
) | ||
server <- function(input, output, session) { | ||
shiny::observe({ | ||
selected_pkgs <- | ||
installed_packages |> | ||
dplyr::filter(Package %in% input$selected_pkg) | ||
try_to_save <- save_pkgs_to_scrape(selected_pkgs) | ||
if (try_to_save) { | ||
shiny::showNotification("Saved packages to scrape.") | ||
} | ||
}) |> shiny::bindEvent(input$save_pkgs) | ||
|
||
output$table_packages <- shiny::renderDataTable( | ||
{ | ||
installed_packages |> dplyr::filter(Package %in% input$selected_pkg) | ||
}, | ||
# options = list(pageLength = 5) | ||
) | ||
} | ||
|
||
shiny::shinyApp(ui, server) | ||
} |
Oops, something went wrong.