修改千帆大模型系统参数,修改大模型系统提问消息输出

This commit is contained in:
junleea 2025-05-10 15:34:52 +08:00
parent 2e02bd22a1
commit 6918b8215c
4 changed files with 26 additions and 15 deletions

View File

@ -77,6 +77,7 @@ type ConfigStruct struct {
TOKEN_SECRET string `json:"token_secret"`
CID_BASE_DIR string `json:"cid_base_dir"`
FILE_BASE_DIR string `json:"file_base_dir"`
LOG_OUTPUT bool `json:"log_output"`
MONITOR bool `json:"monitor"` // 状态监控及邮件通知
SERVER_SQL_LOG bool `json:"server_sql_log"` // 服务器sql日志
SERVER_PORT string `json:"server_port"` // 服务端口

View File

@ -102,8 +102,10 @@ func DouBaoV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
IncludeUsage: true,
},
}
if proto.Config.LOG_OUTPUT {
messagesStr, _ := json.Marshal(req)
log.Println("doubao req messages:", string(messagesStr))
}
stream, err := doubaoClient.CreateChatCompletionStream(ctx, req)
if err != nil {

View File

@ -30,6 +30,11 @@ func Qianfan(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
log.Println("GetQianfanHistoryMessages error:", err)
return
}
if proto.Config.LOG_OUTPUT {
messagesBytes, _ := json.Marshal(messages)
log.Println("qianfan messages:", string(messagesBytes))
}
answer := ""
tokens := 0
@ -81,13 +86,13 @@ func GetQianfanHistoryMessages(sessionID int, systemPrompt string, messages *[]q
//只取最后的 SparkContextLength 条消息
msgs = msgs[len(msgs)-proto.SparkContextLength-1:]
}
//添加系统消息
if systemPrompt != "" {
var message qianfan.ChatCompletionMessage
message.Role = "system"
message.Content = systemPrompt
*messages = append(*messages, message)
}
//添加系统消息,千帆不支持系统参数
//if systemPrompt != "" {
// var message qianfan.ChatCompletionMessage
// message.Role = "system"
// message.Content = systemPrompt
// *messages = append(*messages, message)
//}
for _, msg := range msgs {
var message qianfan.ChatCompletionMessage
if msg.Type == proto.UserToModelMsgType {

View File

@ -201,12 +201,15 @@ func SparkV2(modelParam proto.ModelParam, imCtx *proto.IMParamContext) {
go func() {
data := genSparkParamsV2(imCtx.UserID, modelParam.APPID, modelParam.Domain, imCtx.SessionID, modelParam.System, float64(modelParam.Temperature))
//将数据转换为json
//dataByte, err3 := json.Marshal(data)
//if err3 != nil {
// fmt.Println("Error parsing JSON:", err)
// return
//}
//log.Println("spark send message:", string(dataByte))
if proto.Config.LOG_OUTPUT {
dataByte, err3 := json.Marshal(data)
if err3 != nil {
fmt.Println("Error parsing JSON:", err)
return
}
log.Println("spark send message:", string(dataByte))
}
err2 := conn.WriteJSON(data)
if err != nil {
fmt.Println("write message error:", err2)