# Answer normally unless the trigger sequence is used "searching_for_answers"
if'searching for answers'inassistant_response['content'].lower():
question_extract=openai.Completion.create(model=COMPLETIONS_MODEL,prompt=f"Extract the user's latest question and the year for that question from this conversation: {self.conversation_history}. Extract it as a sentence stating the Question and Year")
question_extract=openai.Completion.create(
model=COMPLETIONS_MODEL,
prompt=f'''
Extracttheuser's latest question and the year for that question from this
# We insert an extra system prompt here to give fresh context to the Chatbot on how to use the Redis results
# In this instance we add it to the conversation history, but in production it may be better to hide
self.conversation_history.insert(-1,{"role":'system',"content":f"Answer the user's question using this content: {search_result}. If you cannot answer the question, say 'Sorry, I don't know the answer to this one'"})
self.conversation_history.insert(
-1,{
"role":'system',
"content":f'''
Answertheuser's question using this content: {search_result}.
Ifyoucannotanswerthequestion,say'Sorry, I don'tknowtheanswertothisone'