Skip to content

Commit 7ab5570

Browse files
not using the instruction adherence model with react
1 parent 4cd39f2 commit 7ab5570

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

aimon/extensions/react.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def create_payload(self, context, user_query, user_instructions, generated_text)
3232
}
3333

3434
aimon_payload['publish'] = self.react_configuration.publish
35-
aimon_payload['config'] = { 'hallucination': {'detector_name': 'default'},
36-
'instruction_adherence': {'detector_name': 'default'},}
35+
aimon_payload['config'] = { 'hallucination': {'detector_name': 'default'},}
36+
# 'instruction_adherence': {'detector_name': 'default'},}
3737

3838
if self.react_configuration.publish:
3939
aimon_payload['application_name'] = self.react_configuration.application_name
@@ -84,16 +84,19 @@ def react(self, user_query, user_instructions,):
8484

8585
for _ in range(self.react_configuration.max_attempts):
8686

87-
failed_instructions = []
88-
## Loop to check for failed instructions
89-
for x in detect_response.instruction_adherence['results']:
90-
if x['adherence'] == False:
91-
failed_instructions.append(x['instruction'])
87+
# failed_instructions = []
88+
# ## Loop to check for failed instructions
89+
# for x in detect_response.instruction_adherence['results']:
90+
# if x['adherence'] == False:
91+
# failed_instructions.append(x['instruction'])
9292

9393
## Check whether the hallucination score is greater than the required threshold OR if any of the supplied instructions are not complied with
94-
if self.react_configuration.hallucination_threshold > 0 and \
95-
(hallucination_score > self.react_configuration.hallucination_threshold or len(failed_instructions)>0):
94+
# if self.react_configuration.hallucination_threshold > 0 and \
95+
# (hallucination_score > self.react_configuration.hallucination_threshold or len(failed_instructions)>0):
9696

97+
if self.react_configuration.hallucination_threshold > 0 and \
98+
hallucination_score > self.react_configuration.hallucination_threshold:
99+
97100
llm_response = self.llm_app(user_query, user_instructions, reprompted_flag=True, hallucination_score=hallucination_score)
98101

99102
context = self.context_extractor(user_query, user_instructions, llm_response)

0 commit comments

Comments
 (0)