From ba400854b0a19d164c393e1244c6e6897bef2f88 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Mar 2023 11:31:36 +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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/model/ai.go b/kernel/model/ai.go index d82a7ab77..de3f1872a 100644 --- a/kernel/model/ai.go +++ b/kernel/model/ai.go @@ -24,8 +24,7 @@ import ( ) func ChatGPTContinueWriteBlocks(ids []string) (ret string) { - if "" == util.OpenAIAPIKey { - util.PushMsg(Conf.Language(193), 5000) + if !isOpenAIAPIEnabled() { return } @@ -41,11 +40,19 @@ func ChatGPTContinueWriteBlocks(ids []string) (ret string) { ret, _ = util.ChatGPTContinueWrite(msg, nil) return } + func ChatGPT(msg string) (ret string) { - if "" == util.OpenAIAPIKey { - util.PushMsg(Conf.Language(193), 5000) + if !isOpenAIAPIEnabled() { return } return util.ChatGPT(msg) } + +func isOpenAIAPIEnabled() bool { + if "" == util.OpenAIAPIKey { + util.PushMsg(Conf.Language(193), 5000) + return false + } + return true +}