Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Fix: Basic output function
Browse files
app.py
CHANGED
|
@@ -1,7 +1,20 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def predict(review: str, display_mode: str):
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
iface = gr.Interface(
|
| 7 |
fn=predict,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import html
|
| 3 |
|
| 4 |
def predict(review: str, display_mode: str):
|
| 5 |
+
review = (review or "").strip()
|
| 6 |
+
if not review:
|
| 7 |
+
# immer zwei Outputs zurückgeben
|
| 8 |
+
return "<i>Please enter a review.</i>", {}
|
| 9 |
+
|
| 10 |
+
if display_mode == "table":
|
| 11 |
+
html_out = f"<b>{html.escape(review)}</b> | <i>{display_mode}</i>"
|
| 12 |
+
json_out = {} # leer lassen
|
| 13 |
+
return html_out, json_out
|
| 14 |
+
else: # "JSON"
|
| 15 |
+
html_out = "" # leer lassen
|
| 16 |
+
json_out = {"review": review, "mode": display_mode}
|
| 17 |
+
return html_out, json_out
|
| 18 |
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=predict,
|