@@ -628,6 +628,10 @@ msgid "The model is currently disabled. Please try again later." msgstr "" "Модель в настоящее время неактивна. Пожалуйста, повторите попытку позже." +#: ml_model/exceptions.py:142 +msgid "Available only in paid plan" +msgstr "Доступно только в платном тарифе" + #: ml_model/exceptions.py:119 msgid "Service is currently unavailable due to high demand. Please try again later" msgstr "Сервис временно недоступен из-за высокой нагрузки. Пожалуйста, попробуйте позже" @@ -10,7 +10,7 @@ from django.utils.translation import gettext_lazy from langchain_core.messages import HumanMessage, SystemMessage, BaseMessage from messages.models import Message -from ml_model.exceptions import FileExtensionNotSupported, CorruptedFileError +from ml_model.exceptions import FileExtensionNotSupported, CorruptedFileError, PaidPlanRequiredError from ml_model.models import NeuronModel from ml_model.services import Chatgpt from ml_model.services.EmbeddingService import EmbeddingService @@ -108,6 +108,8 @@ class Chatgpt_5_4(Chatgpt): user_system_prompt = info.pop('system_prompt', '') plan_info = self.store.user.payment_plan is_free_plan = plan_info and plan_info.plan.price <= 0 + if is_free_plan and model_name == 'gpt-5.4-pro': + raise PaidPlanRequiredError() if is_free_plan: info.pop('web_search', None) info.pop('code_interpreter', None) @@ -136,3 +136,8 @@ class PromptLengthExceeded(Exception): class ServiceHighDemandError(Exception): def __str__(self) -> str: return _('Service is currently unavailable due to high demand. Please try again later') + + +class PaidPlanRequiredError(Exception): + def __str__(self) -> str: + return _('Available only in paid plan') @@ -26,6 +26,7 @@ from ml_model.exceptions import ( FileExtensionNotSupported, FileTooLargeError, ImageAnalysisError, + PaidPlanRequiredError, PromptLengthExceeded, RequestBlocked, TemplateNotFound, @@ -167,6 +168,8 @@ class MessagesAPIView(APIView): {'detail': f'{exc}'}, status=HTTP_503_SERVICE_UNAVAILABLE, ) + except PaidPlanRequiredError as exc: + return Response({'detail': f'{exc}'}, status=HTTP_402_PAYMENT_REQUIRED) except ( FileExtensionNotSupported, ExceededContextLengthError,