thread-master/backend/internal/model/ai/usecase/provider_map.go

21 lines
560 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package usecase
import (
"strings"
app "haixun-backend/internal/library/errors"
"haixun-backend/internal/library/errors/code"
"haixun-backend/internal/model/ai/domain/enum"
)
func MapWorkerProvider(provider string) (enum.ProviderID, error) {
switch strings.TrimSpace(provider) {
case string(enum.ProviderOpenCode):
return enum.ProviderOpenCode, nil
case string(enum.ProviderXAI):
return enum.ProviderXAI, nil
default:
return "", app.For(code.AI).InputInvalidFormat("目前僅支援 opencode-go 與 xai請在 AI 設定調整 provider")
}
}