mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-11 07:15:08 -05:00
Handle invalid or empty response from MusicGen model Fixes: #9145 > ⚠️ Note: This PR does not directly fix issue #9145 (failed run marked as success), but improves the validation of the URL to reduce the chances of invalid states entering the system. This is a related improvement, but not the root cause fix. ### Description During execution of the meta/musicgen model via Replicate API, the application failed with an error indicating the model returned an empty or invalid response. Although some API calls succeeded, this error showed the logic was not checking the structure and content of the result properly before processing it. PROBLEM: CONTEXT: API: Replicate MODEL: meta/musicgen:671ac645 STATUS: Failed after 3 attempts ERROR_MESSAGE: "Unexpected error: Model returned empty or invalid response" CAUSE: - The original logic did not validate result structure. - It assumed any non-null output was valid, including strings like "No output received". - This led to invalid/malformed results being passed to the frontend. ### Changes 🏗️ - Added `AIMusicGeneratorBlock` to support music generation using Meta’s MusicGen models via Replicate API. - Supports configurable inputs like prompt, model version, duration, temperature, top_k/p, and normalization. - Uses robust retry logic for reliability. - Output returns audio URL; errors return user-friendly message. BEFORE_CODE: | ``` if result and result != "No output received": yield "result", result return ``` AFTER_CODE: | ``` if result and isinstance(result, str) and result.startswith("http"): yield "result", result return ``` ### Checklist 📋 #### For code changes: - [x] Clearly listed changes in the PR description - [x] Added test plan and mock outputs - [x] Tested with various prompts and confirmed working output ### Test Plan - [x] Ran locally with valid Replicate API key - [x] Generated audio with different prompts - [x] Simulated failure to verify retry and error message --------- Co-authored-by: Abhimanyu Yadav <122007096+Abhi1992002@users.noreply.github.com> Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>