The .onAppear and Task can be replaced by .task. I did not experience your problem, so might try changing this.
Topic:
Machine Learning & AI
SubTopic:
Foundation Models