fix(speech-generation): return correct finish reason type in Google provider#102
Conversation
PR Review: Fix Google Speech Generation Finish Reason TypeSummaryThis PR correctly fixes a Pydantic validation error by overriding ✅ Code Quality & Best PracticesExcellent:
Code Style:
✅ Bug Fix ValidationRoot Cause Analysis:
Fix Correctness:
🔍 Potential Issues & SuggestionsMinor Consideration: def _parse_finish_reason(
self, response_data: dict[str, Any]
) -> SpeechGenerationFinishReason:
"""Parse finish reason from response."""
finish_reason = super()._parse_finish_reason(response_data)
return SpeechGenerationFinishReason(reason=finish_reason.reason if finish_reason else None)However, this is not required since:
⚡ PerformanceNo concerns:
🔒 SecurityNo concerns:
🧪 Test CoverageCurrent State:
Recommendation:
Example test structure: def test_parse_finish_reason_returns_correct_type(client):
response_data = {}
result = client._parse_finish_reason(response_data)
assert isinstance(result, SpeechGenerationFinishReason)
assert result.reason is None # GoogleCloudTTS returns NoneHowever, since the integration test already exercises this code path and the fix is minimal, this is optional and can be addressed in a future PR. ✅ Overall AssessmentScore: 9.5/10 This is a well-crafted, minimal fix that:
Recommendation: Approve and merge 🚀 The only minor improvement would be adding a dedicated unit test, but this is not blocking given the existing integration test coverage. |
Override _parse_finish_reason to return SpeechGenerationFinishReason instead of base FinishReason class, fixing Pydantic validation error in integration tests.