| 709 | } |
| 710 | |
| 711 | function getOrCreateTextBlock() { |
| 712 | const children = Array.from(currentAssistantMsg.children).filter( |
| 713 | (c) => !c.classList.contains("loading-indicator") |
| 714 | ); |
| 715 | let lastChild = children[children.length - 1]; |
| 716 | |
| 717 | if (!lastChild || !lastChild.classList.contains("text-block")) { |
| 718 | lastChild = document.createElement("div"); |
| 719 | lastChild.className = "content text-block markdown-body"; |
| 720 | lastChild.dataset.mdContent = ""; |
| 721 | |
| 722 | const indicator = currentAssistantMsg.querySelector(".loading-indicator"); |
| 723 | if (indicator) { |
| 724 | currentAssistantMsg.insertBefore(lastChild, indicator); |
| 725 | } else { |
| 726 | currentAssistantMsg.appendChild(lastChild); |
| 727 | } |
| 728 | } |
| 729 | return lastChild; |
| 730 | } |
| 731 | |
| 732 | function enableInput() { |
| 733 | const sendBtn = document.getElementById("send-btn"); |