sydney.py: Is there an error in my code, or is there a bug in the library?

this is my code that I created to have a personal bot on telegram. the bot responds perfectly to questions that do not require searching on the web, as soon as you ask a question for which you will have to look for the answer on the internet I get this error… why? how can I solve it Sydney: Searching the web for: Cosa c’è sulla luna?` it hangs like this without giving me the answer in the telegram bot and it doesn’t give me any errors in the terminal

this is my code

import os import asyncio import telebot from sydney import SydneyClient

Token del bot Telegram, ottenuto da BotFather su Telegram telegram_token = 'bot_token'

Impostazione del cookie _U per l'utilizzo con Sydney.py bing_cookies = 'cookies _u' os.environ["BING_U_COOKIE"] = bing_cookies

` Inizializzazione del bot Telegram bot = telebot.TeleBot(telegram_token)

Funzione per gestire il comando /start @bot.message_handler(commands=['start']) def send_welcome(message): bot.reply_to(message, "Ciao! Scrivi qualcosa per iniziare la conversazione con Sydney.")

Funzione per gestire i messaggi testuali `@bot.message_handler(func=lambda message: True) def handle_message(message): async def ask_sydney(question): async with SydneyClient() as sydney: response = await sydney.ask(question) return response

question = message.text`

`interrogazione di Sydney per ottenere la risposta
response = asyncio.run(ask_sydney(question))

# Invio della risposta al mittente su Telegram
bot.reply_to(message, f"Sydney: {response}")

Avvio del bot

bot.polling()`

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 35 (15 by maintainers)

Most upvoted comments

Glad to know that you got your code working @BlackDicky ! Unfortunately, right now there is no way to generate images from Sydney.py (but you can do the opposite, provide images through attachment parameter), but it is something that I’d like to add in the upcoming weeks 😃

I solved everything and thank you for all the time you have dedicated to me I also updated to 0.19.0 and I implemented the much and beloved function we have been waiting for! Of the “web Search” you are great !! By any chance you also created a method on how to get images with Bing image creator ? 💘 @vsakkas

As for the Captcha error, you can try to get new cookies, or if you see this error, go to the copilot web page, write a message to get the verification response and then try again

I am noticing that the Captcha problem is very frequent. If I go to the coopilot and write a message it does not appear “Verification in progress” as it normally should appear to me, but it responds to me automatically, returning to the script it tells me again to do this captcha check that does not appear even when I write on the copilot @vsakkas

Also sydney.exceptions.ConnectionTimeoutException: Failed to connect to Copilot, connection timed out appears very often making the bot almost unusable

Ok then now I try to see this new version, and I try to insert “headers string” as I did before with cookie editor.

Thanks to you for your patience, I hope to help you understand this mistake as soon as possible ❤️

Thank you for your kind words @BlackDicky !!

I am looking at your report, and I see this important information:

File "/Users/davide/Documents/tutto/jfkdjhfdi.py", line 10, in main await conversation_loop(sydney, colors, color_index) File "/Users/davide/Documents/tutto/jfkdjhfdi.py", line 24, in conversation_loop async for response, suggested_responses in sydney.ask_stream(prompt, suggestions=True): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/sydney/sydney.py", line 453, in ask_stream async for response, suggested_responses in self._ask( File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/sydney/sydney.py", line 244, in _ask for item in messages[1]["suggestedResponses"] ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'suggestedResponses'

KeyError: 'suggestedResponses' suggests that there is a bug with with the library, not your code. Which version of Sydney.py are you using?

This is information I received with the pip show sydney-py command:

Name: sydney-py
Version: 0.18.0
Summary: Python Client for Copilot (formerly named Bing Chat), also known as Sydney.
Home-page: 
Author: vsakkas
Author-email: vasileios.sakkas96@gmail.com
License: MIT
Location: /opt/homebrew/lib/python3.11/site-packages
Requires: aiohttp, websockets

@vsakkas

Thank you for your kind words @BlackDicky !!

I am looking at your report, and I see this important information:

File "/Users/davide/Documents/tutto/jfkdjhfdi.py", line 10, in main await conversation_loop(sydney, colors, color_index) File "/Users/davide/Documents/tutto/jfkdjhfdi.py", line 24, in conversation_loop async for response, suggested_responses in sydney.ask_stream(prompt, suggestions=True): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/sydney/sydney.py", line 453, in ask_stream async for response, suggested_responses in self._ask( File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/sydney/sydney.py", line 244, in _ask for item in messages[1]["suggestedResponses"] ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'suggestedResponses'

KeyError: 'suggestedResponses' suggests that there is a bug with with the library, not your code. Which version of Sydney.py are you using? I suspect you might be using an older version which contains bugs that were fixed in later versions.

@vsakkas If you could take a look and let me know if it’s the code or the library that’s the problem, I’d be grateful. and thank you again for everything you do. Your work is highly appreciated by me, you are very good and I will support you in every project you do! ❤️

Hi @BlackDicky

I will take a look at the code and see what could cause this. There is some code which is supposed to hide those “Searching the web” messages, but it might need to be updated. I will follow up later on this!