langchain: Make RetryWithErrorOutputParser.from_llm() create a correct retry chain (#25053)

Description: RetryWithErrorOutputParser.from_llm() creates a retry chain
that returns a Generation instance, when it should actually just return
a string.
This class was forgotten when fixing the issue in PR #24687
This commit is contained in:
Alexey Lapin 2024-08-05 17:21:27 +03:00 committed by GitHub
parent c5cb52a3c6
commit 335894893b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -214,7 +214,7 @@ class RetryWithErrorOutputParser(BaseOutputParser[T]):
Returns:
A RetryWithErrorOutputParser.
"""
chain = prompt | llm
chain = prompt | llm | StrOutputParser()
return cls(parser=parser, retry_chain=chain, max_retries=max_retries)
def parse_with_prompt(self, completion: str, prompt_value: PromptValue) -> T: