pors / langchain-chat-websockets

LangChain LLM chat with streaming response over websockets
Apache License 2.0
90 stars 9 forks source link

ayncio error #3

Closed janfilips closed 1 year ago

janfilips commented 1 year ago

I get this error -

(.venv) avid-kenning@Jans-MacBook-Air langchain-chat-websockets % uvicorn main:app --reload                 

INFO:     Will watch for changes in these directories: ['/Users/avid-kenning/coding/langchain-chat-websockets']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [51808] using StatReload
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
    target(sockets=sockets)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve
    config.load()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/config.py", line 465, in load
    ws_protocol_class = import_from_string(WS_PROTOCOLS[self.ws])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/uvicorn/protocols/websockets/auto.py", line 6, in <module>
    import websockets  # noqa
    ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websockets/__init__.py", line 3, in <module>
    from .client import *
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websockets/client.py", line 13, in <module>
    from .extensions.permessage_deflate import ClientPerMessageDeflateFactory
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websockets/extensions/permessage_deflate.py", line 13, in <module>
    from ..framing import CTRL_OPCODES, OP_CONT
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websockets/framing.py", line 56, in <module>
    class Frame(FrameData):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websockets/framing.py", line 76, in Frame
    @asyncio.coroutine
     ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'
pors commented 1 year ago

What is the version of your installed websockets package?

pip list | grep websockets

pors commented 1 year ago

It is probably incompatibility between websockets and python 3.11. I only tested this with Python 3.10.9

janfilips commented 1 year ago

I'll play around with this and come back here with my findings

janfilips commented 1 year ago

Python 3.11.4

janfilips commented 1 year ago

It is slightly outdated, I guess these things move quickly, including the langchain, e.g. as far as I know it no longer supports ConversationChain as an example.