feat: add copy code btn in chat page, fixed bug for code wrap in model of ChatGLM and XunFei

This commit is contained in:
RockYang
2023-11-22 17:00:43 +08:00
parent 911f218f0b
commit 61c6a6e7f3
10 changed files with 129 additions and 60 deletions

View File

@@ -84,6 +84,11 @@ func (h *ChatHandler) sendBaiduMessage(
content = line[5:]
}
// 处理代码换行
if len(content) == 0 {
content = "\n"
}
var resp baiduResp
err := utils.JsonDecode(content, &resp)
if err != nil {

View File

@@ -71,6 +71,10 @@ func (h *ChatHandler) sendChatGLMMessage(
if strings.HasPrefix(line, "data:") {
content = line[5:]
}
// 处理代码换行
if len(content) == 0 {
content = "\n"
}
switch event {
case "add":
if len(contents) == 0 {

View File

@@ -138,6 +138,10 @@ func (h *ChatHandler) sendXunFeiMessage(
}
content = result.Payload.Choices.Text[0].Content
// 处理代码换行
if len(content) == 0 {
content = "\n"
}
contents = append(contents, content)
// 第一个结果
if result.Payload.Choices.Status == 0 {