Update app.py
Browse files
app.py
CHANGED
|
@@ -107,25 +107,38 @@ dropdown_options = ["Keine These ausgewählt",
|
|
| 107 |
'Der Flugverkehr soll höher besteuert werden.',
|
| 108 |
'Unternehmen sollen selbst entscheiden, ob sie ihren Beschäftigten das Arbeiten im Homeoffice erlauben.']
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
)
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
print("Interface up and running!")
|
| 131 |
|
|
|
|
| 107 |
'Der Flugverkehr soll höher besteuert werden.',
|
| 108 |
'Unternehmen sollen selbst entscheiden, ob sie ihren Beschäftigten das Arbeiten im Homeoffice erlauben.']
|
| 109 |
|
| 110 |
+
chatbot = gr.Chatbot(value=[[None, "Hallo mein Name ist Avah (Artificial Voting Advice Helper), deine interaktive Hilfe zum Wahl-O-Maten für die Bundestagswahl 2021. Wenn du Fragen zu Thesen der Wahlhilfe hast, wähle gerne die besagt These aus. Ansonsten kannst du mir auch unabhängig von bestimmten Thesen Fragen stellen."]], render_markdown=True)
|
| 111 |
+
|
| 112 |
+
dropdown = gr.Dropdown(choices=dropdown_options, label="Wähle eine These aus, wenn du willst")
|
| 113 |
+
|
| 114 |
+
textbox = gr.Textbox(label="Deine Frage")
|
| 115 |
+
|
| 116 |
+
# Function to handle submit button click
|
| 117 |
+
def combined_response(prompt, history, dropdown_value):
|
| 118 |
+
# Replace response with your actual response handling function
|
| 119 |
+
answer = response(prompt, history, dropdown_value)
|
| 120 |
+
return history + [[prompt, answer]]
|
| 121 |
+
|
| 122 |
+
submit_button = gr.Button("Submit")
|
| 123 |
+
|
| 124 |
+
# Set up the GUI layout
|
| 125 |
+
layout = gr.Blocks(
|
| 126 |
+
gr.Label("Title of Your Application", size="h3"), # Adding a title
|
| 127 |
+
chatbot,
|
| 128 |
+
dropdown,
|
| 129 |
+
textbox,
|
| 130 |
+
submit_button,
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
# Define the click behavior for the submit button
|
| 134 |
+
submit_button.click(
|
| 135 |
+
combined_response,
|
| 136 |
+
inputs=[textbox, chatbot, dropdown],
|
| 137 |
+
outputs=chatbot,
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
# Launch the GUI
|
| 141 |
+
layout.launch()
|
| 142 |
|
| 143 |
print("Interface up and running!")
|
| 144 |
|