Update app.py
Browse files
app.py
CHANGED
@@ -40,6 +40,7 @@ def respond(
|
|
40 |
|
41 |
return response
|
42 |
|
|
|
43 |
# CSS for styling the interface
|
44 |
css = """
|
45 |
body {
|
@@ -60,7 +61,8 @@ body {
|
|
60 |
|
61 |
# Define the button click handler to hide the dropdown
|
62 |
def on_button_click(model_name, message, history, system_message, dropdown_state):
|
63 |
-
|
|
|
64 |
|
65 |
# Define the Gradio interface with buttons and model selection
|
66 |
demo = gr.Interface(
|
@@ -71,11 +73,11 @@ demo = gr.Interface(
|
|
71 |
gr.Button("Chatgpt"),
|
72 |
gr.Button("Llama"),
|
73 |
gr.Button("Claude"),
|
74 |
-
gr.State() #
|
75 |
],
|
76 |
outputs=[
|
77 |
"text", # For the model's response
|
78 |
-
gr.
|
79 |
],
|
80 |
css=css, # Pass the custom CSS here
|
81 |
)
|
|
|
40 |
|
41 |
return response
|
42 |
|
43 |
+
|
44 |
# CSS for styling the interface
|
45 |
css = """
|
46 |
body {
|
|
|
61 |
|
62 |
# Define the button click handler to hide the dropdown
|
63 |
def on_button_click(model_name, message, history, system_message, dropdown_state):
|
64 |
+
# Close the dropdown by setting the state to False
|
65 |
+
return respond(model_name, message, history, system_message), gr.update(visible=False)
|
66 |
|
67 |
# Define the Gradio interface with buttons and model selection
|
68 |
demo = gr.Interface(
|
|
|
73 |
gr.Button("Chatgpt"),
|
74 |
gr.Button("Llama"),
|
75 |
gr.Button("Claude"),
|
76 |
+
gr.State(value=False), # Add state to track visibility of the dropdown
|
77 |
],
|
78 |
outputs=[
|
79 |
"text", # For the model's response
|
80 |
+
gr.State(value=False), # This should be the state output, which tracks visibility
|
81 |
],
|
82 |
css=css, # Pass the custom CSS here
|
83 |
)
|