feat: allow toggling stream mode of channels

This commit is contained in:
ckt1031
2023-07-24 15:30:08 +08:00
parent bc2f48b1f2
commit a588241515
8 changed files with 154 additions and 29 deletions

View File

@@ -12,7 +12,8 @@ import (
)
type ModelRequest struct {
Model string `json:"model"`
Model string `json:"model"`
Stream bool `json:"stream" default:"true"`
}
func Distribute() func(c *gin.Context) {
@@ -84,7 +85,7 @@ func Distribute() func(c *gin.Context) {
modelRequest.Model = "dall-e"
}
}
channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, modelRequest.Model)
channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, modelRequest.Model, modelRequest.Stream)
if err != nil {
message := fmt.Sprintf("当前分组 %s 下对于模型 %s 无可用渠道", userGroup, modelRequest.Model)
if channel != nil {