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
+14 -4
View File
@@ -151,15 +151,25 @@ func ValidateModelLanguage(providerName, modelID, langCode string) error {
// truncate supported languages list for error message
supported := model.SupportedLanguages
if len(supported) > 10 {
supported = append(supported[:10], "...")
suffix := ""
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'. Supported: %s",
modelID,
"model %s does not support language '%s'.%s Supported: %s%s",
model.Name,
langCode,
docsHint,
strings.Join(supported, ", "),
suffix,
)
}