Skip to content

Commit

Permalink
Fix issue with warning for hallucination detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
drazvan committed Jul 24, 2024
1 parent cd01fda commit 1d6fd86
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions nemoguardrails/library/hallucination/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@

log = logging.getLogger(__name__)

try:
from langchain_openai import OpenAI
except ImportError:
log.warning(
"The langchain_openai module is not installed. Please install it using pip: pip install langchain_openai"
)

HALLUCINATION_NUM_EXTRA_RESPONSES = 2


Expand All @@ -58,6 +51,12 @@ async def check_hallucination(
:return: True if hallucination is detected, False otherwise.
"""
try:
from langchain_openai import OpenAI
except ImportError:
log.warning(
"The langchain_openai module is not installed. Please install it using pip: pip install langchain_openai"
)

bot_response = context.get("bot_message")
last_bot_prompt_string = context.get("_last_bot_prompt")
Expand Down

0 comments on commit 1d6fd86

Please sign in to comment.