To create a prompt object with a mix of localized strings and Generable objects, you can pass your Generable directly to the Prompt initializer:
Prompt {
String(localized: "Given the following workout routine, suggest one additional exercise to complement it:")
routine
}
Instead of localizing the prompt, you can also prompt the model in English, and instruct it to generate a localized result. You may then find it easier to iterate over the prompt like this over relying on external translators to create a localized prompt for you.
// After checking that `locale` is supported by the model:
let languageName = Locale(identifier: "en").localizedString(forLanguageCode: locale.languageCode)
Prompt {
"Given the following workout routine, suggest one additional exercise to complement it. Respond in \(languageName)."
routine
}
Topic:
Machine Learning & AI
SubTopic:
Foundation Models
Tags: