Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions guardrails/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,13 +1380,15 @@ def parse(
output, stream=True, verified=verified
)

# Error can be either of (True/False/None/string representing error)
# Error can be either of
# (True/False/None/ValueError/string representing error)
if error:
# If parsing error is a string,
# it is an error from output_schema.parse_fragment()
if isinstance(error, str):
raise ValueError("Unable to parse output: " + error)
# Else if either of (None/True/False), return parsed_output and error
# Else if either of
# (None/True/False/ValueError), return parsed_output and error

action.log(
message_type="info",
Expand Down
4 changes: 3 additions & 1 deletion guardrails/schema/string_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def get_reask_setup(
return self, prompt, instructions

def parse(self, output: str, **kwargs) -> Tuple[Any, Optional[Exception]]:
return output, None
# Return a ValueError if the output is empty, else None
error = ValueError("Empty response received.") if not output else None
return output, error

def validate(
self,
Expand Down