feat: enable thinking mode on ali thinking model
This commit is contained in:
@@ -275,7 +275,7 @@ func testChannel(channel *model.Channel, testModel string) testResult {
|
|||||||
Quota: quota,
|
Quota: quota,
|
||||||
Content: "模型测试",
|
Content: "模型测试",
|
||||||
UseTimeSeconds: int(consumedTime),
|
UseTimeSeconds: int(consumedTime),
|
||||||
IsStream: false,
|
IsStream: info.IsStream,
|
||||||
Group: info.UsingGroup,
|
Group: info.UsingGroup,
|
||||||
Other: other,
|
Other: other,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ali
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
@@ -11,8 +12,7 @@ import (
|
|||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/relay/constant"
|
"one-api/relay/constant"
|
||||||
"one-api/types"
|
"one-api/types"
|
||||||
|
"strings"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Adaptor struct {
|
type Adaptor struct {
|
||||||
@@ -65,7 +65,13 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
|
|||||||
if request == nil {
|
if request == nil {
|
||||||
return nil, errors.New("request is nil")
|
return nil, errors.New("request is nil")
|
||||||
}
|
}
|
||||||
|
// docs: https://bailian.console.aliyun.com/?tab=api#/api/?type=model&url=2712216
|
||||||
|
// fix: InternalError.Algo.InvalidParameter: The value of the enable_thinking parameter is restricted to True.
|
||||||
|
if strings.Contains(request.Model, "thinking") {
|
||||||
|
request.EnableThinking = true
|
||||||
|
request.Stream = true
|
||||||
|
info.IsStream = true
|
||||||
|
}
|
||||||
// fix: ali parameter.enable_thinking must be set to false for non-streaming calls
|
// fix: ali parameter.enable_thinking must be set to false for non-streaming calls
|
||||||
if !info.IsStream {
|
if !info.IsStream {
|
||||||
request.EnableThinking = false
|
request.EnableThinking = false
|
||||||
|
|||||||
@@ -225,6 +225,9 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
|
|||||||
userId := common.GetContextKeyInt(c, constant.ContextKeyUserId)
|
userId := common.GetContextKeyInt(c, constant.ContextKeyUserId)
|
||||||
tokenUnlimited := common.GetContextKeyBool(c, constant.ContextKeyTokenUnlimited)
|
tokenUnlimited := common.GetContextKeyBool(c, constant.ContextKeyTokenUnlimited)
|
||||||
startTime := common.GetContextKeyTime(c, constant.ContextKeyRequestStartTime)
|
startTime := common.GetContextKeyTime(c, constant.ContextKeyRequestStartTime)
|
||||||
|
if startTime.IsZero() {
|
||||||
|
startTime = time.Now()
|
||||||
|
}
|
||||||
// firstResponseTime = time.Now() - 1 second
|
// firstResponseTime = time.Now() - 1 second
|
||||||
|
|
||||||
apiType, _ := common.ChannelType2APIType(channelType)
|
apiType, _ := common.ChannelType2APIType(channelType)
|
||||||
|
|||||||
Reference in New Issue
Block a user