From cc1bb7775a567bc65c91a7e98ee332e0239bcba5 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Mar 2023 11:30:25 +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/api/ai.go | 2 +- kernel/model/ai.go | 10 ++++++++++ kernel/util/openai.go | 2 -- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/api/ai.go b/kernel/api/ai.go index 1def61b5b..2aa5b1005 100644 --- a/kernel/api/ai.go +++ b/kernel/api/ai.go @@ -17,11 +17,11 @@ package api import ( - "github.com/siyuan-note/siyuan/kernel/model" "net/http" "github.com/88250/gulu" "github.com/gin-gonic/gin" + "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/util" ) diff --git a/kernel/model/ai.go b/kernel/model/ai.go index 7f73840cf..d82a7ab77 100644 --- a/kernel/model/ai.go +++ b/kernel/model/ai.go @@ -24,6 +24,11 @@ import ( ) func ChatGPTContinueWriteBlocks(ids []string) (ret string) { + if "" == util.OpenAIAPIKey { + util.PushMsg(Conf.Language(193), 5000) + return + } + sqlBlocks := sql.GetBlocks(ids) buf := bytes.Buffer{} @@ -37,5 +42,10 @@ func ChatGPTContinueWriteBlocks(ids []string) (ret string) { return } func ChatGPT(msg string) (ret string) { + if "" == util.OpenAIAPIKey { + util.PushMsg(Conf.Language(193), 5000) + return + } + return util.ChatGPT(msg) } diff --git a/kernel/util/openai.go b/kernel/util/openai.go index 083063a68..db71654c4 100644 --- a/kernel/util/openai.go +++ b/kernel/util/openai.go @@ -19,7 +19,6 @@ package util import ( "bytes" "context" - "github.com/siyuan-note/siyuan/kernel/model" "net/http" "net/url" "os" @@ -48,7 +47,6 @@ func ChatGPT(msg string) (ret string) { func ChatGPTContinueWrite(msg string, contextMsgs []string) (ret string, retContextMsgs []string) { if "" == OpenAIAPIKey { - PushMsg(model.Conf.Language(193), 5000) return }