format_instructions = output_parser.get_format_instructions()
prompt = PromptTemplate(
    template="List five {subject}.\n{format_instructions}",
    input_variables=["subject"],
    partial_variables={"format_instructions": format_instructions}
)
model = OpenAI(temperature=0)
_input = prompt.format(subject="ice cream flavors")
output = model(_input)
output_parser.parse(output)
['Vanilla',
 'Chocolate',
 'Strawberry',
 'Mint Chocolate Chip',
 'Cookies and Cream']
previous
Example Selectors
next
Prompts
 Contents
  
Output Parsers
PydanticOutputParser
Fixing Output Parsing Mistakes
Fixing Output Parsing Mistakes with the original prompt
Older, less powerful parsers
Structured Output Parser
CommaSeparatedListOutputParser
By Harrison Chase
    
      © Copyright 2023, Harrison Chase.
      
  Last updated on Mar 22, 2023.