Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,18 +69,20 @@ def generate_model_outputs_with_history(input_text, selected_models):
|
|
69 |
|
70 |
# Create a dynamic number of outputs based on model selection
|
71 |
def create_outputs(selected_models):
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
81 |
)
|
82 |
-
|
83 |
-
]
|
84 |
|
85 |
def clear_history():
|
86 |
global history
|
@@ -108,9 +110,15 @@ with gr.Blocks() as demo:
|
|
108 |
generate_button = gr.Button("Generate Outputs")
|
109 |
|
110 |
def generate_and_update(input_text, selected_models):
|
|
|
111 |
results = generate_model_outputs_with_history(input_text, selected_models)
|
112 |
output_components = create_outputs(selected_models)
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
generate_button.click(
|
116 |
fn=generate_and_update,
|
|
|
69 |
|
70 |
# Create a dynamic number of outputs based on model selection
|
71 |
def create_outputs(selected_models):
|
72 |
+
output_components = []
|
73 |
+
for model in selected_models:
|
74 |
+
output_components.append(
|
75 |
+
gr.Textbox(
|
76 |
+
label=f"Output from {model}",
|
77 |
+
interactive=False,
|
78 |
+
lines=5, # Adjust lines as needed
|
79 |
+
max_lines=10, # Max lines before scrolling
|
80 |
+
show_label=False, # Hide label in the tabbed view
|
81 |
+
elem_id=f"output_{model}", # Unique ID for styling
|
82 |
+
css=".output-window { overflow-y: auto; max-height: 200px; }" # Styling for scrollable output
|
83 |
+
)
|
84 |
)
|
85 |
+
return output_components
|
|
|
86 |
|
87 |
def clear_history():
|
88 |
global history
|
|
|
110 |
generate_button = gr.Button("Generate Outputs")
|
111 |
|
112 |
def generate_and_update(input_text, selected_models):
|
113 |
+
# Generate the output and dynamically update the outputs
|
114 |
results = generate_model_outputs_with_history(input_text, selected_models)
|
115 |
output_components = create_outputs(selected_models)
|
116 |
+
|
117 |
+
# Update the output components with the actual model outputs
|
118 |
+
for i, model in enumerate(selected_models):
|
119 |
+
output_components[i].update(value=results.get(model, "No response"))
|
120 |
+
|
121 |
+
return output_components, results # Return dynamic outputs and results
|
122 |
|
123 |
generate_button.click(
|
124 |
fn=generate_and_update,
|