This commit is contained in:
Daniel 2025-03-22 11:16:19 +08:00
parent 95dc762faf
commit 42c0461e3d
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 19 additions and 5 deletions

View File

@ -109,7 +109,9 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
ret = buf.String()
ret = strings.TrimSpace(ret)
retContextMsgs = append(retContextMsgs, msg, ret)
if "" != ret {
retContextMsgs = append(retContextMsgs, msg, ret)
}
return
}

View File

@ -31,15 +31,27 @@ func ChatGPT(msg string, contextMsgs []string, c *openai.Client, model string, m
var reqMsgs []openai.ChatCompletionMessage
for _, ctxMsg := range contextMsgs {
if "" == ctxMsg {
continue
}
reqMsgs = append(reqMsgs, openai.ChatCompletionMessage{
Role: "user",
Content: ctxMsg,
})
}
reqMsgs = append(reqMsgs, openai.ChatCompletionMessage{
Role: "user",
Content: msg,
})
if "" != msg {
reqMsgs = append(reqMsgs, openai.ChatCompletionMessage{
Role: "user",
Content: msg,
})
}
if 1 > len(reqMsgs) {
stop = true
return
}
req := openai.ChatCompletionRequest{
Model: model,