diff --git a/langchain/chains/llm.py b/langchain/chains/llm.py index 46b3cfb7..62cc7a91 100644 --- a/langchain/chains/llm.py +++ b/langchain/chains/llm.py @@ -174,6 +174,16 @@ class LLMChain(Chain, BaseModel): else: return result + async def apredict_and_parse( + self, **kwargs: Any + ) -> Union[str, List[str], Dict[str, str]]: + """Call apredict and then parse the results.""" + result = await self.apredict(**kwargs) + if self.prompt.output_parser is not None: + return self.prompt.output_parser.parse(result) + else: + return result + def apply_and_parse( self, input_list: List[Dict[str, Any]] ) -> Sequence[Union[str, List[str], Dict[str, str]]]: