1
0
mirror of https://github.com/hwchase17/langchain.git synced 2025-09-23 03:19:38 +00:00
This commit is contained in:
Harrison Chase
2022-11-24 09:46:29 -08:00
parent a408ed3ea3
commit c09fe1dfdf

@@ -26,6 +26,20 @@ def check_valid_template(
except KeyError: except KeyError:
raise ValueError("Invalid prompt schema.") 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): class BasePromptTemplate(ABC):
"""Base prompt should expose the format method, returning a prompt.""" """Base prompt should expose the format method, returning a prompt."""