Spaces:
Sleeping
Sleeping
bug fixes
Browse files- gemmademo/_chat.py +18 -14
gemmademo/_chat.py
CHANGED
|
@@ -240,33 +240,37 @@ class GradioChat:
|
|
| 240 |
value=[self.current_model_name], # Default to current model
|
| 241 |
)
|
| 242 |
|
| 243 |
-
#
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
def compare_models(user_input, selected_models):
|
| 247 |
-
responses =
|
| 248 |
for model_name in selected_models:
|
| 249 |
model = self._load_model(model_name) # Load each selected model
|
| 250 |
prompt = self.prompt_manager.get_prompt(user_input=user_input)
|
| 251 |
response = model.generate_response(prompt)
|
| 252 |
-
responses
|
| 253 |
-
return responses
|
| 254 |
|
| 255 |
-
# Button to trigger comparison
|
| 256 |
-
compare_button = gr.Button("Compare Models")
|
| 257 |
compare_button.click(
|
| 258 |
fn=compare_models,
|
| 259 |
inputs=[user_input, model_comparison_dropdown],
|
| 260 |
-
outputs=
|
| 261 |
)
|
| 262 |
|
| 263 |
# Display responses for each model
|
| 264 |
-
with
|
| 265 |
-
for model_name in
|
| 266 |
-
gr.
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
) # Placeholder for model output
|
| 270 |
|
| 271 |
demo.launch()
|
| 272 |
|
|
|
|
| 240 |
value=[self.current_model_name], # Default to current model
|
| 241 |
)
|
| 242 |
|
| 243 |
+
# Create output textboxes for each model
|
| 244 |
+
output_textboxes = {}
|
| 245 |
+
for model_name in self.model_options:
|
| 246 |
+
output_textboxes[model_name] = gr.Textbox(
|
| 247 |
+
label=model_name, interactive=False
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
# Button to trigger comparison
|
| 251 |
+
compare_button = gr.Button("Compare Models")
|
| 252 |
|
| 253 |
def compare_models(user_input, selected_models):
|
| 254 |
+
responses = []
|
| 255 |
for model_name in selected_models:
|
| 256 |
model = self._load_model(model_name) # Load each selected model
|
| 257 |
prompt = self.prompt_manager.get_prompt(user_input=user_input)
|
| 258 |
response = model.generate_response(prompt)
|
| 259 |
+
responses.append(response) # Store response
|
| 260 |
+
return responses # Return list of responses
|
| 261 |
|
|
|
|
|
|
|
| 262 |
compare_button.click(
|
| 263 |
fn=compare_models,
|
| 264 |
inputs=[user_input, model_comparison_dropdown],
|
| 265 |
+
outputs=list(output_textboxes.values()), # Output to textboxes
|
| 266 |
)
|
| 267 |
|
| 268 |
# Display responses for each model
|
| 269 |
+
with gr.Row():
|
| 270 |
+
for model_name, output_box in output_textboxes.items():
|
| 271 |
+
with gr.Column():
|
| 272 |
+
gr.Markdown(f"### Output from {model_name}:")
|
| 273 |
+
output_box # Add the output textbox to the layout
|
|
|
|
| 274 |
|
| 275 |
demo.launch()
|
| 276 |
|