@@ -1116,8 +1116,8 @@ msgid "1080p output is not supported for Seedance Dreamina 2.0 Fast." msgstr "1080р разрешение не поддерживается для Seedance Dreamina 2.0 Fast." #: ml_model/services/seedream.py:90 -msgid "3K output is not supported for Seedream 4.5" -msgstr "3К разрешение не поддерживается для Seedream 4.5" +msgid "3K output is not supported for this model" +msgstr "3К разрешение не поддерживается для этой модели" #: ml_model/services/upscaleai.py:124 msgid "No image given for improving" @@ -21,20 +21,20 @@ from payments.selectors.payment_plan_selector import PaymentPlanSelector class Seedream(SimpleService): TOKEN_COST = { - "seedream-boosted": { - "2K": Decimal('25'), - "3K": Decimal('50'), - "4K": Decimal('100'), + 'seedream-boosted': { + '2K': Decimal('25'), + '3K': Decimal('50'), + '4K': Decimal('100'), }, - "seedream-4.5": { - "2K": Decimal('25'), - "4K": Decimal('100'), + 'seedream-4.5': { + '2K': Decimal('25'), + '4K': Decimal('100'), }, } VERSION_MAPPING = { - "seedream-boosted": "seedream-5-0-260128", - "seedream-4.5": "seedream-4-5-251128", + 'seedream-boosted': 'seedream-5-0-260128', + 'seedream-4.5': 'seedream-4-5-251128', } OPTIMIZATION_PROMPT = """ @@ -74,23 +74,22 @@ class Seedream(SimpleService): def make(self, input_message: Message, save: bool = True) -> list[Message]: start_time = time.time() - if (balance := PaymentPlanSelector(self.store.user).get_current_balance()) < (predicted := self.predict_price( - input_message.content, - input_message.file is not None, - input_message.info, - )): - raise InsufficientBalance(balance, predicted) - version = input_message.info.pop('version', None) + size = input_message.info.get('size', '2K') + if version is None or version not in self.TOKEN_COST: raise ModelVersionNotAvailable(version, self.TOKEN_COST) - size = input_message.info.get('size', '2K') if version == 'seedream-4.5' and size == '3K': - raise InvalidParameterError(_('3K output is not supported for Seedream 4.5')) + raise InvalidParameterError(_('3K output is not supported for this model')) + + if (balance := PaymentPlanSelector(self.store.user).get_current_balance()) < ( + predicted := self.calculate_price(version, size) + ): + raise InsufficientBalance(balance, predicted) callback_data = { - 'prompt': f"{input_message.content}\n{self.OPTIMIZATION_PROMPT}", + 'prompt': f'{input_message.content}\n{self.OPTIMIZATION_PROMPT}', 'watermark': False, **input_message.info, } @@ -21,11 +21,9 @@ class Stablediffusion(Seedream): def _remap_info(cls, info: dict[str, Any]) -> dict[str, Any]: new_info = info.copy() version = info.get('version', 'sd3') - - if version not in cls.PROXY_VERSION_MAPPING and version not in cls.PROXY_VERSION_MAPPING.values(): + if version not in cls.PROXY_VERSION_MAPPING: raise ModelVersionNotAvailable(version, cls.PROXY_VERSION_MAPPING) - new_info['version'] = cls.PROXY_VERSION_MAPPING.get(version, version) - + new_info['version'] = cls.PROXY_VERSION_MAPPING[version] return new_info @classmethod