Skip to content

Commit 6992b22

Browse files
committed
updates for history, streaming handling and fixes
1 parent 9a2df17 commit 6992b22

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

guardrails/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def stream_validate(
104104
)
105105
if line:
106106
json_output = json.loads(line)
107+
if(json_output.get("error")):
108+
raise Exception(json_output.get("error").get("message"))
107109
yield IValidationOutcome.from_dict(json_output)
108110

109111
def get_history(self, guard_name: str, call_id: str):

guardrails/guard.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,10 @@ def _stream_server_call(
12851285
guard_history = self._api_client.get_history(
12861286
self.name, validation_output.call_id
12871287
)
1288-
self.history.extend(
1289-
[Call.from_interface(call) for call in guard_history]
1290-
)
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+
# )
12911292
else:
12921293
raise ValueError("Guard does not have an api client!")
12931294

guardrails/llm_providers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ def _invoke_llm(
498498
),
499499
)
500500

501+
kwargs.pop("reask_prompt", None)
502+
kwargs.pop("reask_instructions", None)
503+
501504
response = completion(
502505
model=model,
503506
*args,
@@ -1088,6 +1091,9 @@ async def invoke_llm(
10881091
),
10891092
)
10901093

1094+
kwargs.pop("reask_prompt", None)
1095+
kwargs.pop("reask_instructions", None)
1096+
10911097
response = await acompletion(
10921098
*args,
10931099
**kwargs,

0 commit comments

Comments
 (0)