-
Notifications
You must be signed in to change notification settings - Fork 37
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 #16 from jcrodriguez1989/develop
Release v0.2.2
- Loading branch information
Showing
25 changed files
with
255 additions
and
124 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
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,17 +1,21 @@ | ||
#' ChatGPT: Comment Code | ||
#' | ||
#' @param code The code to be commented by ChatGPT. | ||
#' @param code The code to be commented by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(comment_code("for (i in 1:10) {\n print(i ** 2)\n}")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
comment_code <- function(code) { | ||
comment_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Add inline comments to the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,21 @@ | ||
#' ChatGPT: Complete Code | ||
#' | ||
#' @param code The code to be completed by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(complete_code("# A function to square each element of a vector\nsquare_each <- function(")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
complete_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Complete the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Create Variable Name | ||
#' | ||
#' @param code The code for which to give a variable name to its result. | ||
#' @param code The code for which to give a variable name to its result. If not provided, it will | ||
#' use what's copied on the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(create_variable_name("sapply(1:10, function(i) i ** 2)")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
create_variable_name <- function(code) { | ||
create_variable_name <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Give a good variable name to the result of the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Document Code (in roxygen2 format) | ||
#' | ||
#' @param code The code to be documented by ChatGPT. | ||
#' @param code The code to be documented by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(document_code("square_numbers <- function(numbers) numbers ** 2")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
document_code <- function(code) { | ||
document_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Document, in roxygen2 format, this R function: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Explain Code | ||
#' | ||
#' @param code The code to be explained by ChatGPT. | ||
#' @param code The code to be explained by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(explain_code("for (i in 1:10) {\n print(i ** 2)\n}")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
explain_code <- function(code) { | ||
explain_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Explain the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Find Issues in Code | ||
#' | ||
#' @param code The code to be analyzed by ChatGPT. | ||
#' @param code The code to be analyzed by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(find_issues_in_code("i <- 0\nwhile (i < 0) {\n i <- i - 1\n}")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
find_issues_in_code <- function(code) { | ||
find_issues_in_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Find issues or bugs in the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Optimize Code | ||
#' | ||
#' @param code The code to be optimized by ChatGPT. | ||
#' @param code The code to be optimized by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(optimize_code("i <- 10\nwhile (i > 0) {\n i <- i - 1\n print(i)\n}")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
optimize_code <- function(code) { | ||
optimize_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Optimize the following R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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,17 +1,21 @@ | ||
#' ChatGPT: Refactor Code | ||
#' | ||
#' @param code The code to be refactored by ChatGPT. | ||
#' @param code The code to be refactored by ChatGPT. If not provided, it will use what's copied on | ||
#' the clipboard. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' cat(refactor_code("i <- 10\nwhile (i > 0) {\n i <- i - 1\n print(i)\n}")) | ||
#' } | ||
#' | ||
#' @importFrom clipr read_clip | ||
#' | ||
#' @return A character value with the response generated by ChatGPT. | ||
#' | ||
#' @export | ||
#' | ||
refactor_code <- function(code) { | ||
refactor_code <- function(code = clipr::read_clip(allow_non_interactive = TRUE)) { | ||
code <- paste(gsub('"', "'", code), collapse = "\n") | ||
prompt <- paste0('Refactor the following R code, returning valid R code: "', code, '"') | ||
parse_response(gpt_get_completions(prompt)) | ||
} |
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
Oops, something went wrong.