mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-12 23:15:05 -05:00
- Replace hardcoded strings with i18n.T translations - Add en and es JSON locale files - Implement custom translated help system - Enable language detection from CLI args - Add locale download capability - Localize error messages throughout codebase - Support TTS and notification translations
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package ai
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"github.com/danielmiessler/fabric/internal/i18n"
|
|
"github.com/danielmiessler/fabric/internal/util"
|
|
)
|
|
|
|
func NewVendorsModels() *VendorsModels {
|
|
return &VendorsModels{GroupsItemsSelectorString: util.NewGroupsItemsSelectorString(i18n.T("available_models_header"))}
|
|
}
|
|
|
|
type VendorsModels struct {
|
|
*util.GroupsItemsSelectorString
|
|
}
|
|
|
|
// PrintWithVendor prints models including their vendor on each line.
|
|
// When shellCompleteList is true, output is suitable for shell completion.
|
|
// Default vendor and model are highlighted with an asterisk.
|
|
func (o *VendorsModels) PrintWithVendor(shellCompleteList bool, defaultVendor, defaultModel string) {
|
|
if !shellCompleteList {
|
|
fmt.Printf("%s:\n\n", o.SelectionLabel)
|
|
}
|
|
|
|
var currentItemIndex int
|
|
|
|
sortedGroups := make([]*util.GroupItems[string], len(o.GroupsItems))
|
|
copy(sortedGroups, o.GroupsItems)
|
|
sort.SliceStable(sortedGroups, func(i, j int) bool {
|
|
return strings.ToLower(sortedGroups[i].Group) < strings.ToLower(sortedGroups[j].Group)
|
|
})
|
|
|
|
for _, groupItems := range sortedGroups {
|
|
items := make([]string, len(groupItems.Items))
|
|
copy(items, groupItems.Items)
|
|
sort.SliceStable(items, func(i, j int) bool {
|
|
return strings.ToLower(items[i]) < strings.ToLower(items[j])
|
|
})
|
|
for _, item := range items {
|
|
currentItemIndex++
|
|
if shellCompleteList {
|
|
fmt.Printf("%s|%s\n", groupItems.Group, item)
|
|
} else {
|
|
mark := " "
|
|
if strings.EqualFold(groupItems.Group, defaultVendor) && strings.EqualFold(item, defaultModel) {
|
|
mark = " *"
|
|
}
|
|
fmt.Printf("%s\t[%d]\t%s|%s\n", mark, currentItemIndex, groupItems.Group, item)
|
|
}
|
|
}
|
|
}
|
|
}
|