Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
661 stars 245 forks source link

Copilot doesn´t work 'TypeError: window.mountChainlitWidget' #102

Open RicardoRobledo opened 3 months ago

RicardoRobledo commented 3 months ago

I am trying to build a chainlit app with copilot, but I can't get the copilot.


I only installed chainlit and run the file following the tutorial.

Uncaught TypeError: Failed to construct 'URL': Invalid URL at index.js:275:3885 at index.js:4208:91586 index.html:12 Uncaught TypeError: window.mountChainlitWidget is not a function at index.html:12:12


Code:

import chainlit as cl

@cl.on_message
async def on_message(msg: cl.Message):
    if cl.context.session.client_type == "copilot":
        fn = cl.CopilotFunction(name="test", args={"msg": msg.content})
        res = await fn.acall()
        await cl.Message(content=res).send()
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    </script>
<script src="http://localhost:8000/copilot/index.js"></script>
  <script>
    window.mountChainlitWidget({
      chainlitServer: "http://localhost:8000",
    });
  </script>
</body>
</html>

image