From c09fe1dfdf10a940afb46050dc6ab4464ef854b8 Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Thu, 24 Nov 2022 09:46:29 -0800 Subject: [PATCH] stash --- langchain/prompts/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/langchain/prompts/base.py b/langchain/prompts/base.py index 44cdad9ff08..c8d9c0f9bb1 100644 --- a/langchain/prompts/base.py +++ b/langchain/prompts/base.py @@ -26,6 +26,20 @@ def check_valid_template( except KeyError: raise ValueError("Invalid prompt schema.") +class OutputParser(ABC): + """Class to parse the output of an LLM call.""" + + @abstractmethod + def parse(self, text: str) -> Union[str, List[str], Dict[str, str]]: + """Parse the output of an LLM call.""" + + +class DefaultParser(OutputParser): + """Just return the text.""" + + def parse(self, text: str) -> Union[str, List[str], Dict[str, str]]: + """Parse the output of an LLM call.""" + return text class BasePromptTemplate(ABC): """Base prompt should expose the format method, returning a prompt."""