Closed CalebCourier closed 1 week ago
Great point @CalebCourier , we can add this in the next iteration of streaming alongwith reask and async support.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
Returning a union from the
__call__
method is the best solution we have with the current implementation, but this is still problematic. Besides unhelpful intellisense, users using pyright or mypy for typing will have to cast their result and know what to cast it too. Because the return type of__call__
is currently dependent on the value of thestream
kwarg, not just its type, it is not possible to properly overload the method signatures to account for it.I think the better option would be for streaming to only be available through its own guard method i.e.
guard.stream
. This way there's no question what the return type would be. This would also put it more in line with our existing pattern sinceguard.parse
is also a distinct method._Originally posted by @CalebCourier in https://github.com/guardrails-ai/guardrails/pull/497#discussion_r1424188374_