How to get an AI controlled character to find and choose a path that is not the shortest?

I want my AI to be able to move on paths not the shortest. Is there a way i could call a function to find a path of greater distance if possible? If there isn’t one then just take the shortest path available.

Thanks everyone!!!