Skip to content

Commit 2921f4b

Browse files
committed
add tests for setting seed
1 parent d436820 commit 2921f4b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/testthat/test-chat.R

+16
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,19 @@ test_that("Test output parameter", {
6969
c("model", "role", "response")
7070
)
7171
})
72+
73+
test_that("Test seed", {
74+
skip_if_not(ping_ollama(silent = TRUE))
75+
snapshot <- query("test", model_params = list(seed = 42), output = "text")
76+
expect_equal(query("test", model_params = list(seed = 42), output = "text"),
77+
snapshot)
78+
expect_equal({
79+
withr::with_options(list(rollama_seed = 42),
80+
query("test", output = "text"))
81+
}, snapshot)
82+
# different seed, different result
83+
expect_false(isTRUE(all.equal(
84+
query("test", model_params = list(seed = 1), output = "text"),
85+
snapshot
86+
)))
87+
})

0 commit comments

Comments
 (0)