21 lines
560 B
Go
21 lines
560 B
Go
|
|
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")
|
|||
|
|
}
|
|||
|
|
}
|