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)
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
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 unusableOk 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 ❤️
This is information I received with the
pip show sydney-py
command:@vsakkas
Thank you for your kind words @BlackDicky !!
I am looking at your report, and I see this important information:
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!