convosim-ui / models /custom_parsers.py
ivnban27-ctl's picture
fixed bug on changin source in comparisor
be43fc0
raw
history blame
No virus
495 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.split("helper")[0]
text = text.rstrip("\n")
text = text.strip()
return text