Skip to content

Commit

Permalink
Merge pull request #54 from mlverse/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
edgararuiz authored Dec 11, 2023
2 parents 210cfb2 + 137e0f9 commit b0dde1b
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 50 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: chattr
Title: Integrates LLM's with the RStudio IDE
Version: 0.0.0.9005
Version: 0.0.0.9006
Authors@R: c(
person("Edgar", "Ruiz", , "[email protected]", role = c("aut", "cre")),
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
Expand Down
6 changes: 3 additions & 3 deletions R/backend-openai-core.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ openai_token <- function() {
if (is.null(ret)) {
abort("No token found
- Add your key to the \"OPENAI_API_KEY\" environment variable
- or - Add \"open-ai-api-key\" to a `config` YAML file")
- or - Add \"openai-api-key\" to a `config` YAML file")
}

ret
Expand Down Expand Up @@ -47,7 +47,7 @@ openai_stream_ide <- function(defaults, req_body) {
} else {
if (!ui_current_console()) ide_paste_text("\n\n")
openai_request(defaults, req_body) %>%
req_stream(
req_perform_stream(
function(x) {
openai_stream_ide_delta(x, defaults)
TRUE
Expand Down Expand Up @@ -115,7 +115,7 @@ openai_stream_file <- function(defaults,
ch_env$stream$response <- NULL

openai_request(defaults, req_body) %>%
req_stream(
req_perform_stream(
function(x) {
openai_stream_file_delta(x, defaults, r_file_stream)
TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/chattr-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ chattr_defaults <- function(type = "default",
if (!is.na(env_model)) {
check_files <- package_file("configs", path_ext_set(env_model, "yml"))
} else {
check_files <- package_file("configs", "gpt35.yml")
check_files <- package_file("configs", "gpt4.yml")
}

if (file_exists(yaml_file)) {
Expand Down
2 changes: 1 addition & 1 deletion R/chatter-use.R → R/chattr-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ chattr_use <- function(model_label = NULL) {
}

if (is.null(model_label)) {
model_label <- "gpt35"
model_label <- "gpt4"
}

use_switch("configs", path_ext_set(model_label, "yml"))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ back-end provides access to multiple LLM types:
href="https://platform.openai.com/docs/introduction">OpenAI</a></td>
<td style="text-align: center;">GPT Models accessible via the OpenAI’s
REST API. <code>chattr</code> provides a convenient way to interact with
GPT 3.5, and DaVinci 3.</td>
GPT 4, 3.5, and DaVinci 3.</td>
<td style="text-align: center;"><a
href="https://mlverse.github.io/chattr/articles/openai-gpt.html">Interact
with OpenAI GPT models</a></td>
Expand Down Expand Up @@ -174,7 +174,7 @@ chattr(preview = TRUE)
#> ── Preview for: Console
#> • Provider: Open AI - Chat Completions
#> • Path/URL: https://api.openai.com/v1/chat/completions
#> • Model: gpt-3.5-turbo
#> • Model: gpt-4
#> • temperature: 0.01
#> • max_tokens: 1000
#> • stream: TRUE
Expand Down
2 changes: 1 addition & 1 deletion README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ provides access to multiple LLM types:

| Provider | Models | Setup Instructions |
|:-----------------:|:----------------------------------:|:-----------------:|
| [OpenAI](https://platform.openai.com/docs/introduction) | GPT Models accessible via the OpenAI's REST API. `chattr` provides a convenient way to interact with GPT 3.5, and DaVinci 3. | [Interact with OpenAI GPT models](`r url`articles/openai-gpt.html) |
| [OpenAI](https://platform.openai.com/docs/introduction) | GPT Models accessible via the OpenAI's REST API. `chattr` provides a convenient way to interact with GPT 4, 3.5, and DaVinci 3. | [Interact with OpenAI GPT models](`r url`articles/openai-gpt.html) |
| [LLamaGPT-Chat](https://github.com/kuvaus/LlamaGPTJ-chat) | LLM models available in your computer. Including GPT-J, LLaMA, and MPT. Tested on a [GPT4ALL](https://gpt4all.io/index.html) model. **LLamaGPT-Chat** is a command line chat program for models written in C++. | [Interact with local models](`r url`articles/backend-llamagpt.html) |

The idea is that as time goes by, more back-ends will be added.
Expand Down
32 changes: 32 additions & 0 deletions inst/configs/gpt4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default:
prompt: |
{readLines(system.file('prompt/base.txt', package = 'chattr'))}
provider: Open AI - Chat Completions
path: https://api.openai.com/v1/chat/completions
model: gpt-4
max_data_files: 0
max_data_frames: 0
include_doc_contents: FALSE
include_history: TRUE
system_msg: You are a helpful coding assistant
model_arguments:
temperature: 0.01
max_tokens: 1000
stream: TRUE
chat:
prompt: |
{readLines(system.file('prompt/base.txt', package = 'chattr'))}
For code output, use RMarkdown code chunks
Avoid all code chunk options
console:
prompt: |
{readLines(system.file('prompt/base.txt', package = 'chattr'))}
For any line that is not code, prefix with a: #
Keep each line of explanations to no more than 80 characters
DO NOT use Markdown for the code
script:
prompt: |
{readLines(system.file('prompt/base.txt', package = 'chattr'))}
For any line that is not code, prefix with a: #
Keep each line of explanations to no more than 80 characters
DO NOT use Markdown for the code
2 changes: 1 addition & 1 deletion man/chattr_use.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/app_ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/backend-llamagpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("llamagpt")
Message <cliMessage>
Message
-- chattr
* Provider: LlamaGPT
Expand All @@ -13,7 +13,7 @@

Code
chattr_test(defaults = chattr_defaults())
Message <cliMessage>
Message
-- Testing chattr
* Provider: LlamaGPT
Expand All @@ -34,7 +34,7 @@

Code
ch_llamagpt_printout(chattr_defaults(), output = "xxx\n> ")
Message <cliMessage>
Message
-- chattr --
Expand All @@ -54,7 +54,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/backend-openai-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
openai_request(chattr_defaults(), list())
Message <cliMessage>
Message
<httr2_request>
POST https://api.openai.com/v1/chat/completions
Headers:
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/backend-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand All @@ -13,7 +13,7 @@

Code
app_init_openai(chattr_defaults())
Message <cliMessage>
Message
* Provider: Open AI - Chat Completions
* Path/URL: https://api.openai.com/v1/chat/completions
* Model: gpt-3.5-turbo
Expand All @@ -26,7 +26,7 @@

Code
chattr_use("llamagpt")
Message <cliMessage>
Message
-- chattr
* Provider: LlamaGPT
Expand All @@ -37,7 +37,7 @@

Code
app_init_openai(chattr_defaults())
Message <cliMessage>
Message
* Provider: LlamaGPT
* Path/URL: ~/LlamaGPTJ-chat/build/bin/chat
* Model: ~/ggml-gpt4all-j-v1.3-groovy.bin
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/ch-defaults-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/ch_defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("llamagpt")
Message <cliMessage>
Message
-- chattr
* Provider: LlamaGPT
Expand All @@ -13,7 +13,7 @@

Code
chattr_defaults()
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down
26 changes: 15 additions & 11 deletions tests/testthat/_snaps/chatter-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

Code
capture.output(ch_get_ymls())
Message <cliMessage>
Message
-- chattr - Available models
1: Open AI - Completions - text-davinci-003 (davinci)
2: Open AI - Chat Completions - gpt-3.5-turbo (gpt35)
3: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt)
3: Open AI - Chat Completions - gpt-4 (gpt4)
4: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt)
Output
[1] "$davinci"
[2] "[1] \"1: Open AI - Completions - text-davinci-003 (davinci) \\n\""
[3] ""
[4] "$gpt35"
[5] "[1] \"2: Open AI - Chat Completions - gpt-3.5-turbo (gpt35) \\n\""
[6] ""
[7] "$llamagpt"
[8] "[1] \"3: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt) \\n\""
[9] ""
[1] "$davinci"
[2] "[1] \"1: Open AI - Completions - text-davinci-003 (davinci) \\n\""
[3] ""
[4] "$gpt35"
[5] "[1] \"2: Open AI - Chat Completions - gpt-3.5-turbo (gpt35) \\n\""
[6] ""
[7] "$gpt4"
[8] "[1] \"3: Open AI - Chat Completions - gpt-4 (gpt4) \\n\""
[9] ""
[10] "$llamagpt"
[11] "[1] \"4: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt) \\n\""
[12] ""

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/chattr-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand All @@ -13,7 +13,7 @@

Code
chattr_test()
Message <cliMessage>
Message
-- Testing chattr
* Provider: Open AI - Chat Completions
Expand All @@ -27,7 +27,7 @@

Code
chattr_use("llamagpt")
Message <cliMessage>
Message
-- chattr
* Provider: LlamaGPT
Expand All @@ -38,7 +38,7 @@

Code
chattr_test()
Message <cliMessage>
Message
-- Testing chattr
* Provider: LlamaGPT
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/_snaps/chattr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
chattr_use("gpt35")
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Chat Completions
Expand All @@ -13,7 +13,7 @@

Code
chattr("test", preview = TRUE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down Expand Up @@ -45,7 +45,7 @@

Code
chattr("test", preview = TRUE, prompt_build = FALSE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand All @@ -64,7 +64,7 @@

Code
chattr("test", preview = TRUE, stream = FALSE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down Expand Up @@ -96,7 +96,7 @@

Code
chattr(preview = TRUE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down Expand Up @@ -164,7 +164,7 @@

Code
ch_use_openai_davinci()
Message <cliMessage>
Message
-- chattr
* Provider: Open AI - Completions
Expand All @@ -175,7 +175,7 @@

Code
chattr("test", preview = TRUE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down Expand Up @@ -225,7 +225,7 @@

Code
chattr(preview = TRUE)
Message <cliMessage>
Message
-- chattr ----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit b0dde1b

Please sign in to comment.