Skip to content

feat: add OpenAI-compatible prompt expander (MiniMax, OpenAI, etc.)#50

Open
octo-patch wants to merge 1 commit intoPhantom-video:mainfrom
octo-patch:feature/add-openai-compatible-prompt-expander
Open

feat: add OpenAI-compatible prompt expander (MiniMax, OpenAI, etc.)#50
octo-patch wants to merge 1 commit intoPhantom-video:mainfrom
octo-patch:feature/add-openai-compatible-prompt-expander

Conversation

@octo-patch
Copy link
Copy Markdown

Summary

Adds a third prompt extension backend (OpenAICompatPromptExpander) that works with any OpenAI-compatible LLM API, complementing the existing DashScope and local Qwen backends.

  • By default uses MiniMax (MiniMax-M2.7 at https://api.minimax.io/v1), but the base URL and model can be overridden for OpenAI, DeepSeek, or any other OpenAI-compatible provider
  • Supports both text-only (extend) and image+text (extend_with_img) prompt extension via base64 encoding
  • Includes think-tag stripping for reasoning models and configurable retries
  • New --prompt_extend_method openai_compatible CLI option in generate.py

Changes

File Description
phantom_wan/utils/prompt_extend.py New OpenAICompatPromptExpander class
generate.py Wire up openai_compatible method + import
README.md Usage docs for MiniMax/OpenAI-compatible prompt extension
tests/test_openai_compat_prompt_expander.py 29 unit tests
tests/test_openai_compat_integration.py 3 live integration tests

Usage

export MINIMAX_API_KEY="your-key"
python generate.py --task s2v-1.3B --size 832*480 \
  --ckpt_dir ./Wan2.1-T2V-1.3B \
  --phantom_ckpt ./Phantom-Wan-Models/Phantom-Wan-1.3B.pth \
  --ref_image "examples/ref1.png,examples/ref2.png" \
  --prompt "A girl playing with a dog" \
  --use_prompt_extend --prompt_extend_method openai_compatible

Test plan

  • 29 unit tests pass (mocked OpenAI client)
  • 3 integration tests pass (live MiniMax API)
  • Existing DashScope/Qwen codepaths unaffected (no changes to existing classes)

Add a third prompt extension backend that works with any
OpenAI-compatible API. By default it uses MiniMax (MiniMax-M2.7 model
at https://api.minimax.io/v1), but the base URL and model can be
overridden for other providers like OpenAI.

- New OpenAICompatPromptExpander class in prompt_extend.py
  (text-only and image+text via base64, think-tag stripping, retries)
- New --prompt_extend_method openai_compatible CLI option in generate.py
- README section documenting MiniMax / OpenAI-compatible usage
- 29 unit tests + 3 live integration tests

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