Skip to content

Commit 1e3be8e

Browse files
committed
have stream generate ValidationOutcome
1 parent a28d1fc commit 1e3be8e

File tree

9 files changed

+1669
-1762
lines changed

9 files changed

+1669
-1762
lines changed

docs/how_to_guides/streaming.ipynb

Lines changed: 347 additions & 465 deletions
Large diffs are not rendered by default.

guardrails/guard.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def __call__(
467467
stream: Optional[bool] = False,
468468
*args,
469469
**kwargs,
470-
) -> Union[ValidationOutcome[OT], Iterable[str]]:
470+
) -> Union[ValidationOutcome[OT], Iterable[ValidationOutcome[OT]]]:
471471
...
472472

473473
@overload
@@ -499,7 +499,8 @@ def __call__(
499499
*args,
500500
**kwargs,
501501
) -> Union[
502-
Union[ValidationOutcome[OT], Iterable[str]], Awaitable[ValidationOutcome[OT]]
502+
Union[ValidationOutcome[OT], Iterable[ValidationOutcome[OT]]],
503+
Awaitable[ValidationOutcome[OT]],
503504
]:
504505
"""Call the LLM and validate the output. Pass an async LLM API to
505506
return a coroutine.
@@ -663,7 +664,7 @@ def _call_sync(
663664
call_log: Call,
664665
*args,
665666
**kwargs,
666-
) -> Union[ValidationOutcome[OT], Iterable[str]]:
667+
) -> Union[ValidationOutcome[OT], Iterable[ValidationOutcome[OT]]]:
667668
instructions_obj = instructions or self.instructions
668669
prompt_obj = prompt or self.prompt
669670
msg_history_obj = msg_history or []

0 commit comments

Comments
 (0)