Object Strategy
Object Strategy
aisdk::OutputStrategy -> ObjectStrategy
schemaThe schema definition (from z_object, etc.).
schema_nameHuman-readable name for the schema.
new()Initialize the ObjectStrategy.
ObjectStrategy$new(schema, schema_name = "json_schema")schemaA schema object created by z_object, z_array, etc.
schema_nameAn optional name for the schema (default: "json_schema").
get_instruction()Generate the instruction for the LLM to output valid JSON.
ObjectStrategy$get_instruction()A character string with the prompt instruction.
validate()Validate and parse the LLM output as JSON.
ObjectStrategy$validate(text, is_final = FALSE)textThe raw text output from the LLM.
is_finalLogical, TRUE if this is the final output.
The parsed R object (list), or NULL if parsing fails.
clone()The objects of this class are cloneable with this method.
ObjectStrategy$clone(deep = FALSE)deepWhether to make a deep clone.
Strategy for generating structured objects based on a JSON Schema. This strategy instructs the LLM to produce valid JSON matching the schema, and handles parsing and validation of the output.