diff --git a/ChuanhuChatbot.py b/ChuanhuChatbot.py index f515fbef..6c2a35d2 100644 --- a/ChuanhuChatbot.py +++ b/ChuanhuChatbot.py @@ -205,6 +205,7 @@ def create_new_model(): type="password", visible=not HIDE_MY_KEY, label="API-Key", + elem_id="api-key" ) if multi_api_key: usageTxt = gr.Markdown(i18n( diff --git a/web_assets/javascript/ChuanhuChat.js b/web_assets/javascript/ChuanhuChat.js index 93979a0c..a35e3d37 100644 --- a/web_assets/javascript/ChuanhuChat.js +++ b/web_assets/javascript/ChuanhuChat.js @@ -109,6 +109,7 @@ function initialize() { setPopupBoxPosition(); setSlider(); setCheckboxes(); + setAutocomplete(); checkModel(); settingBox.classList.add('hideBox'); @@ -336,6 +337,12 @@ function setChatbotScroll() { chatbotWrap.scrollTo(0,scrollHeight) } +function setAutocomplete() { + // 避免API Key被当成密码导致的模型下拉框被当成用户名而引发的浏览器自动填充行为 + const apiKeyInput = gradioApp().querySelector("#api-key input"); + apiKeyInput.setAttribute("autocomplete", "new-password"); +} + function clearChatbot(a, b) { clearHistoryHtml(); // clearMessageRows();