Spaces:
Running on CPU Upgrade

ziem-io commited on
Commit
f35e5d2
·
1 Parent(s): ac240ce

Fix: Basic output function

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
 
2
 
3
  def predict(review: str, display_mode: str):
4
- return review + " | " + display_mode
 
 
 
 
 
 
 
 
 
 
 
 
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,