if (FALSE) {
# Basic usage without schema
result <- response_as_json(
chat_obj = llm_client,
prompt = "List three colors"
)
# With schema validation
schema <- list(
type = "object",
properties = list(
equation = list(type = "string"),
solution = list(type = "number")
),
required = c("equation", "solution")
)
result <- response_as_json(
chat_obj = llm_client,
prompt = "How can I solve 8x + 7 = -23?",
schema = schema,
schema_strict = TRUE,
max_iterations = 3
)
}
Run the code above in your browser using DataLab