Chainlit / chainlit

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

Run tasklist with local db met an error #227

Closed chenjuneking closed 1 year ago

chenjuneking commented 1 year ago

I had tried to run tasklist e2e test case with local db opened:

cd src && poetry run chainlit run ../cypress/e2e/tasklist/main.py -h -c --db local

Then met an error:

a bytes-like object is required, not 'str'

Here's the compleed logs:

$ poetry run chainlit run ../cypress/e2e/tasklist/main.py -h -c --db local
2023-07-25 21:14:23 - Loaded .env file
2023-07-25 21:14:23 - Running in CI mode
2023-07-25 21:14:24 - Your app is available at http://localhost:8000
2023-07-25 21:14:24 - HTTP Request: GET http://localhost:62814/status "HTTP/1.1 200 OK"
2023-07-25 21:15:08 - HTTP Request: POST http://localhost:62814/ "HTTP/1.1 200 OK"
2023-07-25 21:15:08 - a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "D:\projects\deepexi\chainlit\src\chainlit\utils.py", line 36, in wrapper
    return await user_function(**params_values)
  File "D:\projects\deepexi\chainlit\src\../cypress/e2e/tasklist/main.py", line 32, in main
    await task_list.send()
  File "D:\projects\deepexi\chainlit\src\chainlit\element.py", line 115, in send
    element = await self.persist(self.emitter.db_client)
  File "D:\projects\deepexi\chainlit\src\chainlit\element.py", line 86, in persist
    self.url = await client.upload_element(content=self.content, mime=mime)
  File "D:\projects\deepexi\chainlit\src\chainlit\client\local.py", line 284, in upload_element
    await out.write(content)
  File "D:\projects\chainlit\.venv\lib\site-packages\aiofiles\threadpool\utils.py", line 45, in method
    return (yield from self._loop.run_in_executor(self._executor, cb))
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\asyncio\futures.py", line 285, in __await__
    yield self  # This tells Task to wait for completion.
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 304, in __wakeup
    future.result()
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\asyncio\futures.py", line 201, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
TypeError: a bytes-like object is required, not 'str'
2023-07-25 21:15:08 - HTTP Request: POST http://localhost:62814/ "HTTP/1.1 200 OK"

My src/.env file:

LOCAL_DB_PATH=file:../../../.chainlit/chat.db
willydouhard commented 1 year ago

Yes it looks like there is a bug with tasklist + persistence @tpatel

chenjuneking commented 1 year ago

287