There are few main type of OutputParsers, including:Convert text from LLM -> structured information (e.g. JSON)Convert a ChatMessage into just a stringConvert the extra information returned from a call besides the message (like OpenAI function invocation) into a string.For full information on this, see the section on output parsersIn this getting started guide, we will write our own output parser - one that converts a comma separated list into a list.from langchain.schema import BaseOutputParserclass CommaSeparatedListOutputParser(BaseOutputParser):    """Parse the output of an LLM call to a comma-separated list."""    def parse(self, text: str):        """Parse the output of an LLM call."""        return text.strip().split(", ")CommaSeparatedListOutputParser().parse("hi, bye")# >> ['hi', 'bye']PromptTemplate + LLM + OutputParser‚ÄãWe can now combine all these into one chain.
This chain will take input variables, pass those to a prompt template to create a prompt, pass the prompt to a language model, and then pass the output through an (optional) output parser.
This is a convenient way to bundle up a modular piece of logic.
Installation
Installation ->: There are few main type of OutputParsers, including:Convert text from LLM -> structured information (e.g. JSON)Convert a ChatMessage into just a stringConvert the extra information returned from a call besides the message (like OpenAI function invocation) into a string.For full information on this, see the section on output parsersIn this getting started guide, we will write our own output parser - one that converts a comma separated list into a list.from langchain.schema import BaseOutputParserclass CommaSeparatedListOutputParser(BaseOutputParser):    """Parse the output of an LLM call to a comma-separated list."""    def parse(self, text: str):        """Parse the output of an LLM call."""        return text.strip().split(", ")CommaSeparatedListOutputParser().parse("hi, bye")# >> ['hi', 'bye']PromptTemplate + LLM + OutputParser‚ÄãWe can now combine all these into one chain.
This chain will take input variables, pass those to a prompt template to create a prompt, pass the prompt to a language model, and then pass the output through an (optional) output parser.
This is a convenient way to bundle up a modular piece of logic.