convosim-ui / models /custom_parsers.py
ivnban27-ctl's picture
first commit openai simulators
5832f57
raw
history blame
456 Bytes
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