description: Schema to represent a chat prompt.
Chat Prompt Template
 (1) (1).png)
Chat Prompt Template Node
A Chat Prompt Template allows you to define a sequence of chat messages—such as system, human, and AI messages—using templates with placeholders for variables. These templates can be filled in at runtime with user inputs or contextual data, making it easy to generate consistent and context-aware prompts for language models
Parameters
Inputs
-
System Message (Required)
-
Type: string
-
Description: Initial system message that sets the context or role for the AI
-
Example: "You are a helpful assistant that translates {input_language} to {output_language}."
-
-
Human Message (Required)
-
Type: string
-
Description: Human message prompt added at the end of the message sequence
-
Example: "{text}"
-
-
Format Prompt Values (Optional)
-
Type: JSON
-
Description: Variables specification for use in prompts
-
Example:
{ "input_language": "English", "output_language": "Spanish" } -
-
Messages History (Optional)
-
Type: Tabs
-
Default: messageHistoryCode
-
Description: Additional messages after System Message for few-shot examples
-
Tabs:
-
Add Messages (Code)
-
Type: code
-
Description: Custom message history using JavaScript code
-
-
-
Best Practices
-
System Message Design
-
Clear instructions
-
Specific role definition
-
Consistent context
-
Appropriate constraints
-
-
Message History
-
Relevant examples
-
Progressive complexity
-
Clear structure
-
Safe code execution
-
-
Variable Management
-
Clear naming
-
Type consistency
-
Error handling
-
Default values
-
Input/Output
Input
-
The node takes in the defined parameters (system message, human message, prompt values, and optional message history).
-
If message history code is provided, it is executed in a sandboxed environment.
Output
-
The node outputs a ChatPromptTemplate object that includes:
-
A system message
-
Optional message history (if provided and valid)
-
A human message
-
Usage
This node is used to create structured chat prompts for language models. It’s particularly useful for:
-
Setting up consistent system instructions across multiple interactions.
-
Defining a standard format for human inputs.
-
Incorporating few-shot examples or specific conversation context through the message history feature.
-
Allowing for dynamic prompt creation by using variables in the system and human messages.
The Chat Prompt Template Function is a foundational tool for anyone developing advanced conversational AI workflows, enabling structured, maintainable, and highly customizable prompts for chat models
{% hint style="info" %} This section is a work in progress. We appreciate any help you can provide in completing this section. Please check our Contribution Guide to get started. {% endhint %}