From 9e3532560049374b904fc0c09c0e0e2ae27011d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=81=A5?= Date: Mon, 17 Feb 2025 19:37:30 +0800 Subject: [PATCH 1/5] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8314486..ccb784a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: - PATH: /opt/go-1.21/go/bin/:/opt/node/node/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin - GOROOT: /opt/go-1.21/go + PATH: /opt/go-1.23/go/bin/:/opt/node/node/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin + GOROOT: /opt/go-1.23/go GOPROXY: https://goproxy.cn VERSION: $CI_COMMIT_SHORT_SHA APP: apipark From 903f9a08a2224c6ed1f67ba2842afb67a7211e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=81=A5?= Date: Mon, 17 Feb 2025 20:14:06 +0800 Subject: [PATCH 2/5] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ccb784a8..035b15b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - PATH: /opt/go-1.23/go/bin/:/opt/node/node/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin + PATH: /opt/go-1.23/go/bin/:/opt/node-1.22/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin GOROOT: /opt/go-1.23/go GOPROXY: https://goproxy.cn VERSION: $CI_COMMIT_SHORT_SHA From 937877fa7aaca41882fa06e5bf64e443b2217244 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Thu, 13 Mar 2025 14:47:36 +0800 Subject: [PATCH 3/5] fix bug --- module/ai-balance/iml.go | 3 ++- service/ai-api/model.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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/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, } From 5dd055a43f3923898f584273be450c94bbc068ed Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Thu, 13 Mar 2025 17:51:27 +0800 Subject: [PATCH 4/5] fix bug --- .../model-providers/lm_studio/assets/icon_l_en.svg | 12 +----------- .../model-providers/lm_studio/assets/icon_s_en.svg | 5 +---- .../model-providers/ollama/assets/icon_l_en.svg | 10 +++++++++- .../model-providers/ollama/assets/icon_s_en.svg | 10 +++++++++- module/ai-key/iml.go | 6 +++--- 5 files changed, 23 insertions(+), 20 deletions(-) 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 @@ - - - - - - - - - - - +LM Studio \ 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 @@ - - - - +LM Studio \ 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 @@ -LM Studio \ 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 @@ -LM Studio \ No newline at end of file + + + + + + + + + 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 }) From 33c61f6131339bf5c8a0c26efd825e991676fd68 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Thu, 13 Mar 2025 22:14:58 +0800 Subject: [PATCH 5/5] Fix the issue of local model data synchronization errors --- controller/service/iml.go | 3 ++- module/ai-local/iml.go | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) 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-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 }