Skip to content

Commit ac8123a

Browse files
authored
fix: error occurs if change model without initing, the model can't be sel… (#108)
When change model without initing, error occurs: ```shell Uncaught TypeError: Cannot read properties of undefined (reading 'getElementsByClassName') at LLMChatInstance.resetChat (llm_chat.js:693:35) at LLMChatInstance.reboot (llm_chat.js:502:10) at HTMLSelectElement.onChange (llm_chat.js:785:25) ``` <img width="1360" alt="截屏2023-05-22 23 04 58" src="https://github.com/mlc-ai/web-llm/assets/53991079/08ccac43-8517-491a-a99a-35e05198eeb6"> so the model can't be set correctly. check uichat element if occurs can fix it.
1 parent 2d088ea commit ac8123a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

web/llm_chat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ class LLMChatInstance {
687687

688688
resetChat() {
689689
if (this.requestInProgress) return;
690+
if (!this.uiChat) return;
690691
const clearTags = ["left", "right"];
691692
for (const tag of clearTags) {
692693
const matches = this.uiChat.getElementsByClassName(`msg ${tag}-msg`);

0 commit comments

Comments
 (0)