修改千帆大模型系统参数,修改大模型系统提问消息输出
This commit is contained in:
parent
2e02bd22a1
commit
6918b8215c
|
|
@ -77,6 +77,7 @@ type ConfigStruct struct {
|
||||||
TOKEN_SECRET string `json:"token_secret"`
|
TOKEN_SECRET string `json:"token_secret"`
|
||||||
CID_BASE_DIR string `json:"cid_base_dir"`
|
CID_BASE_DIR string `json:"cid_base_dir"`
|
||||||
FILE_BASE_DIR string `json:"file_base_dir"`
|
FILE_BASE_DIR string `json:"file_base_dir"`
|
||||||
|
LOG_OUTPUT bool `json:"log_output"`
|
||||||
MONITOR bool `json:"monitor"` // 状态监控及邮件通知
|
MONITOR bool `json:"monitor"` // 状态监控及邮件通知
|
||||||
SERVER_SQL_LOG bool `json:"server_sql_log"` // 服务器sql日志
|
SERVER_SQL_LOG bool `json:"server_sql_log"` // 服务器sql日志
|
||||||
SERVER_PORT string `json:"server_port"` // 服务端口
|
SERVER_PORT string `json:"server_port"` // 服务端口
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,10 @@ func DouBaoV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
|
||||||
IncludeUsage: true,
|
IncludeUsage: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
messagesStr, _ := json.Marshal(req)
|
if proto.Config.LOG_OUTPUT {
|
||||||
log.Println("doubao req messages:", string(messagesStr))
|
messagesStr, _ := json.Marshal(req)
|
||||||
|
log.Println("doubao req messages:", string(messagesStr))
|
||||||
|
}
|
||||||
|
|
||||||
stream, err := doubaoClient.CreateChatCompletionStream(ctx, req)
|
stream, err := doubaoClient.CreateChatCompletionStream(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,11 @@ func Qianfan(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
|
||||||
log.Println("GetQianfanHistoryMessages error:", err)
|
log.Println("GetQianfanHistoryMessages error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if proto.Config.LOG_OUTPUT {
|
||||||
|
messagesBytes, _ := json.Marshal(messages)
|
||||||
|
log.Println("qianfan messages:", string(messagesBytes))
|
||||||
|
}
|
||||||
|
|
||||||
answer := ""
|
answer := ""
|
||||||
tokens := 0
|
tokens := 0
|
||||||
|
|
||||||
|
|
@ -81,13 +86,13 @@ func GetQianfanHistoryMessages(sessionID int, systemPrompt string, messages *[]q
|
||||||
//只取最后的 SparkContextLength 条消息
|
//只取最后的 SparkContextLength 条消息
|
||||||
msgs = msgs[len(msgs)-proto.SparkContextLength-1:]
|
msgs = msgs[len(msgs)-proto.SparkContextLength-1:]
|
||||||
}
|
}
|
||||||
//添加系统消息
|
//添加系统消息,千帆不支持系统参数
|
||||||
if systemPrompt != "" {
|
//if systemPrompt != "" {
|
||||||
var message qianfan.ChatCompletionMessage
|
// var message qianfan.ChatCompletionMessage
|
||||||
message.Role = "system"
|
// message.Role = "system"
|
||||||
message.Content = systemPrompt
|
// message.Content = systemPrompt
|
||||||
*messages = append(*messages, message)
|
// *messages = append(*messages, message)
|
||||||
}
|
//}
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
var message qianfan.ChatCompletionMessage
|
var message qianfan.ChatCompletionMessage
|
||||||
if msg.Type == proto.UserToModelMsgType {
|
if msg.Type == proto.UserToModelMsgType {
|
||||||
|
|
|
||||||
|
|
@ -201,12 +201,15 @@ func SparkV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
|
||||||
go func() {
|
go func() {
|
||||||
data := genSparkParamsV2(imCtx.UserID, modelParam.APPID, modelParam.Domain, imCtx.SessionID, modelParam.System, float64(modelParam.Temperature))
|
data := genSparkParamsV2(imCtx.UserID, modelParam.APPID, modelParam.Domain, imCtx.SessionID, modelParam.System, float64(modelParam.Temperature))
|
||||||
//将数据转换为json
|
//将数据转换为json
|
||||||
//dataByte, err3 := json.Marshal(data)
|
if proto.Config.LOG_OUTPUT {
|
||||||
//if err3 != nil {
|
dataByte, err3 := json.Marshal(data)
|
||||||
// fmt.Println("Error parsing JSON:", err)
|
if err3 != nil {
|
||||||
// return
|
fmt.Println("Error parsing JSON:", err)
|
||||||
//}
|
return
|
||||||
//log.Println("spark send message:", string(dataByte))
|
}
|
||||||
|
log.Println("spark send message:", string(dataByte))
|
||||||
|
}
|
||||||
|
|
||||||
err2 := conn.WriteJSON(data)
|
err2 := conn.WriteJSON(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("write message error:", err2)
|
fmt.Println("write message error:", err2)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue