Object Generation
When generating objects, the properties field specifies the fields to be generated. This concept is consistent across all SDKs and when using the REST API directly.
Core Concepts
- Properties Field: This field always defines the fields to be generated for an object
- Type Field: To generate an object, the type must be set to
"object" - Nested Objects: The system supports nested objects seamlessly
- ProcessingOrder Field: Use this when fields have dependencies on other fields. Without it, the system relies on the stochastic nature of language models, which might lead to less predictable content
Examples
The following examples show how to define an object with nested properties across different programming languages:
- JSON
- Go
- Python
- JavaScript
{
"type": "object",
"instruction": "Represents the fundamental laws and systems governing the world.",
"properties": {
"lawsOfNature": {
"type": "string",
"instruction": "A description of the natural laws that govern the physical universe, such as gravity, thermodynamics, and other scientific principles."
},
"magic": {
"type": "object",
"instruction": "A detailed description of the magical systems and rules within the world, including how magic is accessed, its limitations, and its effects.",
"properties": {
"source": {
"type": "string",
"instruction": "What is the origin of magical power in this world?"
},
"limits": {
"type": "string",
"instruction": "What are the constraints or costs associated with using magic?"
}
}
}
}
}
var MechanicsDefinition = jsonSchema.Definition{
Type: jsonSchema.Object,
Instruction: "Represents the fundamental laws and systems governing the world.",
Properties: map[string]jsonSchema.Definition{
"lawsOfNature": {
Type: jsonSchema.String,
Instruction: "A description of the natural laws that govern the physical universe, such as gravity, thermodynamics, and other scientific principles.",
},
"magic": {
Type: jsonSchema.Object,
Instruction: "A detailed description of the magical systems and rules within the world, including how magic is accessed, its limitations, and its effects.",
Properties: MagicDefinition.Properties,
},
},
}
MechanicsDefinition = Definition(
definition_type="object",
instruction="Represents the fundamental laws and systems governing the world.",
properties={
"lawsOfNature": Definition(
definition_type="string",
instruction="A description of the natural laws that govern the physical universe, such as gravity, thermodynamics, and other scientific principles."
),
"magic": Definition(
definition_type="object",
instruction="A detailed description of the magical systems and rules within the world, including how magic is accessed, its limitations, and its effects.",
properties=MagicDefinition.properties
)
}
)
const MechanicsDefinition = {
type: "object",
instruction: "Represents the fundamental laws and systems governing the world.",
properties: {
lawsOfNature: {
type: "string",
instruction: "A description of the natural laws that govern the physical universe, such as gravity, thermodynamics, and other scientific principles."
},
magic: {
type: "object",
instruction: "A detailed description of the magical systems and rules within the world, including how magic is accessed, its limitations, and its effects.",
properties: MagicDefinition.properties
}
}
};
Type Options
The options that are currently available are listed below. Additional types will be coming soon, and please note that the Map type is currently in Beta.
Object
Number
Integer
String
Array
Null
Boolean
Map
Vector