Package io.jmix.aitools
Class ResponseLanguageProvider
java.lang.Object
io.jmix.aitools.ResponseLanguageProvider
@NullMarked
@Component("aitls_ResponseLanguageProvider")
public class ResponseLanguageProvider
extends Object
Resolves the human-readable response-language instruction substituted into LLM system prompts
through the
responseLanguage template parameter.
A bare ISO language code (for example "en") is a weak signal that less capable models tend
to ignore. To make the directive robust, this provider emits the language English name, its endonym
(the language written in itself) and the language tag, for example "German / Deutsch (de)"
or "English (en)". The endonym is the strongest cue because the target language is shown in
the target language itself, while the tag keeps the value machine-unambiguous.
Applications may register their own bean with the same name to change the format.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the response-language instruction for the current user's locale.getResponseLanguage(Locale locale) Formats a response-language instruction for the given locale, combining the English language name, the endonym and the language tag.
-
Field Details
-
currentAuthentication
-
-
Constructor Details
-
ResponseLanguageProvider
public ResponseLanguageProvider()
-
-
Method Details
-
getResponseLanguage
Returns the response-language instruction for the current user's locale.- Returns:
- formatted language descriptor for the current user's locale
-
getResponseLanguage
Formats a response-language instruction for the given locale, combining the English language name, the endonym and the language tag.- Parameters:
locale- locale to describe- Returns:
- formatted language descriptor, or the bare language tag when the language name is unknown
-