feat: use new ui bubbletea

This commit is contained in:
leonardotrapani
2026-02-01 20:40:17 +01:00
parent 3ae86f7bae
commit 0b0e084155
25 changed files with 2249 additions and 1934 deletions
+30
View File
@@ -0,0 +1,30 @@
package provider
import (
"fmt"
"strings"
"golang.org/x/text/language"
"golang.org/x/text/language/display"
)
// LanguageLabel returns a human-readable label for a language code.
// Example: "es" -> "Spanish (es)", "en-US" -> "English (United States) (en-US)".
func LanguageLabel(code string) string {
if code == "" {
return ""
}
normalized := strings.ReplaceAll(code, "_", "-")
tag, err := language.Parse(normalized)
if err != nil {
return fmt.Sprintf("language '%s'", code)
}
name := display.English.Tags().Name(tag)
if name == "" || strings.EqualFold(name, code) {
return fmt.Sprintf("language '%s'", code)
}
return fmt.Sprintf("%s (%s)", name, code)
}
+7 -2
View File
@@ -163,10 +163,15 @@ func ValidateModelLanguage(providerName, modelID, langCode string) error {
docsHint = fmt.Sprintf(" See %s for full list.", model.DocsURL)
}
langLabel := LanguageLabel(langCode)
if langLabel == "" {
langLabel = fmt.Sprintf("language '%s'", langCode)
}
return fmt.Errorf(
"model %s does not support language '%s'.%s Supported: %s%s",
"model %s does not support %s.%s Supported: %s%s",
model.Name,
langCode,
langLabel,
docsHint,
strings.Join(supported, ", "),
suffix,
+7 -6
View File
@@ -283,9 +283,9 @@ func TestValidateModelLanguage_ErrorFormat(t *testing.T) {
t.Errorf("error should contain docs URL, got: %s", errMsg)
}
// should contain language code
if !strings.Contains(errMsg, "'es'") {
t.Errorf("error should contain language code, got: %s", errMsg)
// should contain language label
if !strings.Contains(errMsg, "Spanish (es)") {
t.Errorf("error should contain language label, got: %s", errMsg)
}
// should contain supported languages (English-only has just 'en')
@@ -387,10 +387,11 @@ func TestElevenLabsProvider(t *testing.T) {
t.Errorf("scribe_v2_realtime AdapterType=%q, want 'elevenlabs-streaming'", scribeV2Realtime.AdapterType)
}
// All models have explicit SupportedLanguages from docs (subset of our 57)
// All models should share the same supported language list
wantLangCount := len(elevenLabsTranscriptionLanguages)
for _, m := range models {
if len(m.SupportedLanguages) != 57 {
t.Errorf("model %q has %d languages, want 57", m.ID, len(m.SupportedLanguages))
if len(m.SupportedLanguages) != wantLangCount {
t.Errorf("model %q has %d languages, want %d", m.ID, len(m.SupportedLanguages), wantLangCount)
}
}
}