Nyandwi commited on
Commit
9981de9
·
verified ·
1 Parent(s): 3a34054

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -12
app.py CHANGED
@@ -64,19 +64,25 @@ external_log_dir = "./logs"
64
  LOGDIR = external_log_dir
65
  VOTEDIR = "./votes"
66
 
 
 
 
 
67
 
68
- def install_gradio_4_35_0():
69
- current_version = gr.__version__
70
- if current_version != "4.35.0":
71
- print(f"Current Gradio version: {current_version}")
72
- print("Installing Gradio 4.35.0...")
73
- subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==4.35.0", "--force-reinstall"])
74
- print("Gradio 4.35.0 installed successfully.")
75
- else:
76
- print("Gradio 4.35.0 is already installed.")
 
 
77
 
78
  # Call the function to install Gradio 4.35.0 if needed
79
- install_gradio_4_35_0()
80
 
81
  import gradio as gr
82
  import gradio_client
@@ -487,7 +493,8 @@ with gr.Blocks(
487
  label="Max output tokens",
488
  )
489
  with gr.Row():
490
- chatbot = gr.Chatbot([], elem_id="Pangea", bubble_full_width=False, height=750)
 
491
 
492
  with gr.Row():
493
  upvote_btn = gr.Button(value="👍 Upvote", interactive=True)
@@ -734,4 +741,13 @@ if __name__ == "__main__":
734
  device = (torch.device("cuda") if torch.cuda.is_available() else torch.device("mps") if getattr(torch.backends, "mps", None) and torch.backends.mps.is_available() else torch.device("cpu"))
735
  model = model.to(device)
736
  chat_image_num = 0
737
- demo.launch()
 
 
 
 
 
 
 
 
 
 
64
  LOGDIR = external_log_dir
65
  VOTEDIR = "./votes"
66
 
67
+ import gradio, uvicorn, websockets, pathlib
68
+ print("Gradio:", gradio.__version__)
69
+ print("uvicorn:", uvicorn.__version__)
70
+ print("websockets:", websockets.__version__)
71
 
72
+
73
+
74
+ # def install_gradio_4_35_0():
75
+ # current_version = gr.__version__
76
+ # if current_version != "4.35.0":
77
+ # print(f"Current Gradio version: {current_version}")
78
+ # print("Installing Gradio 4.35.0...")
79
+ # subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==4.35.0", "--force-reinstall"])
80
+ # print("Gradio 4.35.0 installed successfully.")
81
+ # else:
82
+ # print("Gradio 4.35.0 is already installed.")
83
 
84
  # Call the function to install Gradio 4.35.0 if needed
85
+ # install_gradio_4_35_0()
86
 
87
  import gradio as gr
88
  import gradio_client
 
493
  label="Max output tokens",
494
  )
495
  with gr.Row():
496
+ # chatbot = gr.Chatbot([], elem_id="Pangea", bubble_full_width=False, height=750)
497
+ chatbot = gr.Chatbot([], elem_id="Pangea", type="tuple", height=750)
498
 
499
  with gr.Row():
500
  upvote_btn = gr.Button(value="👍 Upvote", interactive=True)
 
741
  device = (torch.device("cuda") if torch.cuda.is_available() else torch.device("mps") if getattr(torch.backends, "mps", None) and torch.backends.mps.is_available() else torch.device("cpu"))
742
  model = model.to(device)
743
  chat_image_num = 0
744
+ # demo.launch()
745
+ demo.queue()
746
+
747
+ # Spaces sets $PORT; Gradio also respects GRADIO_SERVER_PORT if you prefer.
748
+ port = int(os.environ.get("PORT", os.environ.get("GRADIO_SERVER_PORT", 7860)))
749
+
750
+ demo.launch(
751
+ server_name="0.0.0.0",
752
+ server_port=port,
753
+ )