List Generation
When generating a list, ensure it is defined with the type "array" and include an items field that defines the structure of each element. The instruction should emphasize creating unique entries to prevent repetition.
Core Concepts
- Type: Must be set to
"array"for list generation - Items: Defines the structure/schema for each element in the array
- Instruction: Should emphasize uniqueness to avoid duplicates
- Nested Lists: Fully supported, with automatic deduplication between lists
For complete API request examples and detailed structure, see the Array Examples in the API Reference section.
Examples
The following examples demonstrate how to define arrays/lists with proper structure across different programming languages:
- JSON
- Go
- Python
- JavaScript
{
"type": "object",
"instruction": "Represents the relationship between parent locations and characters within the story.",
"properties": {
"parentLocations": {
"type": "array",
"instruction": "Please create a unique list of kingdoms, countries, empires, or planets that exist within the story. These 'parent locations' need to be unique and not related to other parent locations found.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"instruction": "The name of the location"
}
}
}
},
"characters": {
"type": "array",
"instruction": "Please create a unique list of characters that appear in the story, each developed to be realistic and consistent.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"instruction": "The character's name"
}
}
}
}
}
}
var ParentLocationCharacterDefinition = jsonSchema.Definition{
Type: jsonSchema.Object,
Instruction: "Represents the relationship between parent locations and characters within the story.",
Properties: map[string]jsonSchema.Definition{
"parentLocations": {
Type: jsonSchema.Array,
Instruction: "Please create a unique list of kingdoms, countries, empires, or planets that exist within the story. These 'parent locations' need to be unique and not related to other parent locations found.",
Items: &ParentLocationDefinition,
},
"characters": {
Type: jsonSchema.Array,
Instruction: "Please create a unique list of characters that appear in the story, each developed to be realistic and consistent. Includes details such as background, personality, and role in the story.",
Model: jsonSchema.Gpt3,
Items: &CharacterDefinition,
},
},
}
ParentLocationCharacterDefinition = Definition(
definition_type="object",
instruction="Represents the relationship between parent locations and characters within the story.",
properties={
"parentLocations": Definition(
definition_type="array",
instruction="Please create a unique list of kingdoms, countries, empires, or planets that exist within the story. These 'parent locations' need to be unique and not related to other parent locations found.",
items=ParentLocationDefinition
),
"characters": Definition(
definition_type="array",
instruction="Please create a unique list of characters that appear in the story, each developed to be realistic and consistent.",
model="gpt-3.5-turbo",
items=CharacterDefinition
)
}
)
const ParentLocationCharacterDefinition = {
type: "object",
instruction: "Represents the relationship between parent locations and characters within the story.",
properties: {
parentLocations: {
type: "array",
instruction: "Please create a unique list of kingdoms, countries, empires, or planets that exist within the story. These 'parent locations' need to be unique and not related to other parent locations found.",
items: ParentLocationDefinition
},
characters: {
type: "array",
instruction: "Please create a unique list of characters that appear in the story, each developed to be realistic and consistent.",
model: "gpt-3.5-turbo",
items: CharacterDefinition
}
}
};
Importance of Instructions
Clear and specific instructions are crucial to avoid repetition and ensure high-quality output. Prompt engineering within the instructions helps guide the model to produce unique and relevant data, maintaining the integrity and value of the generated lists.
Nested Lists
Nested lists are also supported and will be generated in a manner where there should be no duplication of list items between lists. Unless specified for some ungodly reason. The processing time of a nested list will increase due to the increased complexity of the type.
Additional Resources
For more detailed examples of list generation requests, including:
- Complete API request/response structures
- Advanced array patterns
- Nested list implementations
- Real-world use cases
Visit the API Reference - Array Examples section.