Thanks for asking, and I’d say right off the bat that recommending someone talk to a therapist in this scenario could be taken offensively. My recommendation is this:
Stop them when you hear it going down the therapy path and say something like, “Hold on. I’m honored that you trust me enough to share that information with me; however, I don’t think I’m qualified, nor do I think it’s the right time for us to discuss that. I’d love to hear what you have to say, but can we stick to lighter subjects? Why don’t you tell me about ______?”
Let me know what you think of that, but it’s one of many. Overall, I’ve found that starting with something kind and anchoring it with something kind tends to make everything in between much easier to swallow.
I wrote a whole piece about setting boundaries here: https://psiloveyou.xyz/how-to-set-boundaries-and-get-people-to-like-you-723c9d91dcc.
Maybe some of that would apply here.