Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 1, 2024
1 parent b8d0c13 commit b332e46
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
48 changes: 24 additions & 24 deletions R/history.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ create_history <- function(file_name = "chat_history",

if (!dir.exists(tools::file_path_sans_ext(file_path))) {
dir.create(tools::file_path_sans_ext(file_path),
recursive = TRUE, showWarnings = FALSE
recursive = TRUE, showWarnings = FALSE
)
}

Expand Down Expand Up @@ -119,7 +119,7 @@ save_user_history <- function(file_name = "chat_history",
get_query_embedding <- function(query, local = FALSE, model = NULL) {
if (local) {
create_text_embeddings(query,
model = model
model = model
) |>
dplyr::pull(embedding) |>
unlist()
Expand Down Expand Up @@ -217,8 +217,8 @@ chat_with_context <- function(query,
if (rlang::is_true(add_context) || rlang::is_true(add_history)) {
cli_alert_info("Creating embedding from query.")
query_embedding <- get_query_embedding(query,
local = local,
model = embedding_model
local = local,
model = embedding_model
)
}

Expand Down Expand Up @@ -269,35 +269,35 @@ chat_with_context <- function(query,

prompt_instructions <-
switch(task,
"Context Only" =
list(
list(
role = "system",
content =
glue(
"You are a helpful chat bot that answers questions based on
"Context Only" =
list(
list(
role = "system",
content =
glue(
"You are a helpful chat bot that answers questions based on
the context provided by the user. If the user does not
provide related context and you need context to respond
accurately, say \"I am not able to answer that question.
Maybe try rephrasing your question in a different way.\""
)
)
),
"Permissive Chat" =
list(
list(
role = "system",
content =
glue(
"You are a helpful chat bot that answers questions based on
)
)
),
"Permissive Chat" =
list(
list(
role = "system",
content =
glue(
"You are a helpful chat bot that answers questions based on
on the context provided by the user. If the user does not
provide context and you need context to respond correctly,
answer the quest but first say \"I am not able to answer
that question with the context you gave me, but here is my
best but here is my best answer."
)
)
)
)
)
)
)

prompt_context <- list(
Expand Down
4 changes: 2 additions & 2 deletions R/index.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ load_index <- function(domain, local_embeddings = FALSE) {
if (local_embeddings) {
sample_index <-
system.file("sample-index/local/jameshwade-github-io-gpttools.parquet",
package = "gpttools"
package = "gpttools"

Check warning on line 83 in R/index.R

View check run for this annotation

Codecov / codecov/patch

R/index.R#L80-L83

Added lines #L80 - L83 were not covered by tests
)
} else {
sample_index <-
system.file("sample-index/jameshwade-github-io-gpttools.parquet",
package = "gpttools"
package = "gpttools"

Check warning on line 88 in R/index.R

View check run for this annotation

Codecov / codecov/patch

R/index.R#L86-L88

Added lines #L86 - L88 were not covered by tests
)
}
index <- arrow::read_parquet(sample_index)
Expand Down
6 changes: 3 additions & 3 deletions inst/retriever/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ui <- page_fillable(
selected = getOption("gpttools.service", "openai")
),
selectInput("model", "Model",
choices = NULL
choices = NULL
),
selectInput(
"embed_model", "OpenAI Embedding Model",
Expand Down Expand Up @@ -276,8 +276,8 @@ server <- function(input, output, session) {
)
)
observe(updateSelectInput(session, "source",
choices = c("All", indices()),
selected = getOption("gpttools.sources", "All")
choices = c("All", indices()),
selected = getOption("gpttools.sources", "All")
))
observe({
toggle_popover("settings", show = FALSE)
Expand Down

0 comments on commit b332e46

Please sign in to comment.