Bird
0
0

How can you combine CommaSeparatedListOutputParser with a custom function to convert all parsed items to uppercase?

hard📝 Application Q9 of 15
LangChain - Output Parsers
How can you combine CommaSeparatedListOutputParser with a custom function to convert all parsed items to uppercase?
AParse the list then map str.upper to each item
BPass a parameter to parse() to uppercase items
COverride parse method to uppercase inside parser
DUse a different parser that returns uppercase
Step-by-Step Solution
Solution:
  1. Step 1: Understand parser output

    The parser returns a list of strings.
  2. Step 2: Apply custom function after parsing

    Use Python's map or list comprehension to convert each item to uppercase after parsing.
  3. Final Answer:

    Parse the list then map str.upper to each item -> Option A
  4. Quick Check:

    Post-process parsed list for uppercase [OK]
Quick Trick: Apply transformations after parsing, not inside parser [OK]
Common Mistakes:
  • Expecting parse() to accept transformation parameters
  • Trying to override parser without subclassing
  • Using a different parser unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes