vsakkas / sydney.py

Python Client for Copilot (formerly named Bing Chat), also known as Sydney.
MIT License
239 stars 31 forks source link

VPS ERROR: <aiohttp.connector.TCPConnector object at 0x7f56e0757110> #156

Open DavidAI2024 opened 4 months ago

DavidAI2024 commented 4 months ago

I know that maybe it's not a Sydney-py error but I'm going crazy, I can't understand why if I start the Sydney-py example script locally it works, as soon as I start the VPS (Ovh Cloud) I get this errore. Traceback (most recent call last): File "/home/ubuntu/pp.py", line 24, in <module> asyncio.run(main()) File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/ubuntu/pp.py", line 8, in main async with SydneyClient() as sydney: File "/home/ubuntu/.local/lib/python3.11/site-packages/sydney/sydney.py", line 94, in __aenter__ await self.start_conversation() File "/home/ubuntu/.local/lib/python3.11/site-packages/sydney/sydney.py", line 444, in start_conversation response_dict = await response.json() ^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1166, in json raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://copilot.microsoft.com/turing/conversation/create?bundleVersion=1.1573.2') Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f56e0757090> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f56e0902a50>, 1195.864796355)]'] connector: <aiohttp.connector.TCPConnector object at 0x7f56e0757110>

DavidAI2024 commented 4 months ago

Thanks so much for your help if you can 💕 @vsakkas

DavidAI2024 commented 4 months ago

Maybe you need to open some ports in the VPS? if I try to ping google.it in the VPS everything works with the connection, before I think I had read that you had to close the session manually and I found a code that did this, as soon as I started the VPS I got another NoConnection Copilot error while the connection is there The piece of code I repeat works locally on the PC only on VPS from this error🥲 @vsakkas

Traceback (most recent call last): File "/home/ubuntu/pp.py", line 24, in <module> asyncio.run(main()) File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/ubuntu/pp.py", line 8, in main async with SydneyClient() as sydney: File "/home/ubuntu/.local/lib/python3.11/site-packages/sydney/sydney.py", line 94, in __aenter__ await self.start_conversation() File "/home/ubuntu/.local/lib/python3.11/site-packages/sydney/sydney.py", line 444, in start_conversation response_dict = await response.json() ^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1166, in json raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://copilot.microsoft.com/turing/conversation/create?bundleVersion=1.1573.2') Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f56e0757090> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f56e0902a50>, 1195.864796355)]'] connector: <aiohttp.connector.TCPConnector object at 0x7f56e0757110>

import asyncio

from sydney import SydneyClient

async def main() -> None:
    async with SydneyClient() as sydney:
        while True:
            prompt = input("You: ")

            if prompt == "!reset":
                await sydney.reset_conversation()
                continue
            elif prompt == "!exit":
                break

            print("Sydney: ", end="", flush=True)
            async for response in sydney.ask_stream(prompt):
                print(response, end="", flush=True)
            print("\n")

if __name__ == "__main__":
    asyncio.run(main())