Sometimes /prompt_gem does not work
LifeMM opened this issue · 9 comments
When i use the command ‘/prompt_gem xxx’, it rewrites the text with Gemini, but it does not create any images.
Related Info:
command: python3 tg.py <tg_token> <bing_cookie> -c config.toml
config.toml add "[google_gemini] api key"
Traceback (most recent call last):
File "/home/test/.local/lib/python3.10/site-packages/telebot/init.py", line 955, in infinity_polling
self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/home/test/.local/lib/python3.10/site-packages/telebot/init.py", line 1043, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/home/test/.local/lib/python3.10/site-packages/telebot/init.py", line 1118, in __threaded_polling
raise e
File "/home/test/.local/lib/python3.10/site-packages/telebot/init.py", line 1074, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/home/test/.local/lib/python3.10/site-packages/telebot/util.py", line 147, in raise_exceptions
raise self.exception_info
File "/home/test/.local/lib/python3.10/site-packages/telebot/util.py", line 90, in run
task(*args, **kwargs)
File "/home/test/.local/lib/python3.10/site-packages/telebot/init.py", line 6801, in _run_middlewares_and_handler
result = handler'function'
File "/home/test/tg_bing_dalle/tg.py", line 207, in prompt_gemini_handler
respond_prompt(bot, message, bing_cookie_pool, bing_cookie_cnt, s)
File "/home/test/tg_bing_dalle/responder.py", line 47, in respond_prompt
limit = image_obj.get_limit_left()
File "/home/test/.local/lib/python3.10/site-packages/BingImageCreator.py", line 104, in get_limit_left
r = self.session.get("https://www.bing.com/create")
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 557, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 544, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 657, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
sometimes did not work or always did not work?>
Occasionally
ah seems the png problem gemini sometimes refuse to read it
I tried commenting out image_obj.get_limit_left()
, and it seems to be working normally now.
In case of a failure, after it rewrites the text with Gemini, this python script will stuck at get_limit_left func.
def respond_prompt(
bot: TeleBot,
message: Message,
bing_cookie_pool: Iterator[ImageGen],
bing_cookie_cnt: int,
prompt: str,
) -> None:
# Find a cookie within the limit
within_limit = False
for _ in range(bing_cookie_cnt):
image_obj = next(bing_cookie_pool)
limit = image_obj.get_limit_left()
if limit > 1:
within_limit = True
break
I tried commenting out
image_obj.get_limit_left()
, and it seems to be working normally now. In case of a failure, after it rewrites the text with Gemini, this python script will stuck at get_limit_left func.def respond_prompt( bot: TeleBot, message: Message, bing_cookie_pool: Iterator[ImageGen], bing_cookie_cnt: int, prompt: str, ) -> None: # Find a cookie within the limit within_limit = False for _ in range(bing_cookie_cnt): image_obj = next(bing_cookie_pool) limit = image_obj.get_limit_left() if limit > 1: within_limit = True break
thanks for that, can you open one pr about this change
Now I'm getting a new error.
HTTPSConnectionPool(host='www.bing.com', port=443): Read timed out. (read timeout=600)
Using Google, I found a solution.
https://github.com/psf/requests/issues/5430#issuecomment-773738453
I'm trying to modify the Python package code for BingImageCreator-fork==0.7.3.
add below code to BingImageCreator.py
import socket
from urllib3.connection import HTTPConnection
HTTPConnection.default_socket_options = HTTPConnection.default_socket_options + [
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
,(socket.SOL_TCP, socket.TCP_KEEPIDLE, 45)
,(socket.SOL_TCP, socket.TCP_KEEPINTVL, 10)
,(socket.SOL_TCP, socket.TCP_KEEPCNT, 6)
]
and run command
$ python3 setup.py bdist_egg
$ python3 setup.py install
Result: It can always work normally without the various errors reported before.
I have been testing for two days.
@LifeMM Thanks a lot
Can you open PR for all these change?
or I can do it later, will add you to co-auhor?
@yihong0618 You can just do it. This problem has bothered me for a while. Thank you.
OK thanks a lot