yukee1992 commited on
Commit
a1a6ae3
·
verified ·
1 Parent(s): a21ab32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -396,7 +396,7 @@ def update_job_status(job_id: str, status: JobStatus, progress: int, message: st
396
  try:
397
  callback_url = request_data["callback_url"]
398
 
399
- # Simple callback data
400
  callback_data = {
401
  "job_id": job_id,
402
  "status": status.value,
@@ -405,16 +405,33 @@ def update_job_status(job_id: str, status: JobStatus, progress: int, message: st
405
  "story_title": request_data["story_title"],
406
  "total_scenes": len(request_data["scenes"]),
407
  "timestamp": time.time(),
408
- "source": "huggingface-storybook-generator"
 
409
  }
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  # Add result data for completed jobs
412
  if status == JobStatus.COMPLETED and result:
413
  callback_data["result"] = {
414
  "total_pages": result.get("total_pages", 0),
415
  "generation_time": result.get("generation_time", 0),
416
  "oci_bucket_url": result.get("oci_bucket_url", ""),
417
- "pages_generated": result.get("generated_pages", 0)
 
418
  }
419
 
420
  headers = {
@@ -422,6 +439,9 @@ def update_job_status(job_id: str, status: JobStatus, progress: int, message: st
422
  'User-Agent': 'Storybook-Generator/1.0'
423
  }
424
 
 
 
 
425
  response = requests.post(
426
  callback_url,
427
  json=callback_data,
 
396
  try:
397
  callback_url = request_data["callback_url"]
398
 
399
+ # Enhanced callback data with scene information
400
  callback_data = {
401
  "job_id": job_id,
402
  "status": status.value,
 
405
  "story_title": request_data["story_title"],
406
  "total_scenes": len(request_data["scenes"]),
407
  "timestamp": time.time(),
408
+ "source": "huggingface-storybook-generator",
409
+ "estimated_time_remaining": calculate_remaining_time(job_id, progress)
410
  }
411
 
412
+ # Add current scene info for processing jobs
413
+ if status == JobStatus.PROCESSING:
414
+ # Calculate current scene based on progress
415
+ total_scenes = len(request_data["scenes"])
416
+ if total_scenes > 0:
417
+ current_scene = min((progress - 5) // (90 // total_scenes) + 1, total_scenes)
418
+ callback_data["current_scene"] = current_scene
419
+ callback_data["total_scenes"] = total_scenes
420
+
421
+ # Add scene description if available
422
+ if current_scene <= len(request_data["scenes"]):
423
+ scene_data = request_data["scenes"][current_scene-1]
424
+ callback_data["scene_description"] = scene_data.get("visual", "")[:100] + "..."
425
+ callback_data["current_prompt"] = scene_data.get("visual", "")
426
+
427
  # Add result data for completed jobs
428
  if status == JobStatus.COMPLETED and result:
429
  callback_data["result"] = {
430
  "total_pages": result.get("total_pages", 0),
431
  "generation_time": result.get("generation_time", 0),
432
  "oci_bucket_url": result.get("oci_bucket_url", ""),
433
+ "pages_generated": result.get("generated_pages", 0),
434
+ "consistency_seed": result.get("consistency_seed", None)
435
  }
436
 
437
  headers = {
 
439
  'User-Agent': 'Storybook-Generator/1.0'
440
  }
441
 
442
+ print(f"📢 Sending callback to: {callback_url}")
443
+ print(f"📊 Callback data: {json.dumps(callback_data, indent=2)}")
444
+
445
  response = requests.post(
446
  callback_url,
447
  json=callback_data,