Spaces:
Running
Running
Gaurav vashistha commited on
Commit ·
53a2257
1
Parent(s): 62973c2
Fix Pydantic error: remove _api_client from GenerateVideosOperation init
Browse files
agent.py
CHANGED
|
@@ -109,17 +109,14 @@ def generate_only(prompt, path_a, path_c, job_id, style, audio, neg, guidance, m
|
|
| 109 |
config=types.GenerateVideosConfig(number_of_videos=1)
|
| 110 |
)
|
| 111 |
|
| 112 |
-
# 2. Extract ID String
|
| 113 |
op_name = op.name if hasattr(op, 'name') else str(op)
|
| 114 |
logger.info(f"Polling Job ID: {op_name}")
|
| 115 |
|
| 116 |
-
# 3. Create Valid SDK Object for Polling
|
| 117 |
-
# We
|
| 118 |
-
#
|
| 119 |
-
polling_op = types.GenerateVideosOperation(
|
| 120 |
-
name=op_name,
|
| 121 |
-
_api_client=client._api_client
|
| 122 |
-
)
|
| 123 |
|
| 124 |
start_time = time.time()
|
| 125 |
while True:
|
|
@@ -127,20 +124,19 @@ def generate_only(prompt, path_a, path_c, job_id, style, audio, neg, guidance, m
|
|
| 127 |
raise Exception("Timeout (10m).")
|
| 128 |
|
| 129 |
try:
|
| 130 |
-
# Refresh logic:
|
| 131 |
refreshed_op = client.operations.get(polling_op)
|
| 132 |
|
| 133 |
# Check status
|
| 134 |
if hasattr(refreshed_op, 'done') and refreshed_op.done:
|
| 135 |
logger.info("Generation Done.")
|
| 136 |
-
op = refreshed_op
|
| 137 |
break
|
| 138 |
|
| 139 |
except Exception as e:
|
| 140 |
logger.warning(f"Polling error: {e}")
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
pass
|
| 144 |
|
| 145 |
logger.info("Waiting for Veo...")
|
| 146 |
time.sleep(20)
|
|
|
|
| 109 |
config=types.GenerateVideosConfig(number_of_videos=1)
|
| 110 |
)
|
| 111 |
|
| 112 |
+
# 2. Extract ID String
|
| 113 |
op_name = op.name if hasattr(op, 'name') else str(op)
|
| 114 |
logger.info(f"Polling Job ID: {op_name}")
|
| 115 |
|
| 116 |
+
# 3. Create Valid SDK Object for Polling (FIXED)
|
| 117 |
+
# We initialize the object ONLY with the name.
|
| 118 |
+
# The Pydantic model will accept this, and the SDK will use it for the API call.
|
| 119 |
+
polling_op = types.GenerateVideosOperation(name=op_name)
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
start_time = time.time()
|
| 122 |
while True:
|
|
|
|
| 124 |
raise Exception("Timeout (10m).")
|
| 125 |
|
| 126 |
try:
|
| 127 |
+
# Refresh logic: Pass the valid types.GenerateVideosOperation object
|
| 128 |
refreshed_op = client.operations.get(polling_op)
|
| 129 |
|
| 130 |
# Check status
|
| 131 |
if hasattr(refreshed_op, 'done') and refreshed_op.done:
|
| 132 |
logger.info("Generation Done.")
|
| 133 |
+
op = refreshed_op
|
| 134 |
break
|
| 135 |
|
| 136 |
except Exception as e:
|
| 137 |
logger.warning(f"Polling error: {e}")
|
| 138 |
+
time.sleep(20)
|
| 139 |
+
continue
|
|
|
|
| 140 |
|
| 141 |
logger.info("Waiting for Veo...")
|
| 142 |
time.sleep(20)
|