From c214a38eb9182f8b03290e498103d121cd2c1db1 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 6 Mar 2023 14:28:16 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=9D=97=E7=BA=A7=E5=8A=A0=E5=85=A5=20?= =?UTF-8?q?`=E4=BA=BA=E5=B7=A5=E6=99=BA=E8=83=BD`=20https://github.com/siy?= =?UTF-8?q?uan-note/siyuan/issues/7566?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/ai.go | 7 ++++--- kernel/util/openai.go | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/model/ai.go b/kernel/model/ai.go index a2f759263..df9b33b02 100644 --- a/kernel/model/ai.go +++ b/kernel/model/ai.go @@ -31,7 +31,7 @@ func ChatGPTWithAction(ids []string, action string) (ret string) { } msg := getBlocksContent(ids) - ret = util.ChatGPTWithAction(msg, action, Conf.Lang) + ret = util.ChatGPTWithAction(msg, action) return } @@ -81,10 +81,11 @@ func getBlocksContent(ids []string) string { } } + luteEngine := util.NewLute() buf := bytes.Buffer{} for _, node := range nodes { - content := treenode.NodeStaticContent(node, nil, true) - buf.WriteString(content) + md := treenode.ExportNodeStdMd(node, luteEngine) + buf.WriteString(md) buf.WriteString("\n\n") } return buf.String() diff --git a/kernel/util/openai.go b/kernel/util/openai.go index 2ee9bddfb..6a13690b6 100644 --- a/kernel/util/openai.go +++ b/kernel/util/openai.go @@ -45,11 +45,8 @@ func ChatGPT(msg string) (ret string) { return } -func ChatGPTWithAction(msg string, action string, lang string) (ret string) { - prompt := "{action} as follows, the result is in {lang}:\n" - prompt = strings.Replace(prompt, "{action}", action, -1) - prompt = strings.Replace(prompt, "{lang}", lang, -1) - msg = prompt + msg +func ChatGPTWithAction(msg string, action string) (ret string) { + msg = action + ":\n\n" + msg ret, _ = ChatGPTContinueWrite(msg, nil) return }