Add supplier differentiation, custom or built-in

This commit is contained in:
Liujian
2025-03-14 18:02:28 +08:00
parent 15f803a511
commit da85269c9f
3 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ func convertInt(value interface{}) int {
func genAIKey(key string, provider string) string {
keys := strings.Split(key, "@")
return strings.TrimSuffix(keys[0], fmt.Sprintf("-%s", provider))
return strings.TrimPrefix(keys[0], fmt.Sprintf("%s-", provider))
}
// HandleMessage 处理从 NSQ 读取的消息
+1
View File
@@ -17,4 +17,5 @@ type Sort struct {
type NewProvider struct {
Name string `json:"name"`
Type string `json:"type"`
}
+8
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"sort"
"strings"
"time"
ai_model "github.com/APIParkLab/APIPark/service/ai-model"
@@ -200,6 +201,13 @@ func (i *imlProviderModule) Delete(ctx context.Context, id string) error {
}
func (i *imlProviderModule) AddProvider(ctx context.Context, input *ai_dto.NewProvider) (*ai_dto.SimpleProvider, error) {
switch input.Type {
case "customize":
_, has := model_runtime.GetProvider(strings.ToLower(input.Name))
if has {
return nil, fmt.Errorf("provider `%s` duplicate", input.Name)
}
}
// uuid = name
if has := i.providerService.CheckUuidDuplicate(ctx, input.Name); has {
return nil, fmt.Errorf("provider `%s` duplicate", input.Name)