Assign names + descriptions to every theme and subtheme in one AI call
Source:R/theme_algorithm_v2.R
ai_label_theme_set.RdSingle AI call after convergence. The AI sees the FULL tree (themes -> subthemes -> codes) with every member code visible, and assigns researcher-facing names + descriptions to every node. Cross-theme name distinctness is explicitly enforced via the prompt; the AI is told that if two themes both deserve the same name, the underlying structure is wrong.
Usage
ai_label_theme_set(
skeleton,
codes,
provider,
research_focus = "",
concept_str = "",
reflexivity_block = "",
audit_log = NULL,
response_cache = NULL,
methodology_override = NULL,
walk_state = NULL
)Details
The schema (.theme_labeling_schema()) requires the AI to return
the same number of themes as the skeleton has, and the same number of
subthemes per theme. The orchestrator binds names positionally via
theme_index / subtheme_index.
On AI failure or malformed response, falls back to derived names (top member code per theme) so the run still produces an output – but logs a warning so the operator knows labeling didn't succeed.