Skip to content

Commit 2864b0a

Browse files
authored
feat: aiproxy ali opensource models (#5288)
* feat: ali * fix: cache and ali skip test ocr model * fix: lint * fix: skip not support test model
1 parent 418688a commit 2864b0a

File tree

4 files changed

+486
-26
lines changed

4 files changed

+486
-26
lines changed

service/aiproxy/controller/channel-test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package controller
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"math/rand/v2"
@@ -138,6 +139,13 @@ type testResult struct {
138139

139140
func processTestResult(channel *model.Channel, modelName string, returnSuccess bool, successResponseBody bool) *testResult {
140141
ct, err := testSingleModel(channel, modelName)
142+
143+
e := &utils.UnsupportedModelTypeError{}
144+
if errors.As(err, &e) {
145+
log.Errorf("model %s not supported test: %s", modelName, err.Error())
146+
return nil
147+
}
148+
141149
result := &testResult{
142150
Success: err == nil,
143151
}

service/aiproxy/model/cache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (t *Token) ToTokenCache() *TokenCache {
6969
return &TokenCache{
7070
ID: t.ID,
7171
Group: t.GroupID,
72+
Key: t.Key,
7273
Name: t.Name.String(),
7374
Models: t.Models,
7475
Subnet: t.Subnet,

service/aiproxy/relay/adaptor/ali/adaptor.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package ali
22

33
import (
4+
"bytes"
45
"errors"
56
"io"
67
"net/http"
8+
"strings"
79

810
"github.com/gin-gonic/gin"
911
"github.com/labring/sealos/service/aiproxy/model"
@@ -75,6 +77,14 @@ func (a *Adaptor) DoRequest(meta *meta.Meta, _ *gin.Context, req *http.Request)
7577
return TTSDoRequest(meta, req)
7678
case relaymode.AudioTranscription:
7779
return STTDoRequest(meta, req)
80+
case relaymode.ChatCompletions:
81+
if meta.IsChannelTest && strings.Contains(meta.ActualModelName, "-ocr") {
82+
return &http.Response{
83+
StatusCode: http.StatusOK,
84+
Body: io.NopCloser(bytes.NewReader(nil)),
85+
}, nil
86+
}
87+
fallthrough
7888
default:
7989
return utils.DoRequest(req)
8090
}
@@ -87,6 +97,9 @@ func (a *Adaptor) DoResponse(meta *meta.Meta, c *gin.Context, resp *http.Respons
8797
case relaymode.ImagesGenerations:
8898
usage, err = ImageHandler(meta, c, resp)
8999
case relaymode.ChatCompletions:
100+
if meta.IsChannelTest && strings.Contains(meta.ActualModelName, "-ocr") {
101+
return nil, nil
102+
}
90103
usage, err = openai.DoResponse(meta, c, resp)
91104
case relaymode.Rerank:
92105
usage, err = RerankHandler(meta, c, resp)

0 commit comments

Comments
 (0)