-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from edgararuiz/updates
Updates
- Loading branch information
Showing
19 changed files
with
152 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ utils/ | |
^pkgdown$ | ||
^\.github$ | ||
^codecov\.yml$ | ||
^_mall_cache/ | ||
^_mall_cache/ | ||
^_readme_cache/ | ||
^_prompt_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
test_that("Extract works", { | ||
llm_use("simulate_llm", "echo", .silent = TRUE, .force = TRUE) | ||
llm_use("simulate_llm", "prompt", .silent = TRUE, .force = TRUE) | ||
|
||
expect_equal( | ||
llm_vec_extract("{\"product\":\"toaster\"}", labels = "product"), | ||
"toaster" | ||
expect_snapshot( | ||
llm_vec_extract("toaster", labels = "product") | ||
) | ||
}) | ||
|
||
test_that("Extract data frame works", { | ||
llm_use("simulate_llm", "echo", .silent = TRUE, .force = TRUE) | ||
|
||
entries2 <- "{\"product\":\"toaster\", \"product\":\"TV\"}" | ||
entries2_result <- "toaster|TV" | ||
expect_equal( | ||
llm_vec_extract( | ||
entries2, | ||
labels = "product" | ||
), | ||
entries2_result | ||
) | ||
expect_equal( | ||
llm_extract(data.frame(x = entries2), x, labels = "product"), | ||
data.frame(x = entries2, .extract = entries2_result) | ||
llm_extract(data.frame(x = "test"), x, labels = "product"), | ||
data.frame(x = "test", .extract = "test") | ||
) | ||
|
||
expect_equal( | ||
llm_extract( | ||
.data = data.frame(x = entries2), | ||
.data = data.frame(x = "test1|test2"), | ||
col = x, | ||
labels = c("product1", "product2"), | ||
expand_cols = TRUE | ||
), | ||
data.frame(x = entries2, product1 = "toaster", product2 = "TV") | ||
data.frame(x = "test1|test2", product1 = "test1", product2 = "test2") | ||
) | ||
|
||
expect_equal( | ||
llm_extract( | ||
.data = data.frame(x = entries2), | ||
.data = data.frame(x = "test1|test2"), | ||
col = x, | ||
labels = c(y = "product1", z = "product2"), | ||
expand_cols = TRUE | ||
), | ||
data.frame(x = entries2, y = "toaster", z = "TV") | ||
data.frame(x = "test1|test2", y = "test1", z = "test2") | ||
) | ||
}) | ||
|
||
test_that("Extract on Ollama works", { | ||
skip_if_no_ollama() | ||
expect_snapshot(llm_extract(reviews_table(), review, "product")) | ||
expect_snapshot( | ||
llm_vec_extract("bob smith, 105 2nd street", c("name", "address")) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
test_that("Prompt handles list()", { | ||
llm_use( | ||
backend = "simulate_llm", | ||
model = "prompt", | ||
.silent = TRUE, | ||
.force = TRUE, | ||
.cache = "_prompt_cache" | ||
) | ||
test_text <- "Custom:{prompt}\n{{x}}" | ||
expect_equal( | ||
llm_vec_custom(x = "new test", prompt = test_text), | ||
list(list(role = "user", content = test_text)) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters