Skip to content

Commit

Permalink
buxfix: set autocomplete attribute to api-key input (#1024)
Browse files Browse the repository at this point in the history
* buxfix: set autocomplete attribute to api-key input

* 调整变量名

---------

Co-authored-by: Keldos <[email protected]>
  • Loading branch information
stingshen and Keldos-Li authored Jan 6, 2024
1 parent bfec72c commit 5c5d615
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChuanhuChatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions web_assets/javascript/ChuanhuChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function initialize() {
setPopupBoxPosition();
setSlider();
setCheckboxes();
setAutocomplete();
checkModel();

settingBox.classList.add('hideBox');
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5c5d615

Please sign in to comment.