Chainlit / chainlit

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

"Stop Task" when accessing the URL at which I deployed #91

Closed sebderhy closed 1 year ago

sebderhy commented 1 year ago

Sometimes (not always though), when I access the URL at which I deployed the Chainlit app, there seems to be a task running, which prevents me to start the chat (see below) image

Thankfully, I can still start the chat by clicking "Stop Task" and then start chatting (see below) image

willydouhard commented 1 year ago

are you using the langchain_factory decorator or on_chat_start? If so they are considered a "task" and the user has to wait for them to finish before typing.

sebderhy commented 1 year ago

I'm using on_chat_start. Here's my code more precisely:

def create_output_path(user=None):
    this_uuid = str(uuid.uuid4())
    ts = round(time.time())
    dt_object = datetime.fromtimestamp(ts)
    date = str(dt_object).replace(" ","_").replace(":","-")
    path_out = Path(f"./logs/{date}--{user}--{this_uuid}") if user else Path(f"./logs/{date}--{this_uuid}")
    path_out.mkdir(exist_ok=True, parents=True)
    return path_out

@cl.on_chat_start
def init_session():
    user_session.set('chat_history', [])
    print("chat_history: ", user_session.get('chat_history'))
    user_session.set('path_out', create_output_path())
    print("path_out: ", user_session.get('path_out'))
willydouhard commented 1 year ago

This should not happen, which version of chainlit did you deploy?

sebderhy commented 1 year ago

0.4.0

sebderhy commented 1 year ago

I just tried upgrading to the new version, and it didn't help

willydouhard commented 1 year ago

I am going to investigate

sebderhy commented 1 year ago

Hi, any news regarding this? I was hoping to release several chatbots powered by Chainlit on Monday morning, but currently, this bug is blocking me (I've tried to share my chatbots to a few people, and they didn't understand why there was this "Stop task" and how they could start the chat). Any chance it will be fixed by then?

Btw, for what it's worth, the problem disappears when I remove the init_session function, and use the chatbot without session data (but it's not ideal, because then it means I'm completely unable to track anything in the chatbots I release).

sebderhy commented 1 year ago

Issue solved by @willydouhard ! Turns out the issue was in my NGINX conf, it didn't have any specific configuration for WebSocket connections. I just added those lines and it worked

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";