Skip to content

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

:sparkles: 桌面端接入 OpenAI Chat API https://github.com/siyuan-note/siyuan/issues/7560

Liang Ding9a67ec3c097a
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 701a6d4215..31c117396b 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1100,6 +1100,7 @@
"189": "Cloud sync directory is still locked by other devices, please try again later",
"190": "A problem was found while validating the index, which has been automatically fixed",
"191": "[%d/%d] Created historical data index",
- "192": "Rebuilding historical data index, please wait..."
+ "192": "Rebuilding historical data index, please wait...",
+ "193": "Please refer to the [Artificial Intelligence] chapter of the User Guide for configuration"
}
}
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 571a534b3d..fcbe99967c 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1100,6 +1100,7 @@
"189": "El directorio de sincronización en la nube todavía está bloqueado por otros dispositivos, inténtalo de nuevo más tarde",
"190": "Se encontro un problema al validar el indice, el cual se soluciono automaticamente",
"191": "[%d/%d] Índice de datos históricos creado",
- "192": "Reconstruyendo el índice de datos históricos, espere..."
+ "192": "Reconstruyendo el índice de datos históricos, espere...",
+ "193": "Consulte el capítulo [Inteligencia artificial] de la guía del usuario para la configuración"
}
}
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 0cba2e2816..5296617c90 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1100,6 +1100,7 @@
"189": "Le répertoire de synchronisation cloud est toujours verrouillé par d'autres appareils, veuillez réessayer plus tard",
"190": "Un problème a été trouvé lors de la validation de l'index, qui a été automatiquement corrigé",
"191": "[%d/%d] Création d'un index de données historiques",
- "192": "Reconstruction de l'index des données historiques, veuillez patienter..."
+ "192": "Reconstruction de l'index des données historiques, veuillez patienter...",
+ "193": "Veuillez vous référer au chapitre [Intelligence Artificielle] du guide de l'utilisateur pour la configuration"
}
}
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index e660922eaa..7d7eb260f7 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1100,6 +1100,7 @@
"189": "雲端同步目錄還在被其他設備鎖定,請稍後再試",
"190": "校驗索引時發現一個問題,已經自動修復",
"191": "[%d/%d] 已經建立條歷史數據索引",
- "192": "正在重建歷史數據索引,請稍等..."
+ "192": "正在重建歷史數據索引,請稍等...",
+ "193": "請先參考用戶指南 [人工智能] 章節進行配置"
}
}
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index bbe03ae356..3f131c84c2 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1100,6 +1100,7 @@
"189": "云端同步目录还在被其他设备锁定,请稍后再试",
"190": "校验索引时发现一个问题,已经自动修复",
"191": "[%d/%d] 已经建立条历史数据索引",
- "192": "正在重建历史数据索引,请稍等..."
+ "192": "正在重建历史数据索引,请稍等...",
+ "193": "请先参考用户指南 [人工智能] 章节进行配置"
}
}
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 3dd032092b..3303c65912 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -569,7 +569,11 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
}, (response) => {
dialog.destroy();
focusByRange(protyle.toolbar.range);
- insertHTML(`${inputElement.value}\n\n${response.data}`, protyle, true);
+ let respContent = "";
+ if (response.data && "" !== response.data) {
+ respContent = "\n\n" + response.data;
+ }
+ insertHTML(`${inputElement.value}${respContent}`, protyle, true);
});
});
return;
diff --git a/kernel/api/ai.go b/kernel/api/ai.go
index 7e4a592ec8..0182b79160 100644
--- a/kernel/api/ai.go
+++ b/kernel/api/ai.go
@@ -17,6 +17,7 @@
package api
import (
+ "github.com/siyuan-note/siyuan/kernel/model"
"net/http"
"github.com/88250/gulu"
@@ -34,5 +35,10 @@ func chatGPT(c *gin.Context) {
}
msg := arg["msg"].(string)
+ if "" == util.OpenAIAPIKey {
+ util.PushMsg(model.Conf.Language(193), 5000)
+ return
+ }
+
ret.Data = util.ChatGPT(msg)
}