MySafeCode commited on
Commit
daf51c5
·
verified ·
1 Parent(s): dd12853

Update lapi.py

Browse files
Files changed (1) hide show
  1. lapi.py +81 -79
lapi.py CHANGED
@@ -185,8 +185,8 @@ def get_raw_json():
185
  except:
186
  return {"error": "Could not fetch io.json"}
187
 
188
- # Interface
189
- with gr.Blocks(title="BytePlus Video Generator", theme=gr.themes.Soft()) as demo:
190
 
191
  gr.Markdown("# 🎥 BytePlus Video Generator")
192
 
@@ -196,87 +196,85 @@ with gr.Blocks(title="BytePlus Video Generator", theme=gr.themes.Soft()) as demo
196
  else:
197
  gr.Markdown("❌ **API Key:** Not configured - please add 'Key' secret")
198
 
199
- # Create tabs
200
- tab1, tab2 = gr.Tabs().render()
201
-
202
- with tab1:
203
- gr.Markdown("### Generate Video")
204
- with gr.Row():
205
- with gr.Column():
206
- image_input = gr.Image(
207
- label="Upload Starting Image",
208
- type="filepath",
209
- height=300
210
- )
211
-
212
- shot_type = gr.Dropdown(
213
- choices=list(DEFAULT_PROMPTS.keys()),
214
- label="🎬 Shot Type",
215
- value="Cinematic Nature"
216
- )
217
-
218
- prompt = gr.Textbox(
219
- label="📝 Custom Prompt",
220
- lines=3,
221
- value=DEFAULT_PROMPTS["Cinematic Nature"]
222
- )
223
-
224
- shot_type.change(fn=update_prompt, inputs=shot_type, outputs=prompt)
225
 
226
- generate_btn = gr.Button("🚀 Generate Video", variant="primary", size="lg")
 
 
227
 
228
- with gr.Column():
229
- status = gr.Textbox(label="Status", lines=6)
230
- video_output = gr.Video(label="Generated Video")
 
 
 
 
 
 
231
 
232
- # Quick shot buttons
233
- gr.Markdown("### Quick Shot Select")
234
- with gr.Row():
235
- gr.Button("🏔️ Nature").click(fn=lambda: "Cinematic Nature", outputs=shot_type)
236
- gr.Button("🌃 City").click(fn=lambda: "Urban Exploration", outputs=shot_type)
237
- gr.Button("🏎️ Action").click(fn=lambda: "Action Sequence", outputs=shot_type)
238
- gr.Button("🎨 Abstract").click(fn=lambda: "Abstract Art", outputs=shot_type)
239
- gr.Button("🦁 Wildlife").click(fn=lambda: "Wildlife Documentary", outputs=shot_type)
240
- gr.Button("⛷️ Sports").click(fn=lambda: "Sports Highlight", outputs=shot_type)
241
-
242
- with tab2:
243
- gr.Markdown("### 🔧 Manual Polling & Debug")
244
-
245
- with gr.Row():
246
- with gr.Column():
247
- gr.Markdown("#### Poll Specific Task")
248
- task_id_input = gr.Textbox(
249
- label="Task ID",
250
- placeholder="Enter task ID (cgt-...)"
251
- )
252
- poll_btn = gr.Button("🔄 Poll Now", variant="primary")
253
- poll_result = gr.Textbox(label="Poll Result", lines=10)
254
-
255
- poll_btn.click(
256
- fn=manual_poll,
257
- inputs=task_id_input,
258
- outputs=poll_result
259
- )
260
 
261
- with gr.Column():
262
- gr.Markdown("#### Current io.json")
263
- refresh_btn = gr.Button("🔄 Refresh io.json", variant="secondary")
264
- raw_json = gr.JSON(label="io.json Contents")
 
 
 
 
 
 
 
 
 
 
 
265
 
266
- refresh_btn.click(
267
- fn=get_raw_json,
268
- outputs=raw_json
269
- )
270
-
271
- gr.Markdown("""
272
- ### 📝 Instructions
273
- 1. Copy a task ID from above (like `cgt-20260217072358-hszt9`)
274
- 2. Paste it in the Task ID field
275
- 3. Click "Poll Now" to force an update
276
- 4. Check io.json to see if status changed
277
-
278
- This manually triggers the proxy to poll BytePlus for updates!
279
- """)
 
 
 
 
 
280
 
281
  # Connect generate button
282
  generate_btn.click(
@@ -286,4 +284,8 @@ with gr.Blocks(title="BytePlus Video Generator", theme=gr.themes.Soft()) as demo
286
  )
287
 
288
  if __name__ == "__main__":
289
- demo.launch(server_name="0.0.0.0")
 
 
 
 
 
185
  except:
186
  return {"error": "Could not fetch io.json"}
187
 
188
+ # Create the interface WITHOUT theme in Blocks constructor
189
+ with gr.Blocks(title="BytePlus Video Generator") as demo:
190
 
191
  gr.Markdown("# 🎥 BytePlus Video Generator")
192
 
 
196
  else:
197
  gr.Markdown("❌ **API Key:** Not configured - please add 'Key' secret")
198
 
199
+ # Create tabs properly in Gradio 6.5.1
200
+ with gr.Tabs():
201
+ with gr.TabItem("🎬 Generate Video"):
202
+ with gr.Row():
203
+ with gr.Column():
204
+ image_input = gr.Image(
205
+ label="Upload Starting Image",
206
+ type="filepath",
207
+ height=300
208
+ )
209
+
210
+ shot_type = gr.Dropdown(
211
+ choices=list(DEFAULT_PROMPTS.keys()),
212
+ label="🎬 Shot Type",
213
+ value="Cinematic Nature"
214
+ )
215
+
216
+ prompt = gr.Textbox(
217
+ label="📝 Custom Prompt",
218
+ lines=3,
219
+ value=DEFAULT_PROMPTS["Cinematic Nature"]
220
+ )
221
+
222
+ shot_type.change(fn=update_prompt, inputs=shot_type, outputs=prompt)
223
+
224
+ generate_btn = gr.Button("🚀 Generate Video", variant="primary", size="lg")
225
 
226
+ with gr.Column():
227
+ status = gr.Textbox(label="Status", lines=6)
228
+ video_output = gr.Video(label="Generated Video")
229
 
230
+ # Quick shot buttons
231
+ gr.Markdown("### Quick Shot Select")
232
+ with gr.Row():
233
+ gr.Button("🏔️ Nature").click(fn=lambda: "Cinematic Nature", outputs=shot_type)
234
+ gr.Button("🌃 City").click(fn=lambda: "Urban Exploration", outputs=shot_type)
235
+ gr.Button("🏎️ Action").click(fn=lambda: "Action Sequence", outputs=shot_type)
236
+ gr.Button("🎨 Abstract").click(fn=lambda: "Abstract Art", outputs=shot_type)
237
+ gr.Button("🦁 Wildlife").click(fn=lambda: "Wildlife Documentary", outputs=shot_type)
238
+ gr.Button("⛷️ Sports").click(fn=lambda: "Sports Highlight", outputs=shot_type)
239
 
240
+ with gr.TabItem("🔧 Manual Polling"):
241
+ gr.Markdown("### 🔧 Manual Polling & Debug")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
+ with gr.Row():
244
+ with gr.Column():
245
+ gr.Markdown("#### Poll Specific Task")
246
+ task_id_input = gr.Textbox(
247
+ label="Task ID",
248
+ placeholder="Enter task ID (cgt-...)"
249
+ )
250
+ poll_btn = gr.Button("🔄 Poll Now", variant="primary")
251
+ poll_result = gr.Textbox(label="Poll Result", lines=10)
252
+
253
+ poll_btn.click(
254
+ fn=manual_poll,
255
+ inputs=task_id_input,
256
+ outputs=poll_result
257
+ )
258
 
259
+ with gr.Column():
260
+ gr.Markdown("#### Current io.json")
261
+ refresh_btn = gr.Button("🔄 Refresh io.json", variant="secondary")
262
+ raw_json = gr.JSON(label="io.json Contents")
263
+
264
+ refresh_btn.click(
265
+ fn=get_raw_json,
266
+ outputs=raw_json
267
+ )
268
+
269
+ gr.Markdown("""
270
+ ### 📝 Instructions
271
+ 1. Copy a task ID from above (like `cgt-20260217072358-hszt9`)
272
+ 2. Paste it in the Task ID field
273
+ 3. Click "Poll Now" to force an update
274
+ 4. Check io.json to see if status changed
275
+
276
+ This manually triggers the proxy to poll BytePlus for updates!
277
+ """)
278
 
279
  # Connect generate button
280
  generate_btn.click(
 
284
  )
285
 
286
  if __name__ == "__main__":
287
+ # Move theme to launch()
288
+ demo.launch(
289
+ server_name="0.0.0.0",
290
+ theme=gr.themes.Soft()
291
+ )