Skip to contents

restore_module_config() rebuilds a program from a program artifact, such as one read from a pin written by pin_module_config() or created by program_artifact(). The restored program has the saved signatures, configuration and demonstrations but no chat; pass one at run time.

Usage

restore_module_config(config, registry = list(), trusted = FALSE)

Arguments

config

A program artifact, for example from pins::pin_read().

registry

Named runtime registry used to resolve saved function names; see program_artifact().

trusted

Whether embedded runtime values may be restored (default FALSE); see program_artifact().

Value

The restored program.

Examples

classifier <- module(signature("text -> sentiment"))
trainset <- data.frame(
  text = c("I love it!", "Terrible experience", "It's okay"),
  sentiment = c("positive", "negative", "neutral")
)
compiled <- compile(classifier, LabeledFewShot(k = 2L), trainset)

board <- pins::board_temp()
pin_module_config(board, "sentiment-classifier", compiled)
#> Creating new version '20260930T174429Z-6ca78'
#> Writing to pin 'sentiment-classifier'
#> ✔ Pinned program artifact: "sentiment-classifier"
#> ℹ Root module: <PredictModule>
#> ℹ Graph nodes: 1
#> ℹ Compiled: TRUE

artifact <- pins::pin_read(board, "sentiment-classifier")
restored <- restore_module_config(artifact)
#> ✔ Restored program artifact
#> ℹ Root module: <PredictModule>
#> ℹ Artifact version: 6
restored$is_compiled()
#> [1] TRUE

if (FALSE) { # \dontrun{
run(
  restored,
  text = "This is great!",
  .llm = ellmer::chat_openai(model = "gpt-6-luna")
)
} # }