diff --git a/tests/testthat/_snaps/llm-custom.md b/tests/testthat/_snaps/llm-custom.md new file mode 100644 index 0000000..5e1342a --- /dev/null +++ b/tests/testthat/_snaps/llm-custom.md @@ -0,0 +1,14 @@ +# Custom on Ollama works + + Code + llm_custom(reviews_table(), review, my_prompt) + Output + review + 1 This has been the best TV I've ever used. Great screen, and sound. + 2 I regret buying this laptop. It is too slow and the keyboard is too noisy + 3 Not sure how to feel about my new washing machine. Great color, but hard to figure + .pred + 1 Yes + 2 No + 3 No + diff --git a/tests/testthat/_snaps/llm-extract.md b/tests/testthat/_snaps/llm-extract.md new file mode 100644 index 0000000..4da22b7 --- /dev/null +++ b/tests/testthat/_snaps/llm-extract.md @@ -0,0 +1,14 @@ +# Extract on Ollama works + + Code + llm_extract(reviews_table(), review, "product") + Output + review + 1 This has been the best TV I've ever used. Great screen, and sound. + 2 I regret buying this laptop. It is too slow and the keyboard is too noisy + 3 Not sure how to feel about my new washing machine. Great color, but hard to figure + .extract + 1 tv + 2 laptop + 3 washing machine + diff --git a/tests/testthat/_snaps/llm-summarize.md b/tests/testthat/_snaps/llm-summarize.md new file mode 100644 index 0000000..ad13916 --- /dev/null +++ b/tests/testthat/_snaps/llm-summarize.md @@ -0,0 +1,14 @@ +# Summarize on Ollama works + + Code + llm_summarize(reviews_table(), review, max_words = 5) + Output + review + 1 This has been the best TV I've ever used. Great screen, and sound. + 2 I regret buying this laptop. It is too slow and the keyboard is too noisy + 3 Not sure how to feel about my new washing machine. Great color, but hard to figure + .summary + 1 very good tv experience overall + 2 slow and noisy laptop purchase + 3 mixed feelings about new washer + diff --git a/tests/testthat/_snaps/llm-translate.md b/tests/testthat/_snaps/llm-translate.md new file mode 100644 index 0000000..b319411 --- /dev/null +++ b/tests/testthat/_snaps/llm-translate.md @@ -0,0 +1,14 @@ +# Translate on Ollama works + + Code + llm_translate(reviews_table(), review, "spanish") + Output + review + 1 This has been the best TV I've ever used. Great screen, and sound. + 2 I regret buying this laptop. It is too slow and the keyboard is too noisy + 3 Not sure how to feel about my new washing machine. Great color, but hard to figure + .translation + 1 Este ha sido el mejor televisor que he utilizado. Gran pantalla y sonido. + 2 Lamento haber comprado esta laptop. Está demasiado lenta y el teclado es demasiado ruidoso. + 3 No estoy seguro de cómo sentirme sobre mi nueva lavadora. Color genial, pero difícil de manejar. + diff --git a/tests/testthat/test-llm-custom.R b/tests/testthat/test-llm-custom.R index fdfc9a5..1f79531 100644 --- a/tests/testthat/test-llm-custom.R +++ b/tests/testthat/test-llm-custom.R @@ -20,3 +20,14 @@ test_that("Custom works", { data.frame(x = test_text, new = test_text) ) }) + +test_that("Custom on Ollama works",{ + skip_if_no_ollama() + my_prompt <- paste( + "Answer a question.", + "Return only the answer, no explanation", + "Acceptable answers are 'yes', 'no'", + "Answer this about the following text, is this a happy customer?:" + ) + expect_snapshot(llm_custom(reviews_table(), review, my_prompt)) +}) diff --git a/tests/testthat/test-llm-extract.R b/tests/testthat/test-llm-extract.R index f3b1328..14648f6 100644 --- a/tests/testthat/test-llm-extract.R +++ b/tests/testthat/test-llm-extract.R @@ -38,3 +38,8 @@ test_that("Extract works", { data.frame(x = entries2, y = "toaster", z = "TV") ) }) + +test_that("Extract on Ollama works",{ + skip_if_no_ollama() + expect_snapshot(llm_extract(reviews_table(), review, "product")) +}) diff --git a/tests/testthat/test-llm-summarize.R b/tests/testthat/test-llm-summarize.R index 2ad1966..bb84344 100644 --- a/tests/testthat/test-llm-summarize.R +++ b/tests/testthat/test-llm-summarize.R @@ -20,3 +20,8 @@ test_that("Summarize works", { data.frame(x = test_text, new = test_text) ) }) + +test_that("Summarize on Ollama works",{ + skip_if_no_ollama() + expect_snapshot(llm_summarize(reviews_table(), review, max_words = 5)) +}) \ No newline at end of file diff --git a/tests/testthat/test-llm-translate.R b/tests/testthat/test-llm-translate.R index c84359d..b9fb4aa 100644 --- a/tests/testthat/test-llm-translate.R +++ b/tests/testthat/test-llm-translate.R @@ -21,3 +21,8 @@ test_that("Translate works", { data.frame(x = test_text, new = test_text) ) }) + +test_that("Translate on Ollama works",{ + skip_if_no_ollama() + expect_snapshot(llm_translate(reviews_table(), review, "spanish")) +}) \ No newline at end of file