Fix validation errors and runtime exceptions in podcast generation workflow#24
Open
YosiElias wants to merge 6 commits intoNVIDIA-AI-Blueprints:mainfrom
Open
Fix validation errors and runtime exceptions in podcast generation workflow#24YosiElias wants to merge 6 commits intoNVIDIA-AI-Blueprints:mainfrom
YosiElias wants to merge 6 commits intoNVIDIA-AI-Blueprints:mainfrom
Conversation
Prompt said minutes, pydantic model expected seconds as int. This caused validation errors when parsing structured output.
…d transcript files Signed-off-by: Yossi Elias <yelias@redhat.com>
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.
Fix validation errors and runtime exceptions in podcast generation workflow
This PR addresses six bugs that cause validation errors and runtime exceptions during podcast generation. Each fix resolves a specific failure point that prevents successful podcast creation.
Note: Each fix is implemented as a separate commit for easier review.
Bug Fixes
1. Fix Pydantic validation error from missing scratchpad field
Files:
frontend/shared/shared/podcast_types.py,shared/shared/podcast_types.pyBug: The
Conversation.scratchpadfield was required but not instructed to be provided in the prompt, causing Pydantic validation errors.Impact: Podcast generation fails with validation error when scratchpad is omitted.
Solution: Added empty string default (
scratchpad: str = "") to make the field optional.2. Fix duration unit mismatch between prompt and Pydantic model
Files:
services/AgentService/podcast_prompts.pyBug: The prompt instructed the LLM to output duration in minutes, but the Pydantic model expected integer seconds. This type mismatch caused validation failures.
Impact: Every outline generation fails with validation error due to incompatible duration units.
Solution: Updated prompt to clearly specify duration must be integer seconds, matching the model's expectation.
3. Fix schema regeneration that discards filename enum
Files:
services/AgentService/podcast_flow.pyBug: Code dynamically added filename enum to schema, then immediately regenerated the schema, discarding the enum modifications.
Impact: Schema regeneration overrides the dynamic modifications, causing the filename enum constraints to not be applied.
Solution: Removed the redundant
schema = PodcastOutline.model_json_schema()call that was overriding the enum modifications.4. Align models.json with llmmanager.py defaults
Files:
models.jsonBug: Configuration mismatch between
models.jsonand hardcoded defaults inllmmanager.py:llama-3.1-8b-instruct, code defaults tollama-3.1-70b-instructllama-3.1-70b-instruct, code defaults tollama-3.1-405b-instructImpact: Using the 8B model for JSON generation causes frequent Pydantic validation errors due to lower model capacity (NVIDIA hosted models).
Solution: Updated
models.jsonto match the code defaults, ensuring consistent model usage.5. Fix TypeError when recipient field is None
Files:
frontend/__main__.pyBug: The
recipientfield isNoneby default unless the user clicks the accordion. Code attemptslen(recipient)without null check, causingTypeError: object of type 'NoneType' has no len().Impact: Podcast generation fails immediately unless user explicitly opens the recipient accordion (even if not providing a value).
Solution: Added null coalescing:
recipient = recipient or ""to handle the default None case.6. Fix Gradio InvalidPathError for audio and transcript files
Files:
frontend/__main__.pyBug: Gradio raises
InvalidPathErrorwhen attempting to serve generated audio and transcript files.Impact: Users cannot download generated podcast audio or transcripts through the web UI.
Solution: Resolved path handling to ensure Gradio can correctly serve generated files.
Testing
All fixes have been tested and verified to resolve their respective issues.
Impact Summary
These fixes enable successful end-to-end podcast generation by resolving:
Without these fixes, the podcast generation workflow fails at multiple points.