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/7714

Liang Ding695d6848c792
diff --git a/app/src/config/AI.ts b/app/src/config/ai.ts
similarity index 88%
rename from app/src/config/AI.ts
rename to app/src/config/ai.ts
index dfae277152..31b5879375 100644
--- a/app/src/config/AI.ts
+++ b/app/src/config/ai.ts
@@ -1,6 +1,6 @@
import {fetchPost} from "../util/fetch";
-export const AI = {
+export const ai = {
element: undefined as Element,
genHTML: () => {
return `<div class="fn__flex-column" style="height: 100%">
@@ -54,15 +54,15 @@ export const AI = {
</div>`;
},
bindEvent: () => {
- AI.element.querySelectorAll("input").forEach((item) => {
+ ai.element.querySelectorAll("input").forEach((item) => {
item.addEventListener("change", () => {
fetchPost("/api/setting/setAI", {
openAI: {
- apiBaseURL: (AI.element.querySelector("#apiBaseURL") as HTMLInputElement).value,
- apiKey: (AI.element.querySelector("#apiKey") as HTMLInputElement).value,
- apiMaxTokens: parseInt((AI.element.querySelector("#apiMaxTokens") as HTMLInputElement).value),
- apiProxy: (AI.element.querySelector("#apiProxy") as HTMLInputElement).value,
- apiTimeout: parseInt((AI.element.querySelector("#apiTimeout") as HTMLInputElement).value),
+ apiBaseURL: (ai.element.querySelector("#apiBaseURL") as HTMLInputElement).value,
+ apiKey: (ai.element.querySelector("#apiKey") as HTMLInputElement).value,
+ apiMaxTokens: parseInt((ai.element.querySelector("#apiMaxTokens") as HTMLInputElement).value),
+ apiProxy: (ai.element.querySelector("#apiProxy") as HTMLInputElement).value,
+ apiTimeout: parseInt((ai.element.querySelector("#apiTimeout") as HTMLInputElement).value),
}
}, response => {
window.siyuan.config.ai = response.data;
diff --git a/app/src/config/index.ts b/app/src/config/index.ts
index d16a52600d..1360f0a28f 100644
--- a/app/src/config/index.ts
+++ b/app/src/config/index.ts
@@ -11,7 +11,7 @@ import {keymap} from "./keymap";
import {bazaar} from "./bazaar";
import {query} from "./query";
import {Dialog} from "../dialog";
-import {AI} from "./AI";
+import {ai} from "./ai";
import {card} from "./card";
export const openSetting = () => {
@@ -82,9 +82,9 @@ export const openSetting = () => {
fileTree.bindEvent();
break;
case "AI":
- containerElement.innerHTML = AI.genHTML();
- AI.element = dialog.element.querySelector('.config__tab-container[data-name="AI"]');
- AI.bindEvent();
+ containerElement.innerHTML = ai.genHTML();
+ ai.element = dialog.element.querySelector('.config__tab-container[data-name="AI"]');
+ ai.bindEvent();
break;
case "card":
containerElement.innerHTML = card.genHTML();