# Sort the prompt_with_history by increasing timestamp if pinecone is enabled
ifconverser_cog.pinecone_service:
prompt_with_history.sort(key=lambdax:x.timestamp)
# Remove the last two entries after sort, this is from the end of the list as prompt(redo), answer, prompt(original), leaving only prompt(original) and further history
ifredo_request:
prompt_with_history=prompt_with_history[:-2]
converser_cog.conversation_threads[
ctx.channel.id
].history=prompt_with_history
# Ensure that the last prompt in this list is the prompt we just sent (new_prompt_item)