Skip to content

Commit

Permalink
remove unecessary openai error handling code now we have the base han…
Browse files Browse the repository at this point in the history
…dler
  • Loading branch information
dtam committed Jul 9, 2024
1 parent 914c87c commit eb05c63
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions guardrails_api/blueprints/guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,19 @@ def openai_v1_chat_completions(guard_name: str):
pass

if not stream:
try:
validation_outcome: ValidationOutcome = guard(
# todo make this come from the guard struct?
# currently we dont support .configure
num_reasks=0,
**payload,
)
llm_response = guard.history[-1].iterations[-1].outputs.llm_response_info
result = outcome_to_chat_completion(
validation_outcome=validation_outcome,
llm_response=llm_response,
has_tool_gd_tool_call=has_tool_gd_tool_call,
)
return result
except Exception as e:
raise HttpError(
status=400,
message="BadRequest",
cause=(str(e)),
)
validation_outcome: ValidationOutcome = guard(
# todo make this come from the guard struct?
# currently we dont support .configure
num_reasks=0,
**payload,
)
llm_response = guard.history[-1].iterations[-1].outputs.llm_response_info
result = outcome_to_chat_completion(
validation_outcome=validation_outcome,
llm_response=llm_response,
has_tool_gd_tool_call=has_tool_gd_tool_call,
)
return result

else:
# need to return validated chunks that look identical to openai's
Expand Down

0 comments on commit eb05c63

Please sign in to comment.