Skip to content

Commit

Permalink
fix async support
Browse files Browse the repository at this point in the history
  • Loading branch information
dtam committed Oct 21, 2024
1 parent 3a7ef66 commit 98e4a10
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion guardrails_api/api/guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ async def openai_v1_chat_completions(guard_name: str, request: Request):
)

if not stream:
validation_outcome: ValidationOutcome = await guard(num_reasks=0, **payload)
execution = guard(num_reasks=0, **payload)
if inspect.iscoroutine(execution):
validation_outcome: ValidationOutcome = await execution
else:
validation_outcome: ValidationOutcome = execution

llm_response = guard.history.last.iterations.last.outputs.llm_response_info
result = outcome_to_chat_completion(
validation_outcome=validation_outcome,
Expand Down

0 comments on commit 98e4a10

Please sign in to comment.