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
systemPromptfield 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'ssystemPrompt. This means the system will use the child'ssystemPromptfor generating content for that particular property.
Example: Page Definition
Consider the following example schema for a page within a book:
- Go
- Python
- JavaScript
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,
},
},
}
outline_system = "You are an author AI assistant. You are not a chatbot. Follow the instructions given and ensure the asked details are created."
page_definition = Definition(
definition_type="object",
instruction="Create the details and information for a single page within a book.",
processing_order=["outline"],
model="claude-sonnet",
properties={
"outline": Definition(
definition_type="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.",
system_prompt=outline_system
),
"finalContent": Definition(
definition_type="string",
system_prompt=system_prompt
)
}
)
const outlineSystem = "You are an author AI assistant. You are not a chatbot. Follow the instructions given and ensure the asked details are created.";
const pageDefinition = {
type: "object",
instruction: "Create the details and information for a single page within a book.",
processingOrder: ["outline"],
model: "claude-sonnet",
properties: {
outline: {
type: "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: "string",
systemPrompt: systemPrompt
}
}
};
Explanation
-
Parent System Prompt: If the
pageDefinitionhad asystemPromptdefined at its level, it would apply to all properties within thepageDefinitionunless overridden by a child system prompt. -
Child System Prompt: The
outlineproperty has a specificsystemPrompt(outlineSystem). This means when generating content foroutline, the system will use theoutlineSystemprompt, regardless of any prompt defined at thepageDefinitionlevel. -
Final Content: The
finalContentproperty would use thesystemPromptdefined at thepageDefinitionlevel if it exists. IfsystemPromptis defined forfinalContent, 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.