-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
71 lines (60 loc) · 2.37 KB
/
app.R
File metadata and controls
71 lines (60 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
source("R/packages.R")
source("R/utils_demo_agnews.R")
source("R/utils_storage.R")
source("R/utils_text.R")
source("R/utils_openai.R")
source("R/utils_hierarchy.R")
source("R/utils_vectorize.R")
source("R/utils_metrics.R")
source("R/utils_models.R")
source("R/utils_seeding.R")
source("R/modules-data.R")
source("R/modules-enrichment.R")
source("R/modules-scoring.R")
source("R/modules-settings.R")
# ---- Config laden ----
config <- NULL
config_path <- file.path("config", "config.yml")
if (file.exists(config_path)) {
config <- yaml::read_yaml(config_path)
} else {
warning("config.yml niet gevonden in ./config – OpenAI-config wordt overgeslagen.")
}
# OpenAI API key from config → environment variable
if (!is.null(config$openai$api_key) && nzchar(config$openai$api_key)) {
Sys.setenv(OPENAI_API_KEY = config$openai$api_key)
}
# Standard model for search enrichment
if (!is.null(config$openai$model) && nzchar(config$openai$model)) {
options(dabling_search_llm = config$openai$model)
}
options(AUTOCLASSIFY_LLM_DEBUG = TRUE)
ui <- navbarPage(
title = "Auto-Classification Prototype",
id = "mainnav",
tabPanel("Data", data_ui("data")),
tabPanel("Enrichment",enrichment_ui("enrich")),
tabPanel("Scoring", scoring_ui("score")),
tabPanel("Settings", settings_ui("settings"))
)
server <- function(input, output, session) {
data_res <- data_server("data")
enrich_res <- enrichment_server("enrich",
docs = data_res$docs,
schema = data_res$schema,
labels = data_res$labels,
language = data_res$language,
ckpt_dir = data_res$ckpt_dir)
scoring_res <- scoring_server("score",
docs_enriched = enrich_res$docs_enriched,
cats_enriched = enrich_res$cats_enriched,
labels = data_res$labels,
language = data_res$language,
ckpt_dir = data_res$ckpt_dir)
settings_server("settings",
docs_enriched = enrich_res$docs_enriched,
cats_enriched = enrich_res$cats_enriched,
scores = scoring_res$scores,
ckpt_dir = data_res$ckpt_dir)
}
shinyApp(ui, server)