fix dashscope max tokens and hunyuan top_p param

This commit is contained in:
Zhang Minghan 2023-11-23 22:39:19 +08:00
parent 5cfd8a7118
commit 7fe63c1f7d
4 changed files with 8 additions and 7 deletions

View File

@ -136,7 +136,7 @@ func createChatRequest(props *ChatProps, hook globals.Hook) error {
return dashscope.NewChatInstanceFromConfig().CreateStreamChatRequest(&dashscope.ChatProps{
Model: props.Model,
Message: props.Message,
Token: utils.Multi(props.Infinity || props.Plan, nil, utils.ToPtr(2500)),
Token: utils.Multi(props.Infinity || props.Plan, 2048, props.Token),
Temperature: props.Temperature,
TopP: props.TopP,
TopK: props.TopK,

View File

@ -9,7 +9,7 @@ import (
type ChatProps struct {
Model string
Token *int
Token int
Temperature *float32
TopP *float32
TopK *int
@ -26,6 +26,9 @@ func (c *ChatInstance) GetHeader() map[string]string {
}
func (c *ChatInstance) GetChatBody(props *ChatProps) ChatRequest {
if props.Token <= 0 || props.Token > 1500 {
props.Token = 1500
}
return ChatRequest{
Model: strings.TrimSuffix(props.Model, "-net"),
Input: ChatInput{
@ -77,7 +80,6 @@ func (c *ChatInstance) CreateStreamChatRequest(props *ChatProps, callback global
return nil
}
fmt.Println(slice)
globals.Debug(fmt.Sprintf("dashscope error: cannot unmarshal data %s", slice))
return nil

View File

@ -17,7 +17,7 @@ type ChatInput struct {
type ChatParam struct {
IncrementalOutput bool `json:"incremental_output"`
EnableSearch *bool `json:"enable_search,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
MaxTokens int `json:"max_tokens"`
Temperature *float32 `json:"temperature,omitempty"`
TopP *float32 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`

View File

@ -20,7 +20,6 @@ import (
"bufio"
"bytes"
"chat/globals"
"chat/utils"
"context"
"crypto/hmac"
"crypto/sha1"
@ -124,8 +123,8 @@ func NewRequest(mod int, messages []globals.Message, temperature *float32, topP
return ChatRequest{
Timestamp: int(time.Now().Unix()),
Expired: int(time.Now().Unix()) + 24*60*60,
Temperature: float64(utils.GetPtrVal(temperature, 0)),
TopP: float64(utils.GetPtrVal(topP, 0.8)),
Temperature: 0,
TopP: 0.8,
Messages: messages,
QueryID: queryID,
Stream: mod,