如何控制 LanguageModelSession 回答所使用的语言?

Asked on 06/13/2025

1 search

To control the language used by a LanguageModelSession, you can utilize the API to check whether the model supports a certain language. This is useful for ensuring that the user's current language is supported and for showing a disclaimer if it is not. Additionally, you can catch an unsupported language or locale error to handle cases where the language might not be supported. This approach allows you to provide a custom message in your UI if needed.

For more detailed information, you can refer to the session Deep dive into the Foundation Models framework (06:30).