Skip to content

feat: add MiniMax Cloud API as alternative prompt enhancement provider#134

Open
octo-patch wants to merge 1 commit intoTencent-Hunyuan:mainfrom
octo-patch:feature/add-minimax-provider
Open

feat: add MiniMax Cloud API as alternative prompt enhancement provider#134
octo-patch wants to merge 1 commit intoTencent-Hunyuan:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

Summary

Add MiniMax M2.7 as a cloud-based prompt enhancement option for users who don't have enough GPU memory to run the local reprompt model (32B or smaller).

This offloads prompt rewriting to MiniMax's OpenAI-compatible API while keeping the exact same predict()/to() interface as the local RePrompt models, so users only need to change one parameter:

pipe = HunyuanImagePipeline.from_pretrained(
    model_name="hunyuanimage-v2.1",
    reprompt_model="minimax",  # cloud prompt enhancement
    use_fp8=True,
)
image = pipe(prompt="A cute penguin", use_reprompt=True)

Changes

  • New file: hyimage/models/reprompt/reprompt_cloud.pyRePromptCloud class
    • OpenAI-compatible SDK calls to MiniMax API
    • Think-tag stripping + <answer> tag parsing (matches local model output format)
    • Temperature clamped to (0, 1] per MiniMax API constraint
    • Graceful fallback to original prompt on API errors
  • Modified: hyimage/models/model_zoo.pyHUNYUANIMAGE_REPROMPT_MINIMAX() factory
  • Modified: hyimage/diffusion/pipelines/hunyuanimage_pipeline.py
    • _resolve_reprompt_config() for clean model name → config mapping
    • Cloud-aware _load_reprompt_model() (skips models_root_path for cloud models)
    • Updated from_pretrained() docstring
  • Modified: README.md — Cloud-based prompt enhancement usage guide
  • New file: tests/test_reprompt_cloud.py — 36 unit + 3 integration tests

5 files changed, 717 additions, 4 deletions

Environment Variables

Variable Required Default
MINIMAX_API_KEY Yes
MINIMAX_MODEL No MiniMax-M2.7
MINIMAX_BASE_URL No https://api.minimax.io/v1

Test Plan

  • 36 unit tests pass (mocked API, no GPU/network needed)
  • 3 integration tests pass (live MiniMax API calls)
  • Tests cover: init, env vars, predict, think-tag stripping, answer-tag parsing, error fallback, Chinese prompts, interface compatibility
  • Existing pipeline behavior unchanged (no modifications to local reprompt flow)

Add MiniMax M2.7 as a cloud-based prompt enhancement option, allowing
users without sufficient GPU memory for the local reprompt model to
offload prompt rewriting to MiniMax's OpenAI-compatible API.

Changes:
- New RePromptCloud class with same predict()/to() interface as local models
- HUNYUANIMAGE_REPROMPT_MINIMAX factory in model_zoo
- Pipeline support for reprompt_model="minimax" in from_pretrained()
- Cloud detection via empty load_from to skip local model loading
- Think-tag stripping and <answer> tag parsing for M2.7 compatibility
- Temperature clamped to (0, 1] per MiniMax API constraint
- README docs with usage example and env var configuration
- 36 unit tests + 3 integration tests (39 total)

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant