Add music generation agent tool - #5
Open
octo-patch wants to merge 1 commit into
Open
Conversation
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.
Reason: The multimodal tool registry covers image, video, TTS, voice and audio mixing but has no music generation tool.
Changes
multimodal_core.py: added agenerate_musiccapability alongside the existing voice methods, reusing the current region resolution so both the global and CN/v1/music_generationendpoints are supported, together with the shared Bearer/JSON header helper._minimax_music_payload, which sendsmodel(the only mandatory field) plusprompt,lyrics,output_format,audio_setting.format,is_instrumental,lyrics_optimizerand an explicit non-streamingstreamflag. Optional fields are omitted when the caller does not supply them, andaigc_watermarkis only attached on the CN region.hexpayloads are decoded to bytes,urlpayloads are downloaded before the temporary link expires, and both are stored under/storage/audioslike the other audio tools. Audio format acceptsmp3,wavandpcm; unsupported values are rejected before any request is sent._extract_minimax_music_audio: it checksbase_resp.status_code, only readsdata.audiofor the completed status, and reports a clear message for the in-progress status and for empty audio.minimax_music.pytool class exposingminimax_music_generation, registered in the planner/ReAct flow tool list, in the multimodal branch ofagent_task_runner, and in the UI compact tool-content set so its results render like the sibling audio tools..env.example:MINIMAX_MUSIC_MODEL(defaultmusic-3.0),MINIMAX_MUSIC_OUTPUT_FORMAT,MINIMAX_MUSIC_AUDIO_FORMATandMINIMAX_MUSIC_AIGC_WATERMARK. No model name or host is hard-coded at the call site; the existingMINIMAX_REGION/MINIMAX_BASE_URLsettings continue to select the host.Checks
python3 -m pytest tests/test_minimax_music_tool.py tests/test_minimax_voice_tool.py --noconftest -q— 14 passed (10 new tests plus the 4 existing voice tests).--noconftestwas needed becausetests/conftest.pyimports the FastAPI app, whose database dependencies are not installed in this environment.python3 -m py_compileon every changed Python module./v1/music_generationwith the Bearer header, that a completedhexresponse is decoded to a stored file, that aurlresponse is downloaded and stored, and that an in-progress response fails with a readable message.New tests cover the tool schema registration, endpoint resolution for both regions, payload defaults and optional fields, the CN-only watermark field, completed / in-progress / error / empty-audio response parsing, the missing API key guard, the prompt-or-lyrics requirement, and format validation.