Skip to content

Commit 92e91f9

Browse files
updated result logic with 4 edge cases
1 parent 4e10bf9 commit 92e91f9

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

aimon/extensions/react.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,18 @@ def react(self, user_query, user_instructions,):
128128
else:
129129
break
130130

131-
if hallucination_score > self.react_configuration.hallucination_threshold:
132-
result['response'].append(f"The generated LLM response, even after {self.react_configuration.max_attempts} attempts of AIMon ReAct is still hallucinated. Final LLM response: {generated_text}")
131+
132+
if hallucination_score > self.react_configuration.hallucination_threshold and result['adherence']==False:
133+
result['response'].append(f"Even after {self.react_configuration.max_attempts} attempts of AIMon react, the LLM neither adheres to the user instructions, nor generates a response that is not hallucinated. Final LLM response: {generated_text}")
133134
result['hscore'].append(hallucination_score)
134-
135+
elif hallucination_score > self.react_configuration.hallucination_threshold and result['adherence']==True:
136+
result['response'].append(f"Although the LLM adheres to the user instructions, the generated response, even after {self.react_configuration.max_attempts} attempts of AIMon ReAct is still hallucinated. Final LLM response: {generated_text}")
137+
result['hscore'].append(hallucination_score)
138+
elif hallucination_score <= self.react_configuration.hallucination_threshold and result['adherence']==False:
139+
result['response'].append(f"Although the LLM generates a non-hallucinated response, it fails to adhere to the user instructions, even after {self.react_configuration.max_attempts} attempts of AIMon ReAct. Final LLM response: {generated_text}")
140+
result['hscore'].append(hallucination_score)
141+
else:
142+
result['response'].append(generated_text)
143+
result['hscore'].append(hallucination_score)
144+
135145
return result

0 commit comments

Comments
 (0)