improve language-model compatibility error messages with docs URL

This commit is contained in:
leonardotrapani
2026-02-01 13:34:50 +01:00
parent 811ca71c08
commit 170ac22e3c
6 changed files with 70 additions and 12 deletions
+2 -2
View File
@@ -707,7 +707,7 @@ func TestValidateModelLanguageCompatibility(t *testing.T) {
model: "distil-whisper-large-v3-en",
langCode: "es",
wantErr: true,
errContains: "does not support language 'es'",
errContains: "does not support Spanish (es)",
},
{
name: "multilingual model supports spanish",
@@ -722,7 +722,7 @@ func TestValidateModelLanguageCompatibility(t *testing.T) {
model: "base.en",
langCode: "fr",
wantErr: true,
errContains: "does not support language 'fr'",
errContains: "does not support French (fr)",
},
{
name: "whisper-cpp multilingual supports french",
+12 -5
View File
@@ -212,16 +212,23 @@ func ValidateModelLanguageCompatibility(registryProvider, modelID, langCode stri
// truncate supported languages for error message
supported := model.SupportedLanguages
suffix := ""
if len(supported) > 10 {
supported = supported[:10]
if len(supported) > 5 {
supported = supported[:5]
suffix = "..."
}
// build error with docs URL if available
docsHint := ""
if model.DocsURL != "" {
docsHint = fmt.Sprintf(" See %s for full list.", model.DocsURL)
}
return fmt.Errorf(
"model %s does not support language '%s' (%s). Either change model, select auto-detect, or choose a supported language: %s%s",
modelID,
langCode,
"model %s does not support %s (%s).%s Supported: %s%s",
model.Name,
langName,
langCode,
docsHint,
strings.Join(supported, ", "),
suffix,
)