These S7 classes are provided for use by package devlopers who are
extending ellmer. In every day use, use type_boolean()
and friends.
Usage
TypeBasic(description = NULL, required = TRUE, type = stop("Required"))
TypeEnum(description = NULL, required = TRUE, values = character(0))
TypeArray(description = NULL, required = TRUE, items = Type())
TypeObject(
description = NULL,
required = TRUE,
properties = list(),
additional_properties = TRUE
)
Arguments
- description
The purpose of the component. This is used by the LLM to determine what values to pass to the tool or what values to extract in the structured data, so the more detail that you can provide here, the better.
- required
Is the component required? If
FALSE
, and the component does not exist in the data, the LLM may hallucinate a value. Only applies when the element is nested inside of atype_object()
.- type
Basic type name. Must be one of
boolean
,integer
,number
, orstring
.- values
Character vector of permitted values.
- items
The type of the array items. Can be created by any of the
type_
function.- properties
Named list of properties stored inside the object. Each element should be an S7
Type
object.`- additional_properties
Can the object have arbitrary additional properties that are not explicitly listed? Only supported by Claude.
Examples
TypeBasic(type = "boolean")
#> <ellmer::TypeBasic>
#> @ description: NULL
#> @ required : logi TRUE
#> @ type : chr "boolean"
TypeArray(items = TypeBasic(type = "boolean"))
#> <ellmer::TypeArray>
#> @ description: NULL
#> @ required : logi TRUE
#> @ items : <ellmer::TypeBasic>
#> .. @ description: NULL
#> .. @ required : logi TRUE
#> .. @ type : chr "boolean"