feat: retry async image tasks
This commit is contained in:
+13
-10
@@ -246,6 +246,7 @@ def execute_precharged_generation(
|
||||
precharged: PrechargedGeneration,
|
||||
*,
|
||||
image_url_builder: ImageUrlBuilder | None = None,
|
||||
refund_on_failure: bool = True,
|
||||
) -> GenerationResult:
|
||||
prepared = precharged.prepared
|
||||
try:
|
||||
@@ -259,22 +260,24 @@ def execute_precharged_generation(
|
||||
image_url_builder=image_url_builder,
|
||||
)
|
||||
except AiCapabilityError as exc:
|
||||
refund_call_points(
|
||||
precharged.call_record,
|
||||
error_message=str(exc),
|
||||
reason=f"Provider rejected the {prepared.operation_type} request.",
|
||||
)
|
||||
if refund_on_failure:
|
||||
refund_call_points(
|
||||
precharged.call_record,
|
||||
error_message=str(exc),
|
||||
reason=f"Provider rejected the {prepared.operation_type} request.",
|
||||
)
|
||||
raise ApiRequestError(
|
||||
"bad_request",
|
||||
"请求参数不支持当前模型",
|
||||
status.HTTP_400_BAD_REQUEST,
|
||||
) from exc
|
||||
except Exception as exc:
|
||||
refund_call_points(
|
||||
precharged.call_record,
|
||||
error_message=str(exc),
|
||||
reason=f"Upstream {prepared.operation_type} generation failed.",
|
||||
)
|
||||
if refund_on_failure:
|
||||
refund_call_points(
|
||||
precharged.call_record,
|
||||
error_message=str(exc),
|
||||
reason=f"Upstream {prepared.operation_type} generation failed.",
|
||||
)
|
||||
raise upstream_error(exc) from exc
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user