Skip to contents

Produces a JSON Schema list representation compatible with Ollama structured output (format) and OpenAI-compatible local endpoints (response_format).

Usage

as_json_schema(schema)

Arguments

schema

An extraction_schema() object.

Value

A named list representing the JSON Schema.

Examples

sc <- extraction_schema(score = schema_field("integer", min = 1L, max = 5L))
as_json_schema(sc)
#> $type
#> [1] "object"
#> 
#> $title
#> [1] "extraction"
#> 
#> $properties
#> $properties$score
#> $properties$score$type
#> [1] "integer"
#> 
#> $properties$score$minimum
#> [1] 1
#> 
#> $properties$score$maximum
#> [1] 5
#> 
#> 
#> 
#> $required
#> $required[[1]]
#> [1] "score"
#> 
#> 
#> $additionalProperties
#> [1] FALSE
#>