What I've done that has helped redirect bad behavior A) ignore it, B) redirect it, or C) give them a place to go and calm down.
Keep toys on hand near you. Any biting needs to be redirected to a toy. You could also get automatic toys that allows the cat to play solo and pick the cat up and redirect them to this.
It's also totally okay to give the cat a time out by putting them in another room or even their crate to give them space to calm down, but also save your poor ankles and fingers from being bitten repeatedly.
My cat used to randomly lunge at me - misdirected play - so every time I did it I'd grab him quietly and put him in his carrier or the other room behind a closed door. In about 3 weeks he had stopped lunging at me.
Some solo play toys:
https://www.amazon.com/Kalimdor-Interactive-Retractable-%EF%BC%8CHanging-Exercise/dp/B09JFJQZ1T/
https://www.amazon.com/ORSDA-Interactive-Electronic-Automatic-Attachments/dp/B08TW4ZXCC/
https://www.amazon.com/Rechargeable-Automatically-Obstacles-Realistic-Electro-Sensing/dp/B09QH2BLFM/
You could also look into cat specific slow feeders and lick mats.