
Node Details
- Name: fewShotPromptTemplate
- Type: FewShotPromptTemplate
- Version: 1.0
- Category: Prompts
Base Classes
- FewShotPromptTemplate
- BasePromptTemplate
Parameters
Inputs
-
Examples (Required)
- Type: string (JSON)
- Description: Array of example objects with key-value pairs
-
Example:
-
Example Prompt (Required)
- Type: PromptTemplate
- Description: Template for formatting individual examples
-
Prefix (Optional)
- Type: string
- Description: Text appearing before the examples
- Example: “Give the antonym of every input”
-
Suffix (Required)
- Type: string
- Description: Text after examples, containing input variable
- Example: “Word: \nAntonym:”
-
Example Separator (Optional)
- Type: string
- Default: “\n\n”
- Description: String used to separate examples
-
Template Format (Optional)
- Type: options
- Options: [“f-string”, “jinja-2”]
- Default: “f-string”
- Description: Format style for template strings
Functionality
-
Example Processing
- JSON parsing
- Example formatting
- Template application
- Separator handling
-
Template Management
- Format selection
- Variable extraction
- Context building
- Structure validation
Use Cases
-
Pattern Teaching
- Response formatting
- Style demonstration
- Behavior guidance
- Context setting
-
Complex Tasks
- Multi-step processes
- Format standardization
- Response structuring
- Pattern recognition
Integration Notes
- Uses @langchain/core/prompts
- Supports multiple example formats
- Handles variable extraction
- Manages template formatting
Best Practices
-
Example Design
- Clear demonstrations
- Consistent formatting
- Diverse examples
- Progressive complexity
-
Template Structure
- Compatible formats
- Clear separators
- Proper variables
- Consistent style
-
Performance Optimization
- Efficient examples
- Minimal redundancy
- Clear instructions
- Optimal spacing