Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.7k stars 869 forks source link

Copilot Javascript Error - Invalid or unexpected token #1183

Open bdavj opened 1 month ago

bdavj commented 1 month ago

Describe the bug Using a very minimal HTML file served up next to the instance, the following error occurs:

index.js:61 Uncaught SyntaxError: Invalid or unexpected token (at index.js:61:4443)

To Reproduce chainlit = "1.1.305"

HTML Source:

<html>
    <head>
        <title>Chainlit Test</title>
    </head>
    <body>
        <h1> Test</h1>
        <script src="https://<server>/copilot/index.js"></script>
        <script>
          window.mountChainlitWidget({
            chainlitServer: "https://<server>/",
          });
        </script>
        <h1>End Test</h1>
    </body>
</html>

Expected behavior Copilot loads

Screenshots N/A. Console output:

Uncaught SyntaxError: Invalid or unexpected token test.html:9 Uncaught TypeError: window.mountChainlitWidget is not a function at test.html:9:18

Desktop (please complete the following information):

bdavj commented 1 month ago

Found the issue myself. Digging into the JS, it appeared to be an issue within lodash, which was documented on the lodash issue tracker.

The <meta charset="UTF-8"> within the html head tag is essential.