Skip to content

Commit 3c50ad7

Browse files
committed
cleanup
1 parent fa6bbdf commit 3c50ad7

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

guardrails/async_guard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ async def _stream_server_call(
574574
validated_output=validated_output,
575575
validation_passed=(validation_output.validation_passed is True),
576576
)
577+
# TODO re-enable this once we have a way to get history from a multi-node server
577578
# if validation_output:
578579
# guard_history = self._api_client.get_history(
579580
# self.name, validation_output.call_id

guardrails/classes/llm/llm_response.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ def to_interface(self) -> ILLMResponse:
4747
stream_output = [str(so) for so in copy_2]
4848

4949
async_stream_output = None
50-
if self.async_stream_output:
50+
# dont do this again if already aiter-able were updating ourselves here so in memory
51+
# this can cause issues
52+
if self.async_stream_output and not hasattr(
53+
self.async_stream_output, "__aiter__"
54+
):
5155
# tee doesn't work with async iterators
5256
# This may be destructive
5357
async_stream_output = []

guardrails/guard.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ def _single_server_call(self, *, payload: Dict[str, Any]) -> ValidationOutcome[O
12151215
error="The response from the server was empty!",
12161216
)
12171217

1218+
# TODO renable this when we have history support in multi-node server environments
12181219
# guard_history = self._api_client.get_history(
12191220
# self.name, validation_output.call_id
12201221
# )
@@ -1281,14 +1282,15 @@ def _stream_server_call(
12811282
validated_output=validated_output,
12821283
validation_passed=(validation_output.validation_passed is True),
12831284
)
1284-
if validation_output:
1285-
guard_history = self._api_client.get_history(
1286-
self.name, validation_output.call_id
1287-
)
1288-
# TODO renable this. doesnt work in a multiple server environment
1289-
# self.history.extend(
1290-
# [Call.from_interface(call) for call in guard_history]
1291-
# )
1285+
1286+
# TODO reenable this when sever supports multi-node history
1287+
# if validation_output:
1288+
# guard_history = self._api_client.get_history(
1289+
# self.name, validation_output.call_id
1290+
# )
1291+
# self.history.extend(
1292+
# [Call.from_interface(call) for call in guard_history]
1293+
# )
12921294
else:
12931295
raise ValueError("Guard does not have an api client!")
12941296

@@ -1370,7 +1372,7 @@ def to_dict(self) -> Dict[str, Any]:
13701372
description=self.description,
13711373
validators=self.validators,
13721374
output_schema=self.output_schema,
1373-
history=[], # type: ignore
1375+
history=[c.to_interface() for c in self.history], # type: ignore
13741376
)
13751377

13761378
return i_guard.to_dict()

0 commit comments

Comments
 (0)