chore: Refactor error handling in OutputParser for improved readability (#3985)

Refactor: improve readability of error handling in OutputParser
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-10-01 15:38:22 -03:00 committed by GitHub
commit e710b457c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,11 +34,11 @@ class OutputParserComponent(Component):
def build_parser(self) -> OutputParser:
if self.parser_type == "CSV":
return CommaSeparatedListOutputParser()
else:
raise ValueError("Unsupported or missing parser")
msg = "Unsupported or missing parser"
raise ValueError(msg)
def format_instructions(self) -> Message:
if self.parser_type == "CSV":
return Message(text=CommaSeparatedListOutputParser().get_format_instructions())
else:
raise ValueError("Unsupported or missing parser")
msg = "Unsupported or missing parser"
raise ValueError(msg)