From b5457beba624e55038dc5f18cae7561e2ab87e7d Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 21 Mar 2024 16:55:28 -0700 Subject: [PATCH] fix(llm_guard.py): await moderation check --- enterprise/enterprise_hooks/llm_guard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enterprise/enterprise_hooks/llm_guard.py b/enterprise/enterprise_hooks/llm_guard.py index 08ef3e388..41558b640 100644 --- a/enterprise/enterprise_hooks/llm_guard.py +++ b/enterprise/enterprise_hooks/llm_guard.py @@ -73,7 +73,7 @@ class _ENTERPRISE_LLMGuard(CustomLogger): if redacted_text is not None: if ( redacted_text.get("is_valid", None) is not None - and redacted_text["is_valid"] == "True" + and redacted_text["is_valid"] != True ): raise HTTPException( status_code=400, @@ -120,7 +120,7 @@ class _ENTERPRISE_LLMGuard(CustomLogger): formatted_prompt = get_formatted_prompt(data=data, call_type=call_type) # type: ignore self.print_verbose(f"LLM Guard, formatted_prompt: {formatted_prompt}") - return self.moderation_check(text=formatted_prompt) + return await self.moderation_check(text=formatted_prompt) async def async_post_call_streaming_hook( self, user_api_key_dict: UserAPIKeyAuth, response: str