Skip to content

Commit 1d6fd86

Browse files
committed
Fix issue with warning for hallucination detection.
1 parent cd01fda commit 1d6fd86

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

nemoguardrails/library/hallucination/actions.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636

3737
log = logging.getLogger(__name__)
3838

39-
try:
40-
from langchain_openai import OpenAI
41-
except ImportError:
42-
log.warning(
43-
"The langchain_openai module is not installed. Please install it using pip: pip install langchain_openai"
44-
)
45-
4639
HALLUCINATION_NUM_EXTRA_RESPONSES = 2
4740

4841

@@ -58,6 +51,12 @@ async def check_hallucination(
5851
5952
:return: True if hallucination is detected, False otherwise.
6053
"""
54+
try:
55+
from langchain_openai import OpenAI
56+
except ImportError:
57+
log.warning(
58+
"The langchain_openai module is not installed. Please install it using pip: pip install langchain_openai"
59+
)
6160

6261
bot_response = context.get("bot_message")
6362
last_bot_prompt_string = context.get("_last_bot_prompt")

0 commit comments

Comments
 (0)