Skip to content

Commit

Permalink
After code review: lint tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Nov 25, 2024
1 parent 44bad11 commit 4c3e1af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ linters: linters_with_defaults(
),
cyclocomp_linter = NULL
)
exclusions: list(
"tests")
encoding: "UTF-8"
14 changes: 10 additions & 4 deletions tests/testthat/test-process_content.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ test_that("processing a single file content with deterministic output", {
set_llm(seed = 1014, api_args = list(temperature = 0)) |>
set_prompt(system_prompt = "Summarize provided conent with one, short sentence.")

test_content <- "Artificial intelligence (AI) plays a crucial role in transforming industries by automating repetitive tasks and enhancing productivity. It enables personalized experiences in sectors like healthcare, finance, and entertainment by analyzing vast amounts of data. AI algorithms assist in decision-making processes by providing insights that humans may overlook. In addition, AI is vital for advancements in technologies such as self-driving cars and smart home devices. Overall, AI acts as a powerful tool for innovation, driving efficiencies, and solving complex problems."
test_content <- paste0(
"Artificial intelligence (AI) plays a crucial role in transforming industries",
"by automating repetitive tasks and enhancing productivity. It enables personalized experiences",
"in sectors like healthcare, finance, and entertainment by analyzing vast amounts of data. AI algorithms",
"assist in decision-making processes by providing insights that humans may overlook. In addition,",
"AI is vital for advancements in technologies such as self-driving cars and smart home devices. Overall,",
"AI acts as a powerful tool for innovation, driving efficiencies, and solving complex problems."
)

httr2::with_verbosity(verbosity = 0, {

result <- process_content(gitai = my_project,
content = test_content)
result <- process_content(gitai = my_project,
content = test_content)
})
expect_length(gregexpr("\\.", result$text)[[1]], 1)

Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-set_llm.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that("setting system prompt", {

expect_error(
my_project |>
set_prompt(system_prompt = "You always return only 'Hi there!'")
set_prompt(system_prompt = "You always return only 'Hi there!'")
)

my_project <-
Expand All @@ -25,7 +25,8 @@ test_that("setting system prompt", {
set_prompt(system_prompt = "You always return only 'Hi there!'")

expect_equal(
my_project$llm$get_system_prompt(), "You always return only 'Hi there!'")
my_project$llm$get_system_prompt(), "You always return only 'Hi there!'"
)

expect_equal(
my_project$llm$chat("Hi"),
Expand Down

0 comments on commit 4c3e1af

Please sign in to comment.