@@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-20 16:37+0300\n" +"POT-Creation-Date: 2025-12-04 13:22+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,7 +66,7 @@ msgstr "Токен не получен" msgid "Wrong email" msgstr "Неверный email" -#: authentication/exceptions/user.py:11 backend/urls.py:46 +#: authentication/exceptions/user.py:11 backend/urls.py:45 msgid "Wrong password" msgstr "Неверный пароль" @@ -149,8 +149,8 @@ msgid "Business Groups" msgstr "Бизнес Группы" #: authentication/models/business_host.py:22 -#: authentication/models/email_token.py:13 authentication/models/user.py:225 -#: authentication/models/user.py:226 authentication/models/user_telegram.py:22 +#: authentication/models/email_token.py:13 authentication/models/user.py:222 +#: authentication/models/user.py:223 authentication/models/user_telegram.py:22 #: authentication/models/user_vk.py:12 payments/admin.py:35 #: payments/admin.py:89 payments/models/invoice.py:15 #: payments/models/payment.py:26 payments/models/payment_plan.py:61 @@ -161,7 +161,7 @@ msgstr "Пользователь" msgid "Affiliated by" msgstr "Кем привлечена" -#: authentication/models/business_host.py:36 authentication/models/user.py:138 +#: authentication/models/business_host.py:36 authentication/models/user.py:135 #: authentication/models/whitelist.py:16 ml_model/models.py:167 #: payments/models/promocode.py:85 msgid "Is active" @@ -316,48 +316,44 @@ msgstr "Email Токен" msgid "Email Tokens" msgstr "Email Токены" -#: authentication/models/user.py:126 authentication/models/user_telegram.py:9 +#: authentication/models/user.py:124 authentication/models/user_telegram.py:9 msgid "First name" msgstr "Имя" -#: authentication/models/user.py:133 authentication/models/user_telegram.py:10 +#: authentication/models/user.py:131 authentication/models/user_telegram.py:10 msgid "Last name" msgstr "Фамилия" -#: authentication/models/user.py:135 authentication/models/user_telegram.py:11 -msgid "Username" -msgstr "Имя пользователя" - -#: authentication/models/user.py:136 +#: authentication/models/user.py:133 msgid "Email" msgstr "Email" -#: authentication/models/user.py:140 +#: authentication/models/user.py:137 msgid "Is staff" msgstr "Административный" -#: authentication/models/user.py:141 +#: authentication/models/user.py:138 msgid "Is superuser" msgstr "Суперюзер" -#: authentication/models/user.py:142 +#: authentication/models/user.py:139 msgid "Is email confirmed" msgstr "Email подтвержден" -#: authentication/models/user.py:143 +#: authentication/models/user.py:140 msgid "Is subscribed" msgstr "Подписан на уведомления" -#: authentication/models/user.py:145 +#: authentication/models/user.py:142 msgid "Picture name" msgstr "Имя аватара" -#: authentication/models/user.py:147 tools/chats/models.py:13 +#: authentication/models/user.py:144 tools/chats/models.py:13 #: tools/public_api/models.py:45 msgid "Is deleted" msgstr "Удален" -#: authentication/models/user.py:152 authentication/models/utm.py:21 +#: authentication/models/user.py:149 authentication/models/utm.py:21 msgid "UTM" msgstr "UTM" @@ -369,6 +365,10 @@ msgstr "Телеграм ID" msgid "Is bot" msgstr "Является ботом" +#: authentication/models/user_telegram.py:11 +msgid "Username" +msgstr "Имя пользователя" + #: authentication/models/user_telegram.py:12 msgid "Language" msgstr "Язык" @@ -462,13 +462,13 @@ msgstr "Пользователь не найден" msgid "Access token expired or does not exist" msgstr "Токен доступа просрочен или не существует" -#: authentication/selectors/business_host_selector.py:42 -#: authentication/selectors/business_host_selector.py:85 +#: authentication/selectors/business_host_selector.py:41 +#: authentication/selectors/business_host_selector.py:84 msgid "User haven't rights to access host account information" msgstr "" "У пользователя недостаточно прав для просмотра информации бизнес-аккаунта" -#: authentication/selectors/business_host_selector.py:60 +#: authentication/selectors/business_host_selector.py:59 msgid "Host user is not registered for this account" msgstr "Пользователь бизнес-аккаунта не зарегистрирован для этого аккаунта" @@ -494,7 +494,7 @@ msgstr "Пароли не совпадают" msgid "You cannot change the password of an unconfirmed e-mail user." msgstr "Вы не можете изменить пароль неподтвержденного по e-mail пользователя." -#: authentication/services/business_host_service.py:159 +#: authentication/services/business_host_service.py:158 msgid "No user_email is provided" msgstr "" @@ -534,39 +534,35 @@ msgstr "Пароли не совпадают" msgid "Current password is wrong" msgstr "Текущий пароль неверен" -#: authentication/views.py:121 authentication/views.py:230 -#: authentication/views.py:326 authentication/views.py:357 +#: authentication/views.py:120 authentication/views.py:229 +#: authentication/views.py:325 authentication/views.py:356 msgid "Server error occured" msgstr "Случилась серверная ошибка" -#: authentication/views.py:226 +#: authentication/views.py:225 msgid "Email not found" msgstr "Email не найден" -#: authentication/views.py:322 +#: authentication/views.py:321 msgid "Business account has been deleted" msgstr "Сотрудник успешно удален" -#: authentication/views.py:346 +#: authentication/views.py:345 msgid "Business account has been reinvited" msgstr "Повторное приглашение сотруднику успешно отправлено" -#: authentication/views.py:469 +#: authentication/views.py:455 msgid "Could not confirm email, please try again." msgstr "Невозможно подтвердить email, попробуйте позже" -#: backend/urls.py:36 +#: backend/urls.py:35 msgid "Requested object does not exists" msgstr "" -#: backend/urls.py:41 +#: backend/urls.py:40 msgid "Token is invalid" msgstr "" -#: backend/urls.py:51 -msgid "Wrong username" -msgstr "Неверное имя пользователя" - #: messages/serializers.py:50 #, python-format msgid "The file size cannot exceed %(max_mb_size)d MB" @@ -640,6 +636,10 @@ msgstr "Нейронная модель не существует" msgid "The %(file_type)s is not attached" msgstr "Файл (%(file_type)s) не прикреплен" +#: ml_model/exceptions.py:85 +msgid "No image content found in response. Try a different request" +msgstr "В промпте отсутствует описание изображения. Попробуйте другой запрос" + #: ml_model/models.py:18 ml_model/models.py:38 ml_model/models.py:70 #: ml_model/models.py:182 msgid "Slug" @@ -1176,7 +1176,7 @@ msgstr "Публичный API" msgid "Media" msgstr "Медиа" -#: tools/chats/apis.py:181 tools/media/apis.py:160 +#: tools/chats/apis.py:182 tools/media/apis.py:160 #: tools/public_api/views/base.py:103 msgid "" "Error occured when create generation. It may cause NSFW-content not allowed, " @@ -1240,6 +1240,9 @@ msgstr "Отсутствует обязательный параметр: 'messa msgid "Model not found" msgstr "Модель не найдена" +#~ msgid "Wrong username" +#~ msgstr "Неверное имя пользователя" + #~ msgid "Achievement" #~ msgstr "Достижение" @@ -5,9 +5,10 @@ from io import BytesIO import requests from django.core.files import File +from replicate.exceptions import ModelError from messages.models import Message -from ml_model.exceptions import ModelTimeoutError +from ml_model.exceptions import ModelTimeoutError, ImageContentNotFound from ml_model.services.base import SimpleService from ml_model.tasks import replicate_run @@ -37,15 +38,19 @@ class Geminiimage(SimpleService): def make(self, input_message: Message, save: bool = True) -> list[Message]: if input_message.content: - callback_data = dict( - {'prompt': self.translate_prompt(input_message.content), **input_message.info} - ) - start_time = time.time() - images = replicate_run('google/gemini-2.5-flash-image', callback_data) - process_time = timedelta(seconds=(time.time() - start_time)) - self.handle_invoice( - input_message.content_object.model, num_images=input_message.info.get('num_images', 1) - ) - msgs = self.save_results(input_message.content, process_time, images, save) - return msgs + try: + callback_data = dict( + {'prompt': self.translate_prompt(input_message.content), **input_message.info} + ) + start_time = time.time() + images = replicate_run('google/gemini-2.5-flash-image', callback_data) + process_time = timedelta(seconds=(time.time() - start_time)) + self.handle_invoice( + input_message.content_object.model, num_images=input_message.info.get('num_images', 1) + ) + msgs = self.save_results(input_message.content, process_time, images, save) + return msgs + except ModelError as exc: + if exc.prediction.error == 'No image content found in response': + raise ImageContentNotFound raise ModelTimeoutError @@ -78,3 +78,8 @@ class FileNotProvided(Exception): def __str__(self) -> str: return _('The %(file_type)s is not attached') % {'file_type': _(self.file_type).lower()} + + +class ImageContentNotFound(Exception): + def __str__(self): + return _('No image content found in response. Try a different request') @@ -10,7 +10,7 @@ from rest_framework.views import APIView from messages.models import Message from messages.serializers import MessageSerializer -from ml_model.exceptions import RequestBlocked, UnsupportedSize, FileNotProvided +from ml_model.exceptions import RequestBlocked, UnsupportedSize, FileNotProvided, ImageContentNotFound from ml_model.models import NeuronModel from ml_model.services.base import SimpleService from payments.exceptions.insufficient_balance import InsufficientBalance @@ -152,7 +152,7 @@ class MediaAPIView(APIView): input_message.save() if isinstance(exc, InsufficientBalance): return Response({'detail': f'{exc}'}, status=HTTP_402_PAYMENT_REQUIRED) - if isinstance(exc, (UnsupportedSize, RequestBlocked, FileNotProvided)): + if isinstance(exc, (UnsupportedSize, RequestBlocked, FileNotProvided, ImageContentNotFound)): return Response({'detail': f'{exc}'}, status=HTTP_400_BAD_REQUEST) return Response( {