Skip to content

Commit

Permalink
addin for select pkgs; other minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHWade committed Jan 21, 2024
1 parent 2027dbb commit 1adef8c
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 72 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(add_roxygen_addin)
export(addin_run_retriever)
export(addin_run_select_pkgs)
export(chat_with_context)
export(chat_with_context_azure)
export(collect_dataframes)
Expand All @@ -24,6 +25,7 @@ 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_url)
export(script_to_function_addin)
Expand All @@ -38,3 +40,5 @@ importFrom(utils,globalVariables)
importFrom(utils,head)
importFrom(utils,installed.packages)
importFrom(utils,old.packages)
importFrom(utils,packageDescription)
importFrom(utils,packageVersion)
File renamed without changes.
29 changes: 28 additions & 1 deletion R/app-select-pkgs.R → R/addin_select_pkgs.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
#' 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()

Check warning on line 10 in R/addin_select_pkgs.R

View check run for this annotation

Codecov / codecov/patch

R/addin_select_pkgs.R#L10

Added line #L10 was not covered by tests
}

#' 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() |>
Expand All @@ -6,7 +33,7 @@ run_select_pkgs_app <- function() {

ui <- bslib::page_sidebar(
title = "Package Selector",
theme = bslib::bs_theme(version = 5, bootswatch = "morph"),
theme = bslib::bs_theme(version = 5, bootswatch = "litera"),
sidebar = bslib::sidebar(
width = 400,
shiny::selectInput(
Expand Down
16 changes: 4 additions & 12 deletions R/gpt-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ gpt_chat <- function(instructions,
content = glue("{query}")
)
)
cli::cli_process_start(msg = "Sending query to {service}")
cli::cli_progress_update()
cli::cli_inform("Service: {service}")
cli::cli_inform("Model: {model}")
cli::cli_inform("Sending query... this can take up to 3 minutes.")
simple_prompt <- prompt |>
purrr::map_chr(.f = "content") |>
paste(collapse = "\n\n")

Check warning on line 46 in R/gpt-query.R

View check run for this annotation

Codecov / codecov/patch

R/gpt-query.R#L41-L46

Added lines #L41 - L46 were not covered by tests

cat(simple_prompt, "\n\n")

cli::cli_inform("Service: {service}")
cli::cli_inform("Model: {model}")

answer <-
gptstudio:::gptstudio_create_skeleton(
service = service,
Expand All @@ -59,11 +55,7 @@ gpt_chat <- function(instructions,
gptstudio:::gptstudio_request_perform()

Check warning on line 55 in R/gpt-query.R

View check run for this annotation

Codecov / codecov/patch

R/gpt-query.R#L55

Added line #L55 was not covered by tests

cli::cli_process_done(msg_done = "Received response from {service}")
text_to_insert <- c(
as.character(query),
as.character(answer$choices$message.content)
)
cli::cli_inform("Text to insert: {text_to_insert}")
text_to_insert <- as.character(answer$response)

Check warning on line 58 in R/gpt-query.R

View check run for this annotation

Codecov / codecov/patch

R/gpt-query.R#L57-L58

Added lines #L57 - L58 were not covered by tests
insert_text(text_to_insert)
}

Expand Down
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ global_vars <- c(
"embeddings",
"head",
"installed.packages",
"indexed_version",
"installed_version",
"link",
"name",
"old.packages",
Expand Down
93 changes: 38 additions & 55 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,71 +1,54 @@
Addin
addin
addins
airquality
assertthat
aut
BugReports
ChatGPT
cli
CMD
ChatGPT
ChatGPT's
Cmd
Codecov
Config
covr
cre
Conda
Ctrl
GPT
Gitlab
Keras
LLMs
Lifecycle
Miniconda
NLP
NumPy
ORCID
OpenAI
PyPI
RStudio
Renviron
Retreival
Roxygen
Rstudio
Sitrep
WIP
YAML
addin
addins
chatbot
conda
config
davinci
devtools
faq
Freeform
embeddings
freeform
github
gitignore
Gitlab
GPT
gpt
gptstudio
gpttools
https
httr
io
jameshwade
JamesHWade
jsonlite
Lifecycle
LLMs
magrittr
MERCHANTABILITY
miniUI
mockr
mozilla
mtcars
NLP
NONINFRINGEMENT
OpenAI
miniconda
openai
OpenAI's
OpenAI’s
ORCID
pre
PRs
purrr
Renviron
rlang
Roxygen
prebuilt
reticulate
roxygen
RoxygenNote
RStudio
rstudioapi
selectionGet
sexualized
shinytest
skimr
socio
sublicense
summarization
tensorflow
testthat
usethis
uuid
WIP
withr
www
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tibble
venv
virtualenv
whl
11 changes: 8 additions & 3 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name: ChatGPT with Retrieval
Name: Chat with Retrieval
Description: Semantic search and document retrieval for use with ChatGPT
Binding: addin_run_retriever
Interactive: true
Expand All @@ -19,11 +19,16 @@ Binding: suggest_unit_test_addin
Interactive: false

Name: Document Data
Description: Uses OpenAI's GPT-3.5 to document data for a package with help from the user
Description: Uses AI service to document data for a package with help from the user
Binding: document_data
Interactive: true

Name: Suggest Improvements
Description: Uses OpenAI's GPT-3.5 to make suggestions to improve user selected code
Description: Uses AI service to make suggestions to improve user selected code
Binding: suggest_code_improvements
Interactive: false

Name: Select Packages to Scrape
Description: Select packages to scrape for use in Chat with Retrieval app
Binding: addin_run_select_pkgs
Interactive: true
2 changes: 1 addition & 1 deletion man/addin_run_retriever.Rd

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

14 changes: 14 additions & 0 deletions man/addin_run_select_pkgs.Rd

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

24 changes: 24 additions & 0 deletions man/run_select_pkgs_app.Rd

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

0 comments on commit 1adef8c

Please sign in to comment.