anushkap01patidar commited on
Commit
a80913a
·
1 Parent(s): 075b97e

Fix Gradio compatibility: Downgrade to 4.43.0, simplify interface, fix Hugging Face Spaces deployment

Browse files
Files changed (2) hide show
  1. app.py +14 -10
  2. requirements.txt +1 -1
app.py CHANGED
@@ -291,14 +291,14 @@ with gr.Blocks(css=css, title="Research Draft Generator") as demo:
291
  session = gr.State({})
292
 
293
  # Wire actions
294
- # Left preview shows outline initially; right preview mirrors it. After approval, both show draft (right replaces outline visually)
295
- def mirror_left_to_right(md):
296
- return gr.update(visible=md["visible"], value=md["value"]) if isinstance(md, dict) else md
297
-
298
  def toggle_feedback_controls(state):
299
- enabled = bool(state and state.get("thread_id"))
300
- upd = gr.update(interactive=enabled)
301
- return upd, upd, upd, upd
 
 
 
 
302
 
303
  start_btn.click(run_workflow, inputs=[topic], outputs=[info, session, right_preview, pdf_file, right_header]).then(
304
  toggle_feedback_controls, inputs=[session], outputs=[feedback, approve, revise, reject]
@@ -314,6 +314,10 @@ with gr.Blocks(css=css, title="Research Draft Generator") as demo:
314
  )
315
 
316
 
317
- if __name__ == "__main__":
318
- port = int(os.getenv("PORT", 7860))
319
- demo.queue().launch(server_name="0.0.0.0", server_port=port)
 
 
 
 
 
291
  session = gr.State({})
292
 
293
  # Wire actions
 
 
 
 
294
  def toggle_feedback_controls(state):
295
+ try:
296
+ enabled = bool(state and state.get("thread_id"))
297
+ upd = gr.update(interactive=enabled)
298
+ return upd, upd, upd, upd
299
+ except:
300
+ # Fallback if state is corrupted
301
+ return gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)
302
 
303
  start_btn.click(run_workflow, inputs=[topic], outputs=[info, session, right_preview, pdf_file, right_header]).then(
304
  toggle_feedback_controls, inputs=[session], outputs=[feedback, approve, revise, reject]
 
314
  )
315
 
316
 
317
+ # Launch the app for Hugging Face Spaces
318
+ port = int(os.getenv("PORT", 7860))
319
+ demo.launch(
320
+ server_name="0.0.0.0",
321
+ server_port=port,
322
+ show_error=True
323
+ )
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- gradio==5.43.1
2
  transformers
3
  torch
4
  numpy
 
1
+ gradio==4.43.0
2
  transformers
3
  torch
4
  numpy