ruecat / ollama-telegram

🦙 Ollama Telegram bot, with advanced configuration
MIT License
295 stars 81 forks source link

error sometimes when bot sending a message #67

Open kroryan opened 2 months ago

kroryan commented 2 months ago

so i get an error sometimes when the bot try to answer:

[OllamaAPI-ERR] CAUGHT FAULT! Traceback (most recent call last): File "/home/orangepi/ollama-telegram/bot/run.py", line 270, in ollama_request if await handle_response(message, response_data, full_response): File "/home/orangepi/ollama-telegram/bot/run.py", line 225, in handle_response await send_response(message, text) File "/home/orangepi/ollama-telegram/bot/run.py", line 240, in send_response await bot.send_message(chat_id=message.chat.id, text=text,parse_mode=ParseMode.MARKDOWN) File "/home/orangepi/.local/lib/python3.9/site-packages/aiogram/client/bot.py", line 2718, in send_message return await self(call, request_timeout=request_timeout) File "/home/orangepi/.local/lib/python3.9/site-packages/aiogram/client/bot.py", line 432, in call return await self.session(self, method, timeout=request_timeout) File "/home/orangepi/.local/lib/python3.9/site-packages/aiogram/client/session/base.py", line 257, in call return cast(TelegramType, await middleware(bot, method)) File "/home/orangepi/.local/lib/python3.9/site-packages/aiogram/client/session/aiohttp.py", line 179, in make_request response = self.check_response( File "/home/orangepi/.local/lib/python3.9/site-packages/aiogram/client/session/base.py", line 120, in check_response raise TelegramBadRequest(method=method, message=description) aiogram.exceptions.TelegramBadRequest: Telegram server says - Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 702

do you know what i can do about it?

it only happens sometimes not always i dont understand very well what is going on

kroryan commented 2 months ago

it looks like its relate of using "?" or others symbols, not sure

sebaxakerhtc commented 2 weeks ago

Same here

First of all - THANK YOU !!!

2024-10-31 20:56:48 ollama-tg  | INFO:root:[OllamaAPI]: Processing 'Расскажи о нашей группе' for sebaxakerhtc None
2024-10-31 20:57:01 ollama-tg  | -----
2024-10-31 20:57:01 ollama-tg  | [OllamaAPI-ERR] CAUGHT FAULT!
2024-10-31 20:57:01 ollama-tg  | Traceback (most recent call last):
2024-10-31 20:57:01 ollama-tg  |   File "/code/run.py", line 351, in ollama_request
2024-10-31 20:57:01 ollama-tg  |     if await handle_response(message, response_data, full_response):
2024-10-31 20:57:01 ollama-tg  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-31 20:57:01 ollama-tg  |   File "/code/run.py", line 304, in handle_response
2024-10-31 20:57:01 ollama-tg  |     await send_response(message, text)
2024-10-31 20:57:01 ollama-tg  |   File "/code/run.py", line 319, in send_response
2024-10-31 20:57:01 ollama-tg  |     await bot.send_message(chat_id=message.chat.id, text=text,parse_mode=ParseMode.MARKDOWN)
2024-10-31 20:57:01 ollama-tg  |   File "/usr/local/lib/python3.12/site-packages/aiogram/client/bot.py", line 2917, in send_message
2024-10-31 20:57:01 ollama-tg  |     return await self(call, request_timeout=request_timeout)
2024-10-31 20:57:01 ollama-tg  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-31 20:57:01 ollama-tg  |   File "/usr/local/lib/python3.12/site-packages/aiogram/client/bot.py", line 488, in __call__
2024-10-31 20:57:01 ollama-tg  |     return await self.session(self, method, timeout=request_timeout)
2024-10-31 20:57:01 ollama-tg  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-31 20:57:01 ollama-tg  |   File "/usr/local/lib/python3.12/site-packages/aiogram/client/session/base.py", line 254, in __call__
2024-10-31 20:57:01 ollama-tg  |     return cast(TelegramType, await middleware(bot, method))
2024-10-31 20:57:01 ollama-tg  |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-31 20:57:01 ollama-tg  |   File "/usr/local/lib/python3.12/site-packages/aiogram/client/session/aiohttp.py", line 189, in make_request
2024-10-31 20:57:01 ollama-tg  |     response = self.check_response(
2024-10-31 20:57:01 ollama-tg  |                ^^^^^^^^^^^^^^^^^^^^
2024-10-31 20:57:01 ollama-tg  |   File "/usr/local/lib/python3.12/site-packages/aiogram/client/session/base.py", line 120, in check_response
2024-10-31 20:57:01 ollama-tg  |     raise TelegramBadRequest(method=method, message=description)
2024-10-31 20:57:01 ollama-tg  | aiogram.exceptions.TelegramBadRequest: Telegram server says - Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 1504
2024-10-31 20:57:01 ollama-tg  | 
2024-10-31 20:57:01 ollama-tg  | -----
2024-10-31 20:57:01 ollama-tg  | INFO:aiogram.event:Update id=83927814 is handled. Duration 13295 ms by bot id=7567523847