mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-04 10:13:53 +08:00
Add supplier differentiation, custom or built-in
This commit is contained in:
@@ -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 读取的消息
|
||||
|
||||
@@ -17,4 +17,5 @@ type Sort struct {
|
||||
|
||||
type NewProvider struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user