Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ _✨ Access all LLM through the standard OpenAI API format, easy to deploy & use
+ [x] [Baidu Wenxin Yiyuan Series Models](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)
+ [x] [Alibaba Tongyi Qianwen Series Models](https://help.aliyun.com/document_detail/2400395.html)
+ [x] [Zhipu ChatGLM Series Models](https://bigmodel.cn)
+ [x] [SiftQ MiniMax-H3 V2 video generation](./docs/siftq.md)
2. Supports access to multiple channels through **load balancing**.
3. Supports **stream mode** that enables typewriter-like effect through stream transmission.
4. Supports **multi-machine deployment**. [See here](#multi-machine-deployment) for more details.
Expand Down
1 change: 1 addition & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ _✨ 標準的な OpenAI API フォーマットを通じてすべての LLM に
+ [x] [Baidu Wenxin Yiyuan シリーズモデル](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)
+ [x] [Alibaba Tongyi Qianwen シリーズモデル](https://help.aliyun.com/document_detail/2400395.html)
+ [x] [Zhipu ChatGLM シリーズモデル](https://bigmodel.cn)
+ [x] [SiftQ MiniMax-H3 V2 動画生成](./docs/siftq.md)
2. **ロードバランシング**による複数チャンネルへのアクセスをサポート。
3. ストリーム伝送によるタイプライター的効果を可能にする**ストリームモード**に対応。
4. **マルチマシンデプロイ**に対応。[詳細はこちら](#multi-machine-deployment)を参照。
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
+ [x] [Moonshot AI](https://platform.moonshot.cn/)
+ [x] [百川大模型](https://platform.baichuan-ai.com)
+ [x] [MINIMAX](https://api.minimax.chat/)
+ [x] [SiftQ MiniMax-H3 V2 视频生成](./docs/siftq.md)
+ [x] [Groq](https://wow.groq.com/)
+ [x] [Ollama](https://github.com/ollama/ollama)
+ [x] [零一万物](https://platform.lingyiwanwu.com/)
Expand Down
51 changes: 51 additions & 0 deletions controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/gin-gonic/gin"

commonclient "github.com/songquanpeng/one-api/common/client"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/ctxkey"
"github.com/songquanpeng/one-api/common/helper"
Expand All @@ -27,6 +28,7 @@ import (
"github.com/songquanpeng/one-api/monitor"
"github.com/songquanpeng/one-api/relay"
"github.com/songquanpeng/one-api/relay/adaptor/openai"
"github.com/songquanpeng/one-api/relay/adaptor/siftq"
"github.com/songquanpeng/one-api/relay/channeltype"
"github.com/songquanpeng/one-api/relay/controller"
"github.com/songquanpeng/one-api/relay/meta"
Expand Down Expand Up @@ -66,6 +68,9 @@ func parseTestResponse(resp string) (*openai.TextResponse, string, error) {
}

func testChannel(ctx context.Context, channel *model.Channel, request *relaymodel.GeneralOpenAIRequest) (responseMessage string, err error, openaiErr *relaymodel.Error) {
if channel.Type == channeltype.SiftQ {
return testSiftQChannel(ctx, channel)
}
startTime := time.Now()
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
Expand Down Expand Up @@ -166,6 +171,52 @@ func testChannel(ctx context.Context, channel *model.Channel, request *relaymode
return responseMessage, nil, nil
}

func testSiftQChannel(ctx context.Context, channel *model.Channel) (string, error, *relaymodel.Error) {
target, err := siftq.BuildURL(channel.GetBaseURL(), siftq.QueryVideoPath)
if err != nil {
return "", err, nil
}
parsed, err := url.Parse(target)
if err != nil {
return "", err, nil
}
query := parsed.Query()
query.Set("page_num", "1")
query.Set("page_size", "1")
query.Set("filter.model", siftq.ModelName)
parsed.RawQuery = query.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, parsed.String(), nil)
if err != nil {
return "", err, nil
}
req.Header.Set("Authorization", "Bearer "+channel.Key)
req.Header.Set("Accept", "application/json")
resp, err := commonclient.HTTPClient.Do(req)
if err != nil {
return "", err, nil
}
defer resp.Body.Close()
body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
return "", err, nil
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
var envelope siftq.ErrorEnvelope
_ = json.Unmarshal(body, &envelope)
message := envelope.Error.Message
if message == "" {
message = fmt.Sprintf("SiftQ returned HTTP %d", resp.StatusCode)
}
providerError := &relaymodel.Error{Message: message, Type: envelope.Error.Type, Code: envelope.Error.HTTPCode}
return "", errors.New(message), providerError
}
var list siftq.ListResponse
if err := json.Unmarshal(body, &list); err != nil {
return "", errors.New("SiftQ returned a malformed task list"), nil
}
return "SiftQ API reachable", nil, nil
}

func TestChannel(c *gin.Context) {
ctx := c.Request.Context()
id, err := strconv.Atoi(c.Param("id"))
Expand Down
Loading