Wayfindersix commited on
Commit
dcc990e
·
1 Parent(s): 981435d

ship: remove emoji, add fallback matching

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -60,6 +60,19 @@ FALLBACKS = [
60
  ]
61
 
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  def pour(user_input):
64
  topic = user_input.strip() if user_input and user_input.strip() else ""
65
 
@@ -79,7 +92,7 @@ def pour(user_input):
79
  except Exception:
80
  pass
81
 
82
- return random.choice(FALLBACKS)
83
 
84
 
85
  def pour_random():
@@ -133,7 +146,6 @@ with gr.Blocks(css=CUSTOM_CSS, title="Drop", theme=gr.themes.Base()) as demo:
133
  <h1>Drop</h1>
134
  <div class="sub">The thing you need most is the thing you think about least</div>
135
  </div>
136
- <div class="app-visual">💧</div>
137
  """)
138
 
139
  with gr.Column(elem_classes="input-box"):
 
60
  ]
61
 
62
 
63
+ def find_fallback(thing):
64
+ if thing:
65
+ thing_lower = thing.lower().strip()
66
+ for fb in FALLBACKS:
67
+ try:
68
+ fb_topic = fb.split("**")[1].lower()
69
+ if thing_lower == fb_topic or (thing_lower in fb_topic and len(thing_lower) > 5):
70
+ return fb
71
+ except (IndexError, ValueError):
72
+ continue
73
+ return random.choice(FALLBACKS)
74
+
75
+
76
  def pour(user_input):
77
  topic = user_input.strip() if user_input and user_input.strip() else ""
78
 
 
92
  except Exception:
93
  pass
94
 
95
+ return find_fallback(topic)
96
 
97
 
98
  def pour_random():
 
146
  <h1>Drop</h1>
147
  <div class="sub">The thing you need most is the thing you think about least</div>
148
  </div>
 
149
  """)
150
 
151
  with gr.Column(elem_classes="input-box"):