Skip to content

feat: add MiniMax as LLM provider for film skill extraction#8

Open
octo-patch wants to merge 1 commit into
Forget-C:mainfrom
octo-patch:feature/add-minimax-provider
Open

feat: add MiniMax as LLM provider for film skill extraction#8
octo-patch wants to merge 1 commit into
Forget-C:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

Summary

Add MiniMax as an alternative LLM provider for film skill extraction. MiniMax provides an OpenAI-compatible API, enabling seamless integration via langchain-openai's ChatOpenAI with a custom base_url.

Changes

Backend (3 files):

  • config.py: Add MINIMAX_API_KEY, MINIMAX_BASE_URL, MINIMAX_MODEL, and LLM_PROVIDER env vars
  • dependencies.py: Refactor get_llm() to support provider auto-detection (OpenAI > MiniMax) and explicit selection via LLM_PROVIDER
  • .env.example: Add MiniMax configuration section with documentation

Frontend (2 files):

  • constants.ts: Add PROVIDER_PRESETS with Base URL and description for OpenAI, MiniMax, 火山引擎, 阿里百炼
  • ProvidersTab.tsx: Auto-populate Base URL and description when selecting a preset provider

Tests (2 files):

  • test_llm_provider.py: 18 unit tests + 2 integration tests for provider resolution, config defaults, error handling, and real MiniMax API calls
  • test_skills_integration.py: Update real LLM integration tests to support MINIMAX_API_KEY

Usage

Set in .env:

Or explicitly select the provider:

Test Plan

  • 18 unit tests pass (pytest tests/test_llm_provider.py -k "not Integration")
  • 2 integration tests pass with real MiniMax API (MINIMAX_API_KEY=... pytest tests/test_llm_provider.py -m integration)
  • Existing tests unaffected
  • Frontend: verify preset auto-fill in provider creation modal

@Forget-C
Copy link
Copy Markdown
Owner

Forget-C commented Apr 1, 2026

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
@octo-patch octo-patch force-pushed the feature/add-minimax-provider branch from e141960 to 02ecfaa Compare April 24, 2026 09:01
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.
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