Skip to main content

System Prompts

The systemPrompt field in the schema definition plays a crucial role in guiding the generation process by setting the tone and context for the AI. This field specifies the system prompt to be used, ensuring that the generated content aligns with the desired output. If no system prompt is inputted, the in-house curated system prompts will be used instead.

Key Points

  • Choice of System Prompt: The systemPrompt field allows you to define a specific system prompt for each property within a definition. This helps in customizing the AI's behavior and response style for different parts of the data structure.

  • Child Precedence: When a child definition contains a systemPrompt, it takes precedence over the parent definition's systemPrompt. This means the system will use the child's systemPrompt for generating content for that particular property.

Example: Page Definition

Consider the following example schema for a page within a book:

outlineSystem := "You are an author AI assistant. You are not a chatbot. Follow the instructions given and ensure the asked details are created."

pageDefinition := jsonSchema.Definition{
Type: jsonSchema.Object,
Instruction: "Create the details and information for a single page within a book.",
ProcessingOrder: []string{"outline"},
Model: jsonSchema.ClaudeSonnet,
Properties: map[string]jsonSchema.Definition{
"outline": {
Type: jsonSchema.String,
Instruction: "Create detailed overview of what content this page should include. This page outline should be detailed enough to ensure that it will logically lead to the next page, creating a satisfying narrative progression. This outline should be a minimum of 250 words.",
SystemPrompt: &outlineSystem,
},
"finalContent": {
Type: jsonSchema.String,
SystemPrompt: &systemPrompt,
},
},
}

Explanation

  1. Parent System Prompt: If the pageDefinition had a systemPrompt defined at its level, it would apply to all properties within the pageDefinition unless overridden by a child system prompt.

  2. Child System Prompt: The outline property has a specific systemPrompt (outlineSystem). This means when generating content for outline, the system will use the outlineSystem prompt, regardless of any prompt defined at the pageDefinition level.

  3. Final Content: The finalContent property would use the systemPrompt defined at the pageDefinition level if it exists. If systemPrompt is defined for finalContent, it will take precedence.

Benefits of Using systemPrompt

  • Contextual Guidance: Tailors the AI's response to fit the specific context and requirements of each property
  • Precision and Relevance: Ensures that generated content is highly relevant and precise by following the defined prompt closely
  • Flexibility: Allows for varying prompts for different properties, enabling nuanced and context-aware generation

By leveraging the systemPrompt field effectively, developers can fine-tune the AI's behavior and output, ensuring high-quality and contextually appropriate content generation.