diff --git a/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_l_en.svg b/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_l_en.svg
index f1ef8d4b..5f08476c 100644
--- a/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_l_en.svg
+++ b/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_l_en.svg
@@ -1,11 +1 @@
-
+
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_s_en.svg b/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_s_en.svg
index 86f2c419..5f08476c 100644
--- a/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_s_en.svg
+++ b/ai-provider/model-runtime/model-providers/lm_studio/assets/icon_s_en.svg
@@ -1,4 +1 @@
-
+
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/ollama/assets/icon_l_en.svg b/ai-provider/model-runtime/model-providers/ollama/assets/icon_l_en.svg
index 5f08476c..492903f4 100644
--- a/ai-provider/model-runtime/model-providers/ollama/assets/icon_l_en.svg
+++ b/ai-provider/model-runtime/model-providers/ollama/assets/icon_l_en.svg
@@ -1 +1,9 @@
-
\ No newline at end of file
+
diff --git a/ai-provider/model-runtime/model-providers/ollama/assets/icon_s_en.svg b/ai-provider/model-runtime/model-providers/ollama/assets/icon_s_en.svg
index 5f08476c..492903f4 100644
--- a/ai-provider/model-runtime/model-providers/ollama/assets/icon_s_en.svg
+++ b/ai-provider/model-runtime/model-providers/ollama/assets/icon_s_en.svg
@@ -1 +1,9 @@
-
\ No newline at end of file
+
diff --git a/controller/service/iml.go b/controller/service/iml.go
index b391241a..489d66e2 100644
--- a/controller/service/iml.go
+++ b/controller/service/iml.go
@@ -354,7 +354,8 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
if !has {
return nil, fmt.Errorf("model %s not found", pv.DefaultLLM)
}
- modelId = m.ID()
+ //modelId = m.ID()
+ modelId = m.Name()
modelCfg = m.DefaultConfig()
}
diff --git a/module/ai-balance/iml.go b/module/ai-balance/iml.go
index 2d6c0b41..81d0c655 100644
--- a/module/ai-balance/iml.go
+++ b/module/ai-balance/iml.go
@@ -220,7 +220,8 @@ func (i *imlBalanceModule) Delete(ctx context.Context, id string) error {
return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
{
BasicItem: &gateway.BasicItem{
- ID: id,
+ ID: id,
+ Resource: "ai-provider",
},
},
}, false)
diff --git a/module/ai-key/iml.go b/module/ai-key/iml.go
index 21cf216e..618dbb26 100644
--- a/module/ai-key/iml.go
+++ b/module/ai-key/iml.go
@@ -383,12 +383,12 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i
}
releases := []*gateway.DynamicRelease{{
BasicItem: &gateway.BasicItem{
- ID: id,
+ ID: fmt.Sprintf("%s-%s", providerId, id),
Resource: "ai-key",
},
Attr: nil,
}}
- return i.syncGateway(ctx, providerId, releases, false)
+ return i.syncGateway(ctx, cluster.DefaultClusterID, releases, false)
}
if info.Status == ai_key_dto.KeyDisable.Int() || info.Status == ai_key_dto.KeyExceed.Int() {
// 超额 或 停用状态,可启用
@@ -411,7 +411,7 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i
return err
}
releases := []*gateway.DynamicRelease{newKey(info)}
- return i.syncGateway(ctx, providerId, releases, true)
+ return i.syncGateway(ctx, cluster.DefaultClusterID, releases, true)
}
return nil
})
diff --git a/module/ai-local/iml.go b/module/ai-local/iml.go
index a7da6a29..3547c84b 100644
--- a/module/ai-local/iml.go
+++ b/module/ai-local/iml.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
+ "time"
ai_balance "github.com/APIParkLab/APIPark/service/ai-balance"
@@ -60,6 +61,7 @@ func (i *imlLocalModel) SyncLocalModels(ctx context.Context, address string) err
if err != nil {
return err
}
+
return i.syncGateway(ctx, cluster.DefaultClusterID, releases, true)
}
@@ -246,7 +248,7 @@ func (i *imlLocalModel) pullHook(fn ...func() error) func(msg ai_provider_local.
v, _ := i.settingService.Get(ctx, "system.ai_model.ollama_address")
cfg := make(map[string]interface{})
- cfg["provider"] = "ollama"
+ cfg["provider"] = ai_provider_local.ProviderLocal
cfg["model"] = msg.Model
cfg["model_config"] = ai_provider_local.LocalConfig
cfg["priority"] = 0
@@ -448,7 +450,7 @@ func (i *imlLocalModel) Enable(ctx context.Context, model string) error {
}
v, _ := i.settingService.Get(ctx, "system.ai_model.ollama_address")
cfg := make(map[string]interface{})
- cfg["provider"] = "ollama"
+ cfg["provider"] = ai_provider_local.ProviderLocal
cfg["model"] = info.Id
cfg["model_config"] = ai_provider_local.LocalConfig
cfg["priority"] = 0
@@ -615,14 +617,14 @@ func (i *imlLocalModel) getLocalModels(ctx context.Context, v string) ([]*gatewa
return nil, errors.New("ollama_address not set")
}
}
-
+ provider := ai_provider_local.ProviderLocal
releases := make([]*gateway.DynamicRelease, 0, len(list))
for _, l := range list {
if l.State != ai_local_dto.LocalModelStateNormal.Int() {
continue
}
cfg := make(map[string]interface{})
- cfg["provider"] = "ollama"
+ cfg["provider"] = provider
cfg["model"] = l.Id
cfg["model_config"] = ai_provider_local.LocalConfig
cfg["base"] = v
@@ -639,6 +641,25 @@ func (i *imlLocalModel) getLocalModels(ctx context.Context, v string) ([]*gatewa
Attr: cfg,
})
}
+ releases = append(releases, &gateway.DynamicRelease{
+ BasicItem: &gateway.BasicItem{
+ ID: fmt.Sprintf("%s-key", ai_provider_local.ProviderLocal),
+ Description: "auto generate key",
+ Resource: "ai-key",
+ Version: time.Now().Format("20060102150405"),
+ MatchLabels: map[string]string{
+ "module": "ai-key",
+ },
+ },
+ Attr: map[string]interface{}{
+ "expired": 0,
+ "config": fmt.Sprintf("{\"base\":\"%s\"}", v),
+ "provider": provider,
+ "priority": 1,
+ "disabled": true,
+ },
+ })
+
return releases, nil
}
diff --git a/service/ai-api/model.go b/service/ai-api/model.go
index 8364c02f..f2154bfa 100644
--- a/service/ai-api/model.go
+++ b/service/ai-api/model.go
@@ -76,6 +76,7 @@ func FromEntity(e *api.AiAPIInfo) *API {
Updater: e.Updater,
Disable: e.Disable,
UseToken: e.UseToken,
+ Provider: e.Provider,
Type: e.Type,
AdditionalConfig: cfg,
}