File size: 456 Bytes
5832f57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from typing import List
from langchain.schema import BaseOutputParser

class CustomStringOutputParser(BaseOutputParser[List[str]]):
    """Parse the output of an LLM call to a list."""

    @property
    def _type(self) -> str:
        return "str"

    def parse(self, text: str) -> str:
        """Parse the output of an LLM call."""
        text = text.split("texter:")[0]
        text = text.rstrip("\n")
        text = text.strip()
        return text