Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions apps/models_provider/impl/minimax_model_provider/credential/itv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

class MiniMaxModelParams(BaseForm):
"""
Parameters class for the Qwen Text-to-Video model.
Defines fields such as Video size, number of Videos, and style.
Parameters class for the MiniMax V1 (legacy) Video model.
"""

aigc_watermark = SwitchField(
Expand All @@ -25,6 +24,40 @@ class MiniMaxModelParams(BaseForm):
)


class MiniMaxH3ModelParams(BaseForm):
"""
Parameters class for the MiniMax V2 (MiniMax-H3) Video model.
"""

resolution = forms.SingleSelect(
TooltipLabel(_("Resolution"), _("Output video resolution.")),
required=True,
default_value="480P",
option_list=[{"value": value, "label": value} for value in ["480P", "768P", "2K"]],
text_field="label",
value_field="value",
)

duration = forms.SliderField(
TooltipLabel(_("Duration"), _("Video duration in seconds (4-15).")),
4,
15,
1,
0,
required=True,
default_value=10,
)

ratio = forms.SingleSelect(
TooltipLabel(_("Aspect ratio"), _("Output video aspect ratio.")),
required=False,
default_value="16:9",
option_list=[{"value": value, "label": value} for value in ["16:9", "9:16", "1:1", "4:3", "3:4"]],
text_field="label",
value_field="value",
)


class ImageToVideoModelCredential(BaseForm, BaseModelCredential):
"""
Credential class for the Qwen Text-to-Video model.
Expand Down Expand Up @@ -103,3 +136,17 @@ def get_model_params_setting_form(self, model_name: str):
:return: Parameter setting form.
"""
return MiniMaxModelParams()


class MiniMaxH3ImageToVideoModelCredential(ImageToVideoModelCredential):
"""
Credential for the MiniMax H3 / H3-Max (V2) image-to-video model.
Uses the V2 endpoint and requires resolution / duration / ratio.
"""

# BaseForm 只收集本类的字段(vars(self.__class__) 不走 MRO),继承字段需重新声明
api_base = forms.TextInputField("API URL", required=True, default_value="https://api.minimaxi.com/v2")
api_key = PasswordInputField("API Key", required=True)

def get_model_params_setting_form(self, model_name: str):
return MiniMaxH3ModelParams()
51 changes: 49 additions & 2 deletions apps/models_provider/impl/minimax_model_provider/credential/ttv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

class MiniMaxModelParams(BaseForm):
"""
Parameters class for the Qwen Text-to-Video model.
Defines fields such as Video size, number of Videos, and style.
Parameters class for the MiniMax V1 (legacy) Video model.
"""

aigc_watermark = SwitchField(
Expand All @@ -25,6 +24,40 @@ class MiniMaxModelParams(BaseForm):
)


class MiniMaxH3ModelParams(BaseForm):
"""
Parameters class for the MiniMax V2 (MiniMax-H3) Video model.
"""

resolution = forms.SingleSelect(
TooltipLabel(_("Resolution"), _("Output video resolution.")),
required=True,
default_value="480P",
option_list=[{"value": value, "label": value} for value in ["480P", "768P", "2K"]],
text_field="label",
value_field="value",
)

duration = forms.SliderField(
TooltipLabel(_("Duration"), _("Video duration in seconds (4-15).")),
4,
15,
1,
0,
required=True,
default_value=10,
)

ratio = forms.SingleSelect(
TooltipLabel(_("Aspect ratio"), _("Output video aspect ratio.")),
required=False,
default_value="16:9",
option_list=[{"value": value, "label": value} for value in ["16:9", "9:16", "1:1", "4:3", "3:4"]],
text_field="label",
value_field="value",
)


class TextToVideoModelCredential(BaseForm, BaseModelCredential):
"""
Credential class for the Qwen Text-to-Video model.
Expand Down Expand Up @@ -103,3 +136,17 @@ def get_model_params_setting_form(self, model_name: str):
:return: Parameter setting form.
"""
return MiniMaxModelParams()


class MiniMaxH3TextToVideoModelCredential(TextToVideoModelCredential):
"""
Credential for the MiniMax H3 / H3-Max (V2) text-to-video model.
Uses the V2 endpoint and requires resolution / duration / ratio.
"""

# BaseForm 只收集本类的字段(vars(self.__class__) 不走 MRO),继承字段需重新声明
api_base = forms.TextInputField("API URL", required=True, default_value="https://api.minimaxi.com/v2")
api_key = PasswordInputField("API Key", required=True)

def get_model_params_setting_form(self, model_name: str):
return MiniMaxH3ModelParams()
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
ModelTypeConst,
ModelInfoManage,
)
from models_provider.impl.minimax_model_provider.credential.itv import ImageToVideoModelCredential
from models_provider.impl.minimax_model_provider.credential.itv import (
ImageToVideoModelCredential,
MiniMaxH3ImageToVideoModelCredential,
)
from models_provider.impl.minimax_model_provider.credential.llm import MiniMaxLLMModelCredential
from models_provider.impl.minimax_model_provider.credential.tti import MiniMaxTextToImageModelCredential
from models_provider.impl.minimax_model_provider.credential.tts import MiniMaxTTSModelCredential
from models_provider.impl.minimax_model_provider.credential.ttv import TextToVideoModelCredential
from models_provider.impl.minimax_model_provider.credential.ttv import (
MiniMaxH3TextToVideoModelCredential,
TextToVideoModelCredential,
)
from models_provider.impl.minimax_model_provider.model.llm import MiniMaxChatModel
from models_provider.impl.minimax_model_provider.model.tti import MiniMaxTextToImageModel
from models_provider.impl.minimax_model_provider.model.tts import MiniMaxTextToSpeech
Expand All @@ -27,6 +33,8 @@
minimax_tti_model_credential = MiniMaxTextToImageModelCredential()
minimax_ttv_model_credential = TextToVideoModelCredential()
minimax_itv_model_credential = ImageToVideoModelCredential()
minimax_h3_ttv_model_credential = MiniMaxH3TextToVideoModelCredential()
minimax_h3_itv_model_credential = MiniMaxH3ImageToVideoModelCredential()

minimax_m2_7 = ModelInfo(
"MiniMax-M2.7",
Expand Down Expand Up @@ -87,10 +95,14 @@
ModelInfo("image-01", _(""), ModelTypeConst.TTI, minimax_tti_model_credential, MiniMaxTextToImageModel),
]
minimax_ttv_list = [
ModelInfo("MiniMax-H3", _(""), ModelTypeConst.TTV, minimax_h3_ttv_model_credential, GenerationVideoModel),
ModelInfo("MiniMax-H3-Max", _(""), ModelTypeConst.TTV, minimax_h3_ttv_model_credential, GenerationVideoModel),
ModelInfo("MiniMax-Hailuo-2.3", _(""), ModelTypeConst.TTV, minimax_ttv_model_credential, GenerationVideoModel),
]

model_info_itv_list = [
ModelInfo("MiniMax-H3", _(""), ModelTypeConst.ITV, minimax_h3_itv_model_credential, GenerationVideoModel),
ModelInfo("MiniMax-H3-Max", _(""), ModelTypeConst.ITV, minimax_h3_itv_model_credential, GenerationVideoModel),
ModelInfo("MiniMax-Hailuo-2.3", _(""), ModelTypeConst.ITV, minimax_itv_model_credential, GenerationVideoModel),
]
model_info_manage = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def _build_session(self) -> requests.Session:
# ---------- API 版本探测 / URL 构建 ----------

def _detect_api_version(self) -> str:
"""根据 api_base 路径判断当前使用 V1 还是 V2 (MiniMax-H3)。"""
"""探测当前使用 V1 还是 V2 (MiniMax-H3)。"""
# 模型名包含 H3 -> V2
if self.model_name and "H3" in self.model_name.upper():
return "v2"
# api_base 路径包含 /v2 -> V2
base_path = self.api_base.split("://", 1)[-1] if "://" in self.api_base else self.api_base
if "/v2" in base_path:
return "v2"
Expand Down
Loading