Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -189,7 +189,14 @@ def CogMapAnalysis(text):
|
|
| 189 |
plot = None # Use None instead of empty string for non-existent objects
|
| 190 |
return formatted_result, plot
|
| 191 |
|
|
|
|
| 192 |
# Create the GUI using the 'gr' library
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
with gr.Blocks() as demo:
|
| 194 |
with gr.Row():
|
| 195 |
gr.Markdown('<div style="text-align: center;"><h1><strong>CogMApp</strong></h1></div> <div style="text-align: center;"><h3>Generate cognitive maps from text with one click!</h3></div>')
|
|
@@ -211,20 +218,25 @@ with gr.Blocks() as demo:
|
|
| 211 |
with gr.Row():
|
| 212 |
output = gr.Textbox(label="CogMap", lines=1, placeholder=" ")
|
| 213 |
cogmap_plot = gr.Plot(label="Visualization")
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
with gr.Row():
|
| 216 |
gr.Markdown("⚠️ Feel free to flag me if you find any errors. :)")
|
| 217 |
-
|
| 218 |
with gr.Row():
|
| 219 |
gr.Markdown('<p style="text-align: center; ">Demo made with ❤ by P.K. Ningrum (2024) | Contact: https://ningrumdaud.github.io/ </p>')
|
| 220 |
|
| 221 |
-
#
|
| 222 |
def load_example(example_index):
|
| 223 |
inputs.value = examples[example_index]
|
| 224 |
|
|
|
|
| 225 |
example_dropdown.change(load_example, inputs=[example_dropdown], outputs=[inputs])
|
| 226 |
submit_button.click(CogMapAnalysis, inputs=[inputs], outputs=[output, cogmap_plot])
|
|
|
|
| 227 |
|
| 228 |
if __name__ == "__main__":
|
| 229 |
demo.launch(show_api=False, share=True)
|
| 230 |
|
|
|
|
|
|
| 189 |
plot = None # Use None instead of empty string for non-existent objects
|
| 190 |
return formatted_result, plot
|
| 191 |
|
| 192 |
+
|
| 193 |
# Create the GUI using the 'gr' library
|
| 194 |
+
|
| 195 |
+
def handle_flag(text, description):
|
| 196 |
+
# Placeholder for handling flags; log to a file or send to an endpoint
|
| 197 |
+
print(f"Flagged by user: {text}, Reason: {description}")
|
| 198 |
+
return "Thank you for your feedback!"
|
| 199 |
+
|
| 200 |
with gr.Blocks() as demo:
|
| 201 |
with gr.Row():
|
| 202 |
gr.Markdown('<div style="text-align: center;"><h1><strong>CogMApp</strong></h1></div> <div style="text-align: center;"><h3>Generate cognitive maps from text with one click!</h3></div>')
|
|
|
|
| 218 |
with gr.Row():
|
| 219 |
output = gr.Textbox(label="CogMap", lines=1, placeholder=" ")
|
| 220 |
cogmap_plot = gr.Plot(label="Visualization")
|
| 221 |
+
flag_description = gr.Textbox(label="Describe the issue", lines=2, placeholder="What's wrong?")
|
| 222 |
+
flag_button = gr.Button("Flag Issue")
|
| 223 |
+
|
| 224 |
with gr.Row():
|
| 225 |
gr.Markdown("⚠️ Feel free to flag me if you find any errors. :)")
|
| 226 |
+
|
| 227 |
with gr.Row():
|
| 228 |
gr.Markdown('<p style="text-align: center; ">Demo made with ❤ by P.K. Ningrum (2024) | Contact: https://ningrumdaud.github.io/ </p>')
|
| 229 |
|
| 230 |
+
# Functions for handling inputs and examples
|
| 231 |
def load_example(example_index):
|
| 232 |
inputs.value = examples[example_index]
|
| 233 |
|
| 234 |
+
# Link functions to interface elements
|
| 235 |
example_dropdown.change(load_example, inputs=[example_dropdown], outputs=[inputs])
|
| 236 |
submit_button.click(CogMapAnalysis, inputs=[inputs], outputs=[output, cogmap_plot])
|
| 237 |
+
flag_button.click(handle_flag, inputs=[inputs, flag_description], outputs=[])
|
| 238 |
|
| 239 |
if __name__ == "__main__":
|
| 240 |
demo.launch(show_api=False, share=True)
|
| 241 |
|
| 242 |
+
|