From 4c3e1af93f4b800dcbccf2b1bdfdcdf6a8f03ff0 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Mon, 25 Nov 2024 08:46:28 +0000 Subject: [PATCH] After code review: lint tests. --- .lintr | 2 -- tests/testthat/test-process_content.R | 14 ++++++++++---- tests/testthat/test-set_llm.R | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.lintr b/.lintr index 5485b57..37d7fa4 100644 --- a/.lintr +++ b/.lintr @@ -8,6 +8,4 @@ linters: linters_with_defaults( ), cyclocomp_linter = NULL ) -exclusions: list( - "tests") encoding: "UTF-8" diff --git a/tests/testthat/test-process_content.R b/tests/testthat/test-process_content.R index 2beb4a2..970a03b 100644 --- a/tests/testthat/test-process_content.R +++ b/tests/testthat/test-process_content.R @@ -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) diff --git a/tests/testthat/test-set_llm.R b/tests/testthat/test-set_llm.R index 188d447..d832a54 100644 --- a/tests/testthat/test-set_llm.R +++ b/tests/testthat/test-set_llm.R @@ -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 <- @@ -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"),