| CustomProvider | R Documentation |
A provider that wraps a user-supplied
function(prompt, schema, ...) -> list | character. This is the
offline end-to-end seam and the escape hatch for backends the built-in HTTP
providers do not cover. It uses NO network and needs neither httr2
nor jsonlite.
The user function is run inside tryCatch: if it errors, the provider
degrades to exactly one warning() plus an 'es_provider_response' with
text = NA_character_ – it never crashes the session.
ProviderBase -> CustomProvider
CustomProvider$new()Construct a CustomProvider.
CustomProvider$new(fn, model = NULL, ...)
fnA function of (prompt, schema, ...) returning a list or a
character completion. Required.
modelOptional character model identifier (informational only).
...Ignored; forwarded for forward-compatibility.
CustomProvider$complete()Run the wrapped user function and wrap its result in an 'es_provider_response'. A throwing function degrades to one warning + NA.
CustomProvider$complete(prompt, schema = NULL, ...)
promptCharacter prompt passed to the user function.
schemaOptional structured-output schema passed through to the user function.
...Additional arguments forwarded to the user function.
An 'es_provider_response' (see ProviderBase$complete).
CustomProvider$clone()The objects of this class are cloneable with this method.
CustomProvider$clone(deep = FALSE)
deepWhether to make a deep clone.
Other eventstudy-advisor:
AnthropicProvider,
OpenAICompatProvider,
ProviderBase,
es_advise(),
es_diagnostics(),
es_kb(),
flag_robustness(),
provider(),
recommend_stat()
# In-process, no network: the user function supplies the completion text.
p <- CustomProvider$new(function(prompt, schema) "canned advice")
res <- p$complete("Summarise these diagnostics")
res$text
res$source
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.