mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 20:38:49 +01:00
🎨 支持应用内配置人工智能 https://github.com/siyuan-note/siyuan/issues/7714
This commit is contained in:
parent
a1594fe3ab
commit
4329c70952
2 changed files with 11 additions and 11 deletions
|
|
@ -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;
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue