chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

Watch option on Windows crashes when reload

Open kimwonj77 opened this issue 2 years ago • 4 comments

> chainlit run .\langchain_lcel.py -w
2024-01-10 00:00:55 - Your app is available at http://localhost:8000
2024-01-10 00:01:01 - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
2024-01-10 00:01:02 - 1 change detected
2024-01-10 00:01:02 - File modified: langchain_lcel.py. Reloading app...
C:\[redacted]\langchain\venv\lib\site-packages\langchain_openai\embeddings\base.py:21: UserWarning: The NumPy module was reloaded (imported a second time). This can in some cases result in small but subtle issues and is discouraged.
  import numpy as np
2024-01-10 00:01:03 - Error reloading module: 'opentelemetry.proto.collector'
[crashed]
> python --version
Python 3.9.12
> chainlit --version
Chainlit, version 0.7.700

I just created with venv, and make sure package versions are same as chainlit's dependency version. Seems like opentelemetry is dependency of uptrace.

import of file was:

from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough, Runnable, RunnableConfig
from langchain_openai import ChatOpenAI

import chainlit as cl

kimwonj77 avatar Jan 10 '24 06:01 kimwonj77

I've got the same issue here, from what I read on other issues it's related to the venv not behaving as expected, I have no more infos.

Someone found a way?

WH-Yoshi avatar Feb 20 '24 13:02 WH-Yoshi

Will look into this

willydouhard avatar Feb 21 '24 09:02 willydouhard

Same issue here in windows. Have had it for several releases. Tried new venv, checked all dependencies, nothing...

In my case, the culprit seems to be related to async modules like playwright and some other async web tool for my chatbot that mess with the async loop. Probably something in how they are initialized, Will investigate, since i need to use a non blocking browser tool.

If venv is correctly setup, package versions are correct and no dependency loops than I would look into async modules other than chainlit. This is problaly a package loading/class instanciation issue so make sure you get your chainlit module to work with just:

@cl.on_chat_start
async def main():
    print("This is the entry point")

zulven avatar Feb 27 '24 15:02 zulven

One of the reason of this issue is one of files (which is located on same folder of runable python file AND NOT IMPORTED NOR USED) is invalid python file. ex) syntax error etc... I don't know why the non-used files are reloaded too and crash the python sliently...

kimwonj77 avatar Mar 06 '24 01:03 kimwonj77