Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
octo-patch wants to merge 1 commit into
Phantom-video:mainPhantom-video/Phantom:mainfrom
octo-patch:feature/add-openai-compatible-prompt-expanderocto-patch/Phantom:feature/add-openai-compatible-prompt-expanderCopy head branch name to clipboard
Open

feat: add OpenAI-compatible prompt expander (MiniMax, OpenAI, etc.)#50
octo-patch wants to merge 1 commit into
Phantom-video:mainPhantom-video/Phantom:mainfrom
octo-patch:feature/add-openai-compatible-prompt-expanderocto-patch/Phantom:feature/add-openai-compatible-prompt-expanderCopy head branch name to clipboard

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>
@richardchen874-sys

Copy link
Copy Markdown

The point about an OpenAI-compatible prompt expander for video generation workflows is worth separating from generic provider support. In real workloads, the hard part is usually not sending one request; it is keeping cost, latency, and response shape predictable once users switch providers.

I would track prompt expansion, video request, retry, and output status separately. In media workflows, the expensive part is often not the prompt expansion itself but failed or repeated generation attempts.

I am working through similar issues while testing an OpenAI-compatible layer for official Chinese models, where normalized usage and fallback behavior matter a lot. Is prompt expansion mainly for quality improvement, provider fallback, or reducing failed video generations?

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.