chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

After running the chainlit run app.py getting the error "Could not reach the server"

Open Cenrax opened this issue 2 years ago • 3 comments

Platform : Windows 11

  1. Installed the chainlit from
  • Download the wheel
  • Run pip uninstall chainlit
  • Run pip install PATH_TO_WHEEL
  1. After that getting the error:
2023-06-11 19:29:28 - Module should at least expose one of @langchain_factory, @on_message or @on_chat_start function

Cenrax avatar Jun 11 '23 14:06 Cenrax

yes, a chainlit app should at lease expose one of those. for instance:

import chainlit as cl

@cl.on_message
async def main(message: str):
   await cl.Message(content=message).send()

Is a minimal example

willydouhard avatar Jun 11 '23 17:06 willydouhard

Hey @willydouhard. Yup that works but I have a followup question regarding the following example in https://docs.chainlit.io/examples/qa

This is not working and it is showing the same error,

Module should at least expose one of @langchain_factory, @on_message or @on_chat_start function

Even though the code has @langchain_factory function

Cenrax avatar Jun 11 '23 19:06 Cenrax

Ah I see you are using the wheel from the PR. Then langchain_factory now takes a parameter use_async. So it should be:

@cl.langchain_factory(use_async=False)
def main():
    pass

willydouhard avatar Jun 12 '23 14:06 willydouhard