Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 块级加入 `人工智能` https://github.com/siyuan-note/siyuan/issues/7566

Liang Dingcc1bb7775a56
diff --git a/kernel/api/ai.go b/kernel/api/ai.go
index 1def61b5b3..2aa5b10055 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 7f73840cf1..d82a7ab772 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 083063a68d..db71654c4d 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
}