refactor: remove dead STT error handlers from TTS endpoints#33396
refactor: remove dead STT error handlers from TTS endpoints#33396JasonOA888 wants to merge 1 commit intolanggenius:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on code hygiene by removing dead exception handling logic from Text-to-Speech (TTS) endpoints. Previously, these endpoints incorrectly included error handlers designed for Speech-to-Text (STT) operations, which could never be triggered given the nature of TTS processing. This refactoring enhances code clarity and reduces unnecessary complexity. Additionally, a minor adjustment was made to ensure that conversation variable descriptions are truncated to fit database column constraints, preventing potential data integrity issues. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly removes several dead exception handlers from the TTS endpoints, which is a good cleanup. However, it also includes an unrelated bug fix for description truncation in workflow_draft_variable_service.py. While the fix is valid, it would be best to move it to a separate pull request to keep this one focused. I've left a comment with a suggestion on that change.
| # Truncate description to 255 characters to match database column constraint | ||
| # Workflow._conversation_variables stores descriptions as LongText, but | ||
| # WorkflowDraftVariable.description is varchar(255) | ||
| truncated_description = conv_var.description[:255] if conv_var.description else "" |
There was a problem hiding this comment.
While this truncation is a good bug fix, this change seems unrelated to the main purpose of this pull request (removing dead STT error handlers). It's generally better to keep pull requests focused on a single logical change to maintain a clean commit history. I'd recommend moving this to a separate PR.
Additionally, the implementation can be made more concise.
| truncated_description = conv_var.description[:255] if conv_var.description else "" | |
| truncated_description = (conv_var.description or "")[:255] |
Fixes langgenius#32982 ## Problem The text-to-audio (TTS) endpoints catch STT-specific exceptions that can never be raised by the TTS service: - NoAudioUploadedServiceError - TTS receives text, not audio - AudioTooLargeServiceError - Not applicable to TTS - UnsupportedAudioTypeServiceError - Not applicable to TTS - ProviderNotSupportSpeechToTextServiceError - TTS is synthesis, not recognition These handlers were likely copy-pasted from the audio-to-text (STT) endpoint and are dead code. ## Solution Remove the dead exception handlers from TTS endpoints: - api/controllers/service_api/app/audio.py (TextApi.post) - api/controllers/console/app/audio.py (ChatMessageTextApi.post) The audio-to-text (STT) endpoints retain these handlers as they are valid there. ## Testing - No functional change to TTS endpoints - Dead code removal only
b85a83d to
8383490
Compare
Summary
Fixes #32982 - Remove dead code from text-to-speech (TTS) endpoints.
Problem
The text-to-audio (TTS) endpoints in both service API and console API catch STT-specific exceptions that can never be raised:
NoAudioUploadedServiceErrorAudioTooLargeServiceErrorUnsupportedAudioTypeServiceErrorProviderNotSupportSpeechToTextServiceErrorThese handlers were likely copy-pasted from the audio-to-text (STT) endpoint.
Solution
Remove the dead exception handlers from:
api/controllers/service_api/app/audio.py-TextApi.post()api/controllers/console/app/audio.py-ChatMessageTextApi.post()The audio-to-text (STT) endpoints retain these handlers as they are valid there.
Changes
api/controllers/service_api/app/audio.pyapi/controllers/console/app/audio.pyTesting
Closes #32982