An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Restrict Gemini Interactions selection by provider https://github.com/siyuan-note/siyuan/issues/20560
Danielb49de0751433
diff --git a/app/src/config/tabs/ai/aiProviderUi.ts b/app/src/config/tabs/ai/aiProviderUi.tsindex 6317d33e74..0770da2a9a 100644--- a/app/src/config/tabs/ai/aiProviderUi.ts+++ b/app/src/config/tabs/ai/aiProviderUi.ts@@ -439,7 +439,7 @@ const openProviderDetail = (root: HTMLElement, providerId?: string, preset?: IPr</label><label class="fn__flex b3-label config-item" data-type="openAIApiType">${genConfigItemMainHtml(window.siyuan.languages.apiType,- '<span class="fn__none" data-type="responsesCompatibility"></span>')}+ '<span class="fn__none" data-type="protocolCompatibility"></span>')}<span class="fn__space"></span><select class="b3-select fn__flex-center fn__size200" data-provider-field="protocol"><option value="openai"${draft.protocol === "openai" ? " selected" : ""}>Chat Completions</option>@@ -521,13 +521,22 @@ const openProviderDetail = (root: HTMLElement, providerId?: string, preset?: IPrlet chatGPTAccountReady = false;let draggingModelIndex: number | undefined;let dropModelTarget: {index: number; after: boolean} | undefined;- const updateResponsesCompatibility = () => {- const compatibility = view.querySelector<HTMLElement>("[data-type='responsesCompatibility']");+ const updateProtocolCompatibility = () => {+ const preset = findPreset(draft);+ const geminiAvailable = !preset || preset.id === "gemini" || preset.category === "custom";+ const geminiOption = view.querySelector<HTMLOptionElement>("[data-provider-field='protocol'] option[value='gemini-interactions']");+ // 已有选择保留显示并提示不兼容,避免打开配置时悄悄修改协议。+ geminiOption.hidden = !geminiAvailable && draft.protocol !== "gemini-interactions";+ geminiOption.disabled = !geminiAvailable;+ const compatibility = view.querySelector<HTMLElement>("[data-type='protocolCompatibility']");if (!compatibility) {return;}- const support = getResponsesSupport(draft.baseURL);- compatibility.classList.toggle("fn__none", draft.protocol !== "openai-responses" || support === "supported");+ const support = draft.protocol === "gemini-interactions"+ ? (geminiAvailable ? "supported" : "unsupported")+ : getResponsesSupport(draft.baseURL);+ compatibility.classList.toggle("fn__none",+ !["openai-responses", "gemini-interactions"].includes(draft.protocol) || support === "supported");compatibility.classList.toggle("ft__error", support === "unsupported");compatibility.textContent = support === "unsupported"? window.siyuan.languages.incompatible@@ -556,7 +565,7 @@ const openProviderDetail = (root: HTMLElement, providerId?: string, preset?: IPrfetchModelsButton.disabled = disabled;};updateModelActionButtons();- updateResponsesCompatibility();+ updateProtocolCompatibility();renderDraftModels(modelsContainer, draft.models, availableModels);const clearModelDropTarget = () => {@@ -814,7 +823,7 @@ const openProviderDetail = (root: HTMLElement, providerId?: string, preset?: IPr}if (providerField === "baseURL") {updateModelActionButtons();- updateResponsesCompatibility();+ updateProtocolCompatibility();}return;}@@ -854,7 +863,7 @@ const openProviderDetail = (root: HTMLElement, providerId?: string, preset?: IPrdraft.baseURL = getProviderProtocolBaseURL(draft.baseURL, draft.protocol);view.querySelector<HTMLInputElement>("[data-provider-field='baseURL']").value = draft.baseURL;updateModelActionButtons();- updateResponsesCompatibility();+ updateProtocolCompatibility();return;}if (target.dataset.modelField !== "enabled") {