Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,11 @@ MODEL_OPTIONS = [
|
|
21 |
"liquid/lfm-40b:free"
|
22 |
]
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
results = {}
|
26 |
for model in selected_models:
|
27 |
response = requests.post(
|
@@ -52,17 +56,28 @@ def generate_comparisons(input_text, selected_models):
|
|
52 |
else:
|
53 |
results[model] = f"Error: {response.status_code}, {response.text}"
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
# Create Gradio interface with multiple model selection
|
58 |
iface = gr.Interface(
|
59 |
-
fn=
|
60 |
inputs=[
|
61 |
gr.Textbox(lines=2, label="Input Text", placeholder="Enter your query here"),
|
62 |
gr.CheckboxGroup(choices=MODEL_OPTIONS, label="Select Models", value=[MODEL_OPTIONS[0]])
|
63 |
],
|
64 |
-
outputs=
|
65 |
-
|
|
|
|
|
|
|
66 |
)
|
67 |
|
68 |
iface.launch()
|
|
|
21 |
"liquid/lfm-40b:free"
|
22 |
]
|
23 |
|
24 |
+
# History storage
|
25 |
+
history = []
|
26 |
+
|
27 |
+
def generate_comparisons_with_history(input_text, selected_models):
|
28 |
+
global history
|
29 |
results = {}
|
30 |
for model in selected_models:
|
31 |
response = requests.post(
|
|
|
56 |
else:
|
57 |
results[model] = f"Error: {response.status_code}, {response.text}"
|
58 |
|
59 |
+
# Add input and results to history
|
60 |
+
history_entry = {
|
61 |
+
"input": input_text,
|
62 |
+
"selected_models": selected_models,
|
63 |
+
"outputs": results
|
64 |
+
}
|
65 |
+
history.append(history_entry)
|
66 |
+
|
67 |
+
return results, history
|
68 |
|
69 |
+
# Create Gradio interface with multiple model selection and history
|
70 |
iface = gr.Interface(
|
71 |
+
fn=generate_comparisons_with_history,
|
72 |
inputs=[
|
73 |
gr.Textbox(lines=2, label="Input Text", placeholder="Enter your query here"),
|
74 |
gr.CheckboxGroup(choices=MODEL_OPTIONS, label="Select Models", value=[MODEL_OPTIONS[0]])
|
75 |
],
|
76 |
+
outputs=[
|
77 |
+
gr.JSON(label="Model Comparisons"),
|
78 |
+
gr.JSON(label="History")
|
79 |
+
],
|
80 |
+
title="Compare Outputs and Maintain History"
|
81 |
)
|
82 |
|
83 |
iface.launch()
|