Skip to content

Commit

Permalink
Fixes reference index page
Browse files Browse the repository at this point in the history
  • Loading branch information
edgararuiz committed Sep 23, 2024
1 parent c9c37d2 commit 6d08870
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions reference/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ description: Run multiple 'Large Language Model' predictions against a table, or
---
Function(s) | Description
|---|---|
|[llm_classify() \| llm_vec_classify()](reference/llm_classify.html)|Categorize data as one of options given|
|[llm_custom() \| llm_vec_custom()](reference/llm_custom.html)|Send a custom prompt to the LLM|
|[llm_extract() \| llm_vec_extract()](reference/llm_extract.html)|Extract entities from text|
|[llm_sentiment() \| llm_vec_sentiment()](reference/llm_sentiment.html)|Sentiment analysis|
|[llm_summarize() \| llm_vec_summarize()](reference/llm_summarize.html)|Summarize text|
|[llm_translate() \| llm_vec_translate()](reference/llm_translate.html)|Translates text to a specific language|
|[llm_use()](reference/llm_use.html)|Specify the model to use|
|[m_backend_prompt() \| m_backend_submit()](reference/m_backend_submit.html)|Functions to integrate different back-ends|
|[llm_classify() \| llm_vec_classify()](llm_classify.html)|Categorize data as one of options given|
|[llm_custom() \| llm_vec_custom()](llm_custom.html)|Send a custom prompt to the LLM|
|[llm_extract() \| llm_vec_extract()](llm_extract.html)|Extract entities from text|
|[llm_sentiment() \| llm_vec_sentiment()](llm_sentiment.html)|Sentiment analysis|
|[llm_summarize() \| llm_vec_summarize()](llm_summarize.html)|Summarize text|
|[llm_translate() \| llm_vec_translate()](llm_translate.html)|Translates text to a specific language|
|[llm_use()](llm_use.html)|Specify the model to use|
|[m_backend_prompt() \| m_backend_submit()](m_backend_submit.html)|Functions to integrate different back-ends|
2 changes: 1 addition & 1 deletion utils/website/build_reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build_reference_index <- function(pkg = ".", folder = "reference") {
try(dir_create(folder))
ref_path <- path(folder, "index", ext = "qmd")
try(file_delete(ref_path))
writeLines(reference_index(folder = folder), ref_path)
writeLines(reference_index(), ref_path)
cli_inform(col_green(ref_path))
}

Expand Down
13 changes: 6 additions & 7 deletions utils/website/index-page.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
reference_index <- function(pkg = ".", folder = "/reference") {
reference_index <- function(pkg = ".") {
if (is.character(pkg)) pkg <- pkgdown::as_pkgdown(pkg)
ref_list <- reference_to_list_index(pkg)
dir_out <- path(folder)
ref_convert <- reference_index_convert(ref_list, dir_out)
ref_convert <- reference_index_convert(ref_list)
res <- imap(
ref_convert,
\(.x, .y) {
Expand All @@ -23,8 +22,8 @@ reference_index <- function(pkg = ".", folder = "/reference") {
)
}

reference_index_convert <- function(index_list, dir_out = "") {
out <- map(index_list, \(.x) map(.x, reference_links, dir_out))
reference_index_convert <- function(index_list) {
out <- map(index_list, \(.x) map(.x, reference_links))
header <- c("Function(s) | Description", "|---|---|")
map(
out,
Expand All @@ -37,14 +36,14 @@ reference_index_convert <- function(index_list, dir_out = "") {
)
}

reference_links <- function(x, dir_out) {
reference_links <- function(x) {
# Manual fixes of special characters in funs variable
funcs <- x$funs
if (length(funcs) == 0) funcs <- x$alias
funcs <- gsub("&lt;", "<", funcs)
funcs <- gsub("&gt;", ">", funcs)
funcs <- paste0(funcs, collapse = " \\| ")
file_out <- path(dir_out, x$file_out)
file_out <- path(x$file_out)
desc <- x$title
c(
paste0("[", funcs, "](", file_out, ")"),
Expand Down

0 comments on commit 6d08870

Please sign in to comment.