Skip to content

Commit e354ff5

Browse files
added condition and logic to handle the case when the response is still hallucinated after n number of max attemps
1 parent e3beac6 commit e354ff5

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

aimon/extensions/react.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,7 @@ def react( llm_app,
5454

5555
_, _, _, query_result, aimon_response = context_extractor(user_query, user_instructions, llm_response)
5656

57-
return query_result
57+
if hallucination_score > react_configuration.hallucination_threshold:
58+
return f"The generated LLM response, even after {react_configuration.max_attempts} attempts of ReAct is still hallucinated. The response: {query_result}"
5859

59-
60-
61-
62-
## llm_app is a function that has both conservative and creative LLMs to its access
63-
## returns the LLM's response to the user's query
64-
65-
## Template for llm_app function
66-
# def llm_app(user_query, user_instructions, reprompted_flag=False):
67-
# from aimon_llamaindex import get_response
68-
# if reprompted_flag==False:
69-
# return get_response(user_query, retriever, llm_creative)
70-
# else:
71-
# llm_conservative.system_prompt += user_instructions
72-
# return get_response(user_query, retriever, llm_conservative)
60+
return query_result

0 commit comments

Comments
 (0)