Skip to content

Commit 8a727fa

Browse files
author
qingjing.cai
committed
fix: add provider checker
1 parent 88ecd0e commit 8a727fa

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

backend/internal/model/repo/model.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ func (r *ModelRepo) GetTokenUsage(ctx context.Context, modelType consts.ModelTyp
184184
OrderBy("date")
185185
}).
186186
Scan(ctx, &dailyUsages)
187-
188187
if err != nil {
189188
return nil, err
190189
}

backend/internal/proxy/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/chaitin/MonkeyCode/backend/internal/middleware"
2020
"github.com/chaitin/MonkeyCode/backend/pkg/logger"
2121
"github.com/chaitin/MonkeyCode/backend/pkg/tee"
22+
"github.com/chaitin/MonkeyCode/backend/pkg/tools"
2223
)
2324

2425
type CtxKey struct{}
@@ -114,7 +115,7 @@ func (l *LLMProxy) rewrite(r *httputil.ProxyRequest) {
114115
}
115116

116117
metadata := make(map[string]string)
117-
if m.Provider == consts.ModelProviderZhiPu {
118+
if tools.CheckProvider(r.In.Context(), m.Provider, m.ModelName) == consts.ModelProviderZhiPu {
118119
body, err := io.ReadAll(r.In.Body)
119120
if err != nil {
120121
l.logger.ErrorContext(r.In.Context(), "read request body failed", slog.String("path", r.In.URL.Path), slog.Any("err", err))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package tools
2+
3+
import (
4+
"context"
5+
"strings"
6+
7+
"github.com/chaitin/MonkeyCode/backend/consts"
8+
)
9+
10+
// CheckProvider 根据 model 的前缀来判断 provider
11+
func CheckProvider(ctx context.Context, provider consts.ModelProvider, modelName string) consts.ModelProvider {
12+
if strings.HasPrefix(modelName, "glm") {
13+
provider = consts.ModelProviderZhiPu
14+
}
15+
return provider
16+
}

0 commit comments

Comments
 (0)