I was able to open a new project and play around with the Foundation Model, but when I dropped this class in a production app (with a lot of files) I'm running into Safety Guardrail errors for this very small prompt. Specifically it's "Safety guardrail was triggered after consecutive failures during streaming." Does it have something to do with the size of the app? I don't know what else to try to get it to work?
import FoundationModels import Playgrounds
@available(iOS 26.0, *)
#Playground {
Task {
do {
let session = LanguageModelSession()
let prompt = "Write a short story about a talking cat."
let response = try await session.respond(to: prompt)
print(response)
} catch {
print("Error: \(error)")
}
}
}
For this I get this error: "Error: Resource (Local Sanitizer Asset) unavailable error." I can't figure out what might be the cause.
This seems to be the same error reported in this thread, and building with Xcode 26 beta 2 seems to help. Would you mind to give it a try and share your result here? Thanks.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.