feat: add MiniMax as LLM provider for film skill extraction#8
Open
octo-patch wants to merge 1 commit into
Open
feat: add MiniMax as LLM provider for film skill extraction#8octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
Owner
|
Thank you for your submission. @octo-patch I have updated the code version, the new version is for the model supplier in the database. If convenient, please merge the code and submit again. |
- Add MiniMax chat model provider (OpenAI-compatible interface) - Register MiniMax with default base URL https://api.minimax.io/v1 - Support MiniMax-M2.7 and MiniMax-M2.7-highspeed models - Add MINIMAX_API_KEY environment variable support via existing Provider API - Add unit tests for MiniMax provider registration and model names
e141960 to
02ecfaa
Compare
yhyyz
pushed a commit
to yhyyz/Jellyfish
that referenced
this pull request
May 27, 2026
…-8 prompt constraint
P3 Wave 17 closing tasks T17-7 + T17-8.
services/studio/chapter_av_planner.py NEW:
- DurationEstimator: text → estimated TTS ms
* Language detection (zh / en / mixed via unicode ranges)
* Rate constants: zh dialog 4 chars/s, narration 3 chars/s, en 0.5s/word
* speed × voice_pack.default_speed multipliers
- ChapterAvPlanner: Decision F decision tree per ShotDialogLine
1. ESTIMATE @ speed=1.0
2. COMPARE: |estimated - shot_duration_ms| / shot_duration_ms > 0.15 → mismatch
3. ACTION:
a. SPEED_ADJUST: clamp ideal speed to [0.95, 1.15]; accept if within ±15%
b. LLM_REWRITE: invoke DurationRewriterAgent up to MAX_REWRITE_ATTEMPTS=3,
each attempt feeds shorter text back into estimator
c. HOLD: returns DurationDecision(action='hold', warning=...) for user
intervention (R-P3-3 mitigation: prevents infinite rewrite loop)
chains/agents/commerce/duration_rewriter_agent.py NEW:
- DurationRewriterAgent: structured output via method='json_schema' strict=True
per Decision D5; reads _DURATION_REWRITER template; tail-truncate fallback
if LLM violates target_chars cap
services/studio/chapter_av_plan_worker.py NEW:
- TASK_KIND='chapter_av_plan', slow queue, 7200s timeout
- 3 cancel checkpoints: before_iterate / after_iterate / after_persist
- Walks chapter shots → loads voice_pack (per dialog line override > character
default > variant default > narration variant for VOICE_OVER > first system)
→ calls planner.plan_dialog_line → writes ShotDialogLine.start_time_ms /
end_time_ms / text update / suggested_speed metadata
- result schema: {decisions: [DurationDecision], holds: [line_ids],
total_warnings: int, warnings: [str]}
services/studio/builtin_prompts.py:
- T17-8: _STORY_FORMULA_GENERATOR adds hard constraint Forget-C#8 (dialog ≤ 4·N
chars, narration ≤ 3·N chars; en 1 word ≈ 0.5s) + Shot schema dialog/
narration field descriptions tightened
- _DURATION_REWRITER template: NEW module constant (NOT in
BUILTIN_PROMPT_DEFINITIONS — preserves 27-item snapshot contract; agent
imports directly to avoid PromptCategory enum drift)
services/commerce/task_dispatch.py:
- TASK_KIND_CHAPTER_AV_PLAN constant + enqueue_chapter_av_plan(body) (slow queue)
services/worker/task_registry.py:
- register('chapter_av_plan', build_chapter_av_plan_executor()) (7200s timeout)
tests/_snapshots_builtin_prompts/story_formula_generator_v1.txt:
- Regenerated to reflect T17-8 duration constraint addition (5 new lines for
constraint Forget-C#8 + 2 lines on Shot schema dialog/narration; diff is intended)
5 NEW test files (41 cases):
- test_duration_estimator.py (10): zh/en/mixed lang detect, dialog vs narration
rate, speed multiplier, voice_pack default_speed multiplier, edge cases
- test_chapter_av_planner.py (11): all 4 Decision F branches covered (accept,
speed_adjust, llm_rewrite, hold), threshold=0.15 + max_attempts=3 locked,
mixed-language handling, empty text edge case
- test_duration_rewriter_agent.py (4): json_schema structured output, target
cap enforcement, tail-truncate fallback
- test_chapter_av_plan_worker.py (5): full chapter walk-through, persistence,
3 cancel checkpoints, hold case populates result.holds + warnings
- test_builtin_prompts_duration_constraint.py (11): _STORY_FORMULA_GENERATOR
contains constraint Forget-C#8, Shot schema dialog field has cap, _DURATION_REWRITER
exported but NOT in BUILTIN_PROMPT_DEFINITIONS, registry count locked at 27
Verification: 41 + 52 regression + 26 sibling = 119 tests green +
pylint 10.00/10 across 6 changed source files + lsp 0 errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add MiniMax as an alternative LLM provider for film skill extraction. MiniMax provides an OpenAI-compatible API, enabling seamless integration via
langchain-openai'sChatOpenAIwith a custombase_url.Changes
Backend (3 files):
config.py: AddMINIMAX_API_KEY,MINIMAX_BASE_URL,MINIMAX_MODEL, andLLM_PROVIDERenv varsdependencies.py: Refactorget_llm()to support provider auto-detection (OpenAI > MiniMax) and explicit selection viaLLM_PROVIDER.env.example: Add MiniMax configuration section with documentationFrontend (2 files):
constants.ts: AddPROVIDER_PRESETSwith Base URL and description for OpenAI, MiniMax, 火山引擎, 阿里百炼ProvidersTab.tsx: Auto-populate Base URL and description when selecting a preset providerTests (2 files):
test_llm_provider.py: 18 unit tests + 2 integration tests for provider resolution, config defaults, error handling, and real MiniMax API callstest_skills_integration.py: Update real LLM integration tests to supportMINIMAX_API_KEYUsage
Set in
.env:Or explicitly select the provider:
Test Plan
pytest tests/test_llm_provider.py -k "not Integration")MINIMAX_API_KEY=... pytest tests/test_llm_provider.py -m integration)