langchain_core.prompts.few_shot.FewShotPromptTemplate¶
class langchain_core.prompts.few_shot.FewShotPromptTemplate[source]¶
Bases: _FewShotPromptTemplateMixin, StringPromptTemplate
Prompt template that contains few shot examples.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param example_prompt: PromptTemplate [Required]¶
PromptTemplate used to format an individual example.
param example_selector: Any = None¶
ExampleSelector to choose the examples to format into the prompt.
Either this or examples should be provided.
param example_separator: str = '\n\n'¶
String separator used to join the prefix, the examples, and suffix.
param examples: Optional[List[dict]] = None¶
Examples to format into the prompt.
Either this or example_selector should be provided.
param input_types: Dict[str, Any] [Optional]¶
A dictionary of the types of the variables the prompt template expects.
If not provided, all variables are assumed to be strings.
param input_variables: List[str] [Required]¶
A list of the names of the variables the prompt template expects.
param output_parser: Optional[BaseOutputParser] = None¶
How to parse the output of calling an LLM on this formatted prompt.
param partial_variables: Mapping[str, Union[str, Callable[[], str]]] [Optional]¶
param prefix: str = ''¶
A prompt template string to put before the examples.
param suffix: str [Required]¶
A prompt template string to put after the examples.
param template_format: Union[Literal['f-string'], Literal['jinja2']] = 'f-string'¶
The format of the prompt template. Options are: ‘f-string’, ‘jinja2’.