Spaces:
Build error
Build error
Michael Hu
commited on
Commit
·
74466cd
1
Parent(s):
52563c2
fix error
Browse files
src/application/dtos/processing_result_dto.py
CHANGED
@@ -51,7 +51,8 @@ class ProcessingResultDto:
|
|
51 |
if self.error_code:
|
52 |
valid_error_codes = [
|
53 |
'STT_ERROR', 'TRANSLATION_ERROR', 'TTS_ERROR',
|
54 |
-
'AUDIO_FORMAT_ERROR', 'VALIDATION_ERROR', 'SYSTEM_ERROR'
|
|
|
55 |
]
|
56 |
if self.error_code not in valid_error_codes:
|
57 |
raise ValueError(f"Invalid error code: {self.error_code}. Valid codes: {valid_error_codes}")
|
|
|
51 |
if self.error_code:
|
52 |
valid_error_codes = [
|
53 |
'STT_ERROR', 'TRANSLATION_ERROR', 'TTS_ERROR',
|
54 |
+
'AUDIO_FORMAT_ERROR', 'VALIDATION_ERROR', 'SYSTEM_ERROR',
|
55 |
+
'UNKNOWN_ERROR' # Add missing error code for unexpected errors
|
56 |
]
|
57 |
if self.error_code not in valid_error_codes:
|
58 |
raise ValueError(f"Invalid error code: {self.error_code}. Valid codes: {valid_error_codes}")
|
src/application/error_handling/recovery_manager.py
CHANGED
@@ -151,16 +151,14 @@ class CircuitBreaker:
|
|
151 |
self.state = CircuitBreakerState.OPEN
|
152 |
self.logger.warning(
|
153 |
f"Circuit breaker {self.name} transitioning to OPEN after failure in HALF_OPEN",
|
154 |
-
context=context
|
155 |
-
exception=exception
|
156 |
)
|
157 |
elif (self.state == CircuitBreakerState.CLOSED and
|
158 |
self.failure_count >= self.config.failure_threshold):
|
159 |
self.state = CircuitBreakerState.OPEN
|
160 |
self.logger.warning(
|
161 |
f"Circuit breaker {self.name} transitioning to OPEN after {self.failure_count} failures",
|
162 |
-
context=context
|
163 |
-
exception=exception
|
164 |
)
|
165 |
|
166 |
|
@@ -280,8 +278,7 @@ class RecoveryManager:
|
|
280 |
|
281 |
self.logger.warning(
|
282 |
f"Attempt {attempt + 1}/{config.max_attempts} failed for {func.__name__}: {e}",
|
283 |
-
context=context
|
284 |
-
exception=e
|
285 |
)
|
286 |
|
287 |
# All attempts failed
|
@@ -325,9 +322,8 @@ class RecoveryManager:
|
|
325 |
|
326 |
except Exception as e:
|
327 |
self.logger.warning(
|
328 |
-
|
329 |
-
|
330 |
-
exception=e
|
331 |
)
|
332 |
|
333 |
last_exception = e
|
@@ -353,8 +349,7 @@ class RecoveryManager:
|
|
353 |
last_exception = fallback_e
|
354 |
self.logger.warning(
|
355 |
f"Fallback {fallback_func.__name__} failed: {fallback_e}",
|
356 |
-
context=context
|
357 |
-
exception=fallback_e
|
358 |
)
|
359 |
|
360 |
# All functions failed
|
|
|
151 |
self.state = CircuitBreakerState.OPEN
|
152 |
self.logger.warning(
|
153 |
f"Circuit breaker {self.name} transitioning to OPEN after failure in HALF_OPEN",
|
154 |
+
context=context
|
|
|
155 |
)
|
156 |
elif (self.state == CircuitBreakerState.CLOSED and
|
157 |
self.failure_count >= self.config.failure_threshold):
|
158 |
self.state = CircuitBreakerState.OPEN
|
159 |
self.logger.warning(
|
160 |
f"Circuit breaker {self.name} transitioning to OPEN after {self.failure_count} failures",
|
161 |
+
context=context
|
|
|
162 |
)
|
163 |
|
164 |
|
|
|
278 |
|
279 |
self.logger.warning(
|
280 |
f"Attempt {attempt + 1}/{config.max_attempts} failed for {func.__name__}: {e}",
|
281 |
+
context=context
|
|
|
282 |
)
|
283 |
|
284 |
# All attempts failed
|
|
|
322 |
|
323 |
except Exception as e:
|
324 |
self.logger.warning(
|
325 |
+
f"Primary function {primary_func.__name__} failed, trying fallbacks",
|
326 |
+
context=context
|
|
|
327 |
)
|
328 |
|
329 |
last_exception = e
|
|
|
349 |
last_exception = fallback_e
|
350 |
self.logger.warning(
|
351 |
f"Fallback {fallback_func.__name__} failed: {fallback_e}",
|
352 |
+
context=context
|
|
|
353 |
)
|
354 |
|
355 |
# All functions failed
|
src/application/services/audio_processing_service.py
CHANGED
@@ -473,9 +473,9 @@ class AudioProcessingApplicationService:
|
|
473 |
|
474 |
# Create translation request
|
475 |
translation_request = TranslationRequest(
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
)
|
480 |
|
481 |
# Perform translation
|
|
|
473 |
|
474 |
# Create translation request
|
475 |
translation_request = TranslationRequest(
|
476 |
+
source_text=text, # text is already a TextContent object
|
477 |
+
target_language=target_language,
|
478 |
+
source_language=source_language
|
479 |
)
|
480 |
|
481 |
# Perform translation
|