sydney.py: Exception: Failed to create conversation, received status: 404, Unclosed client session
when i use Sydney.py to easily create a CLI client for Bing Chat: example.py
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())
But it reported this error:
Traceback (most recent call last):
File "~/Project/sydney.py/example.py", line 24, in <module>
asyncio.run(main())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "~/Project/sydney.py/example.py", line 7, in main
async with SydneyClient() as sydney:
File "~/Project/sydney.py/sydney/sydney.py", line 57, in __aenter__
await self.start_conversation()
File "~/Project/sydney.py/sydney/sydney.py", line 259, in start_conversation
raise Exception(
Exception: Failed to create conversation, received status: 404
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10a233bb0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x10aef11c0>, 0.491523)]']
connector: <aiohttp.connector.TCPConnector object at 0x10ae5ea00>
Is this a problem with Python 3.9?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (10 by maintainers)
@vsakkas I apologize for the delayed response as I have been busy with a Vue project lately. I just noticed your merge and it seems to be working perfectly, just as we hoped for in this project.
Thank you for your contribution and for your patience.
Best regards
Thank you very much for letting me learn a lot about Python. Thank you again!
Yes, I was able to reproduce this issue sometimes on my local setup as well. I am not sure if it is related to the proxy support though, as it seems to be the behavior of
input()
in Python. You can see here a short discussion (and solution) about it: https://stackoverflow.com/questions/65976696/how-to-ignore-input-while-in-a-loop-pythonSo what seems to happens is that after this, Bing Chat closes the conversation from its side with the last message being:
I'm sorry but I haven't received any message from you. If you have any questions or need help with anything, feel free to ask me anytime.🙂
but the Sydney Client tries to send another message to it anyways.This script should fix the issue for you, I think:
According to my testing, if you type enter again while waiting for Sydney’s answer, it will prompt for the first time:
You: Sydney: I'm sorry but I haven't received any message from you. If you have any questions or need help with anything, feel free to ask me anytime.🙂
The second time you ask again, he will report this error:
So if you wait for it to reply every time before entering, there won’t be any problems.
That’s great. I successfully used the latest branch.
At that time, I replied with “love you”,She may be too shy to report the mistake ^-^
I have never heard of Poetry before and have always used Pip. It seems like it’s a good tool, and I will try to learn its usage.
It doesn’t seem to be working