Prompt
Element
The <prompt></prompt>
element contains the query that describes the high level task.
📚 Components of a Prompt Element
In addition to the high level task description, the prompt also contains the following:
Component | Syntax | Description |
---|---|---|
Variables | ${variable_name} |
These are provided by the user at runtime, and substituted in the prompt. |
Output Schema | ${output_schema} |
This is the schema of the expected output, and is compiled based on the output element. For more information on how the output schema is compiled for the prompt, check out output element compilation. |
Prompt Primitives | ${gr.prompt_primitive_name} |
These are pre-constructed prompts that are useful for common tasks. E.g., some primitives may contain information that helps the LLM understand the output schema better. To see the full list of prompt primitives, check out guardrails/constants.xml . |
<rail version="0.1">
<prompt>
<!-- (1)! -->
Given the following document, answer the following questions. If the answer doesn't exist in the document, enter 'None'.
${document} <!-- (2)! -->
${gr.xml_prefix_prompt} <!-- (3)! -->
${output_schema} <!-- (4)! -->
${gr.json_suffix_prompt} <!-- (5)! -->
</prompt>
</rail>
- The prompt contains high level task information.
- The variable
${document}
is provided by the user at runtime. ${gr.xml_prefix_prompt}
is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the prompt:Given below is XML that describes the information to extract from this document and the tags to extract it into.
${output_schema}
is the output schema and contains information about , which is compiled based on theoutput
element.${gr.json_suffix_prompt}
is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the prompt: