| foundry_extract | R Documentation |
Apply a JSON Schema to one or more text inputs and return model-extracted fields as a tidy tibble. This is useful for research coding tasks such as sentiment annotation, entity extraction, study abstraction, and converting free-text records into analyzable variables.
foundry_extract(
text,
schema = NULL,
text_col = NULL,
instructions = NULL,
schema_name = "ExtractedData",
strict = TRUE,
model = NULL,
flatten = TRUE,
store = FALSE,
max_active = 2L,
progress = TRUE,
api_key = NULL,
endpoint = NULL,
...
)
text |
Character vector or data frame. Texts to extract from, or a data frame containing a text column. |
schema |
List. JSON Schema object describing the fields to extract. |
text_col |
Character. Column name containing text when |
instructions |
Character. Optional extraction instructions. If omitted, a concise default extraction instruction is used. |
schema_name |
Character. Name for the JSON Schema format. |
strict |
Logical. Whether the model must strictly follow the schema. |
model |
Character. The model deployment name. Defaults to
|
flatten |
Logical. If |
store |
Logical. Whether to store Responses API objects. Defaults to
|
max_active |
Integer. Maximum number of concurrent requests. |
progress |
Logical. Whether to show a progress bar for parallel extraction. |
api_key |
Character. Optional API key override. |
endpoint |
Character. Optional endpoint override. |
... |
Additional parameters passed to |
A tibble with one row per input text. Metadata columns are prefixed
with ., followed by extracted schema fields when flatten = TRUE.
Structured outputs: https://learn.microsoft.com/azure/foundry/openai/how-to/structured-outputs
## Not run:
# Requires a configured Azure endpoint, credentials, and AZURE_FOUNDRY_MODEL
# naming a deployment that supports structured outputs.
schema <- list(
type = "object",
properties = list(
sentiment = list(type = "string", enum = c("positive", "negative", "neutral")),
entities = list(type = "array", items = list(type = "string"))
),
required = c("sentiment", "entities"),
additionalProperties = FALSE
)
foundry_extract(
c("I love using R with Azure.", "The workflow was slow and confusing."),
schema = schema
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.