Skip to content

Commit

Permalink
Merge pull request #59 from JamesHWade/back-from-leave-cleanup
Browse files Browse the repository at this point in the history
major cleanup
  • Loading branch information
JamesHWade authored Jan 22, 2024
2 parents 42f140a + 9d058bd commit ffd1827
Show file tree
Hide file tree
Showing 94 changed files with 2,246 additions and 1,768 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
^cran-comments\.md$
^docs$
^gpttools\.Rproj$
^images$
^pkgdown$
^revdep$
^.lintr$
Expand All @@ -19,3 +18,4 @@
^inst/positgpt-app/indices$
^inst/longevity$
^inst/azure-retriever/rsconnect/$
^media/
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ repos:
- id: parsable-R
- id: no-browser-statement
- id: no-debug-statement
- id: deps-in-desc
# - id: deps-in-desc
# args: [--warn_only]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=200']
args: ['--maxkb=25000']
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
rev: v1.6.1
hooks:
Expand Down
16 changes: 6 additions & 10 deletions DESCRIPTION
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"))
Expand All @@ -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,
Expand All @@ -49,14 +42,16 @@ Imports:
tidyr,
tokenizers,
tools,
tuneR,
urltools,
usethis,
xml2
xml2,
yaml
Suggests:
bslib,
bsicons,
covr,
htmltools,
httr,
knitr,
later,
mockr,
Expand All @@ -69,6 +64,7 @@ Suggests:
testthat (>= 3.0.0),
tidymodels,
tidyverse,
tuneR,
uuid,
waiter,
withr
Expand Down
19 changes: 16 additions & 3 deletions NAMESPACE
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)
31 changes: 25 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
# gpttools 0.0.7
# gpttools 0.0.8

# gpttools 0.0.6
## Major features and improvements

# gpttools 0.0.5
* Added support for more AI services: anthropic, huggingface, google ai studio, and ollama (local models) (in #0042b93, #f3c64c2).
* Implemented a fully local option for AI models (in #231f2c8, #482157f).
* Users can now use local embeddings as an option within the package (in #0042b93).
* Improved site scraping workflow for more efficiency and better data retrieval (in #308c809).
* Enhanced the package documentation index updating functions for smoother maintenance (in #2139bfb, #4aa2344, #0304daf).
* Provided package options for easy switching between different AI models (in #2027dbb).
* Added save options to the chat with retrieval app for better user experience (in #51cc6a3, #4202256).

# gpttools 0.2.3
## Bug fixes and other changes

# gpttools 0.2.2
* Reconciled local versus OpenAI API for history tracking, ensuring consistency and reliability in the app's history feature (in #f3c64c2, #6d328b2).
* Improved scraping of packages, exploring potential improvements in scraping efficiency (in #46e233a).
* Added an "all indices" option to the app, providing users with a comprehensive view of indices.
* Updated the README and pkgdown site to reflect recent changes and guide the users through new features (in #15a971b).
* Improved AI services vignettes to provide more detailed and up-to-date documentation on using various AI services (in #0304daf).
* Added a new vignette for package scraping, making the scraping process clearer for other developers.
* Added a vignette for chat with retrieval, offering a tutorial on how to leverage this new feature within the package.
* Removed dedicated azure functions and azure embedding option due to the new focus on fully local options (in #ea30c57, #4259474).

This is the first CRAN release of gpttools. The package includes models for:
## Developmental changes

* Major cleanup of the codebase to remove old, unused files, and tidy the namespace and global variables (in #7b71ab9, #737a266, #5e83b2e).
* Updated pre-commit configurations to help maintain a clean and consistent coding style (in #39828fb, #466830e, #32e5f1e, #423e107, #4c1713f).
* Removed unnecessary dependencies such as miniUI to streamline the package (in #f337b32).

# early versions of gpttools 0.0.7

- comment code
- generate roxygen
Expand Down
9 changes: 4 additions & 5 deletions R/run-retriever.R → R/addin-run-retriever.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Run Chat GPT with Retrieval
#' Run Chat with Retrieval
#'
#' Run the ChatGPT shiny app with semantic search and document retrieval
#' Run the Chat with Retrieval shiny app
#'
#' @export
#'
Expand All @@ -9,10 +9,9 @@
#' @examples
#' # Call the function as an RStudio addin
#' \dontrun{
#' addin_run_retriever()
#' chat_with_retrieval()
#' }
addin_run_retriever <- function() {
gptstudio::check_api()
chat_with_retrieval <- function() {
indices <- list_index()
if (length(indices) == 0) {
cli::cli_abort(
Expand Down
117 changes: 117 additions & 0 deletions R/addin_scrape_pkgs.R
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)
}
Loading

0 comments on commit ffd1827

Please sign in to comment.