fix(api): handle reasoning and generating polling statuses
BFL's get_result reference documents two intermediate statuses the Status enum was missing: Reasoning and Generating (returned by FLUX 3 tasks). Status(status) raised ValueError on them, which landed in the JSON-parsing error handler with a misleading log line. Both now retry like Pending, and the retry log prints the actual status.
This commit is contained in:
+2
-2
@@ -107,8 +107,8 @@ class BaseFlux:
|
||||
if Status(status) == Status.READY:
|
||||
print(f"[BFL] Task {task_id} ready after {elapsed:.1f}s — downloading image")
|
||||
return self.process_result(result, output_format=output_format)
|
||||
elif Status(status) == Status.PENDING:
|
||||
print(f"[BFL] Attempt {attempt}/{max_attempts}: pending — retrying in 5s")
|
||||
elif Status(status) in [Status.PENDING, Status.REASONING, Status.GENERATING]:
|
||||
print(f"[BFL] Attempt {attempt}/{max_attempts}: {status} — retrying in 5s")
|
||||
attempt += 1
|
||||
if attempt <= max_attempts:
|
||||
time.sleep(5)
|
||||
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Status(Enum):
|
||||
TASK_NOT_FOUND = "Task not found"
|
||||
PENDING = "Pending"
|
||||
REASONING = "Reasoning"
|
||||
GENERATING = "Generating"
|
||||
REQUEST_MODERATED = "Request Moderated"
|
||||
CONTENT_MODERATED = "Content Moderated"
|
||||
READY = "Ready"
|
||||
ERROR = "Error"
|
||||
ERROR = "Error"
|
||||
|
||||
Reference in New Issue
Block a user