mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-10 06:48:04 -05:00
## CHANGES - Add case-insensitive vendor lookup in VendorsManager - Implement model name normalization in GetChatter method - Add FilterByVendor method with case-insensitive matching - Add FindModelNameCaseInsensitive helper for model queries - Update group/item comparison to use case-insensitive checks - Store vendors with lowercase keys internally - Add comprehensive tests for case-insensitive functionality - Fix vendor filtering for model listing command
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/danielmiessler/fabric/internal/core"
|
|
"github.com/danielmiessler/fabric/internal/i18n"
|
|
)
|
|
|
|
type transcriber interface {
|
|
TranscribeFile(ctx context.Context, filePath, model string, split bool) (string, error)
|
|
}
|
|
|
|
func handleTranscription(flags *Flags, registry *core.PluginRegistry) (message string, err error) {
|
|
vendorName := flags.Vendor
|
|
if vendorName == "" {
|
|
vendorName = "OpenAI"
|
|
}
|
|
|
|
vendor := registry.VendorManager.FindByName(vendorName)
|
|
if vendor == nil {
|
|
return "", fmt.Errorf("%s", fmt.Sprintf(i18n.T("vendor_not_configured"), vendorName))
|
|
}
|
|
tr, ok := vendor.(transcriber)
|
|
if !ok {
|
|
return "", fmt.Errorf("%s", fmt.Sprintf(i18n.T("vendor_no_transcription_support"), vendorName))
|
|
}
|
|
model := flags.TranscribeModel
|
|
if model == "" {
|
|
return "", fmt.Errorf("%s", i18n.T("transcription_model_required"))
|
|
}
|
|
if message, err = tr.TranscribeFile(context.Background(), flags.TranscribeFile, model, flags.SplitMediaFile); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|