Skip to content

Commit f04f546

Browse files
authored
Merge pull request NVIDIA-NeMo#681
Fix/issue 183 non openai hallucination check
2 parents f0e97b0 + 3896ba0 commit f04f546

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

nemoguardrails/library/hallucination/actions.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
@action()
4343
async def self_check_hallucination(
44+
llm: BaseLLM,
4445
llm_task_manager: LLMTaskManager,
4546
context: Optional[dict] = None,
46-
llm: Optional[BaseLLM] = None,
4747
use_llm_checking: bool = True,
4848
config: Optional[RailsConfig] = None,
4949
):
@@ -68,10 +68,16 @@ async def self_check_hallucination(
6868

6969
if "openai" not in str(type(llm)).lower():
7070
log.warning(
71-
f"Hallucination rail can only be used with OpenAI LLM engines."
72-
f"Current LLM engine is {type(llm).__name__}."
71+
f"Hallucination rail is optimized for OpenAI LLM engines. "
72+
f"Current LLM engine is {type(llm).__name__}, which may not support all features."
7373
)
74-
return False
74+
75+
if "n" not in llm.__fields__:
76+
log.warning(
77+
f"LLM engine {type(llm).__name__} does not support the 'n' parameter for generating multiple completion choices. "
78+
f"Please use an OpenAI LLM engine or a model that supports the 'n' parameter for optimal performance."
79+
)
80+
return False
7581

7682
# Use the "generate" call from langchain to get all completions in the same response.
7783
last_bot_prompt = PromptTemplate(template="{text}", input_variables=["text"])

0 commit comments

Comments
 (0)