lightmate commited on
Commit
7fc772b
1 Parent(s): 43ef50f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -107,7 +107,6 @@ def create_gradio_interface():
107
  return gr.Dropdown.update(choices=model_ids, value=model_ids[0])
108
 
109
  model_id_selector = gr.Dropdown(choices=model_language, value=model_language[0], label="Model ID")
110
- model_id_selector.change(update_model_ids, inputs=model_language, outputs=model_id_selector)
111
 
112
  # Set up a checkbox for enabling AWQ compression
113
  enable_awq = gr.Checkbox(value=False, label="Enable AWQ for Compression")
@@ -124,10 +123,6 @@ def create_gradio_interface():
124
  # Return the loaded model and tokenizer
125
  return ov_model, tok
126
 
127
- # Connect model selection UI to load model dynamically
128
- load_button = gr.Button("Load Model")
129
- load_button.click(load_model_on_select, inputs=[model_language, model_id, enable_awq], outputs=[gr.Textbox(label="Model Status")])
130
-
131
  # Create the Gradio chatbot interface
132
  chatbot = gr.Chatbot()
133
 
@@ -137,14 +132,23 @@ def create_gradio_interface():
137
  top_k = gr.Slider(minimum=0, maximum=50, step=1, label="Top-k", value=50)
138
  repetition_penalty = gr.Slider(minimum=0, maximum=2, step=0.1, label="Repetition Penalty", value=1.0)
139
 
140
- # Run the Gradio interface
141
- demo = gr.Interface(
142
- fn=bot,
143
- inputs=[chatbot, temperature, top_p, top_k, repetition_penalty],
144
- outputs=[chatbot],
145
- title="OpenVINO Chatbot",
146
- live=True
147
- )
 
 
 
 
 
 
 
 
 
148
 
149
  return demo
150
 
 
107
  return gr.Dropdown.update(choices=model_ids, value=model_ids[0])
108
 
109
  model_id_selector = gr.Dropdown(choices=model_language, value=model_language[0], label="Model ID")
 
110
 
111
  # Set up a checkbox for enabling AWQ compression
112
  enable_awq = gr.Checkbox(value=False, label="Enable AWQ for Compression")
 
123
  # Return the loaded model and tokenizer
124
  return ov_model, tok
125
 
 
 
 
 
126
  # Create the Gradio chatbot interface
127
  chatbot = gr.Chatbot()
128
 
 
132
  top_k = gr.Slider(minimum=0, maximum=50, step=1, label="Top-k", value=50)
133
  repetition_penalty = gr.Slider(minimum=0, maximum=2, step=0.1, label="Repetition Penalty", value=1.0)
134
 
135
+ with gr.Blocks() as demo:
136
+ # Create the Gradio components and add them to the Blocks context
137
+ model_id_selector.change(update_model_ids, inputs=model_language, outputs=model_id_selector)
138
+ load_button = gr.Button("Load Model")
139
+ load_button.click(load_model_on_select, inputs=[model_language, model_id, enable_awq], outputs=[gr.Textbox(label="Model Status")])
140
+
141
+ # Set up the chatbot UI with all the required components
142
+ gr.Row([model_id_selector, enable_awq]) # Arrange the dropdowns and checkbox in a row
143
+ gr.Row([load_button]) # Add the button below the inputs
144
+ gr.Row([chatbot]) # Add the chatbot output
145
+
146
+ # Parameters for generation
147
+ gr.Row([temperature, top_p, top_k, repetition_penalty]) # Add sliders in a row
148
+
149
+ # Define bot function and run the interface
150
+ demo.queue() # This is used to queue inputs and outputs, handling concurrent generation calls
151
+ demo.launch(debug=True, share=True) # For public access
152
 
153
  return demo
154