You try catach the error, like:
catch LanguageModelSession.GenerationError.guardrailViolation {...}
catch LanguageModelSession.GenerationError.exceededContextWindowSize { ... }
catch { answer = error.localizedDescription }
If I am not wrong, this is theguardrail violation (prompt too sensitive). Change the prompt.
It seems that Foundation Models framework in beta 3 got issues. As time goes along, more and more questions (that previously work in beta 3) got guardrailViolation errors. Now even "tell me a joke" got a guardrailViolation error!
I found that I can change to:
func call(arguments: Arguments) async throws -> GeneratedContent {
var temp:Int
switch arguments.city {
case .singapore: temp = Int.random(in: 30..<40)
case .china: temp = Int.random(in: 10..<30)
}
return GeneratedContent(temp)
}
But not sure if this is correct.
You try catach the error, like:
catch LanguageModelSession.GenerationError.guardrailViolation {...}
catch LanguageModelSession.GenerationError.exceededContextWindowSize { ... }
catch { answer = error.localizedDescription }
If I am not wrong, this is theguardrail violation (prompt too sensitive). Change the prompt.
It seems that Foundation Models framework in beta 3 got issues. As time goes along, more and more questions (that previously work in beta 3) got guardrailViolation errors. Now even "tell me a joke" got a guardrailViolation error!
I found that I can change to:
func call(arguments: Arguments) async throws -> GeneratedContent {
var temp:Int
switch arguments.city {
case .singapore: temp = Int.random(in: 30..<40)
case .china: temp = Int.random(in: 10..<30)
}
return GeneratedContent(temp)
}
But not sure if this is correct.