Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -192,7 +192,7 @@ def append_token(token_id: int):
|
|
| 192 |
text_rx.set(text_rx.value + decoded)
|
| 193 |
# lock highlight to the clicked token and keep it after re-predict
|
| 194 |
preview_token(int(token_id))
|
| 195 |
-
on_predict() # refresh next tokens but
|
| 196 |
|
| 197 |
# ------------------ Auto-predict on typing (debounced) ------------------
|
| 198 |
@solara.component
|
|
@@ -221,7 +221,7 @@ def AutoPredictWatcher():
|
|
| 221 |
solara.use_effect(effect, [text, auto])
|
| 222 |
return solara.Text("", style={"display": "none"})
|
| 223 |
|
| 224 |
-
# ------------------ UI: clickable +
|
| 225 |
@solara.component
|
| 226 |
def PredictionsList():
|
| 227 |
df = preds_rx.value
|
|
@@ -240,21 +240,17 @@ def PredictionsList():
|
|
| 240 |
tok_disp = display_token_from_id(tid)
|
| 241 |
label = fmt_row(i, prob, tid, tok_disp)
|
| 242 |
|
| 243 |
-
#
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
on_mouse_enter=lambda e=None, tid=tid: preview_token(tid),
|
| 248 |
-
on_mouse_over=lambda e=None, tid=tid: preview_token(tid),
|
| 249 |
-
on_mouse_move=lambda e=None, tid=tid: preview_token(tid),
|
| 250 |
-
on_focus=lambda e=None, tid=tid: preview_token(tid),
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
on_click=lambda tid=tid: append_token(tid),
|
| 255 |
-
classes=["rowbtn"],
|
| 256 |
-
style={"justifyContent": "flex-start", "width": "100%"},
|
| 257 |
-
)
|
| 258 |
|
| 259 |
# ------------------ Page ------------------
|
| 260 |
@solara.component
|
|
@@ -298,4 +294,4 @@ def Page():
|
|
| 298 |
|
| 299 |
# Seed initial predictions and mount
|
| 300 |
on_predict()
|
| 301 |
-
Page()
|
|
|
|
| 192 |
text_rx.set(text_rx.value + decoded)
|
| 193 |
# lock highlight to the clicked token and keep it after re-predict
|
| 194 |
preview_token(int(token_id))
|
| 195 |
+
on_predict() # refresh next tokens but preserve highlight
|
| 196 |
|
| 197 |
# ------------------ Auto-predict on typing (debounced) ------------------
|
| 198 |
@solara.component
|
|
|
|
| 221 |
solara.use_effect(effect, [text, auto])
|
| 222 |
return solara.Text("", style={"display": "none"})
|
| 223 |
|
| 224 |
+
# ------------------ UI: clickable + HOVERABLE rows ------------------
|
| 225 |
@solara.component
|
| 226 |
def PredictionsList():
|
| 227 |
df = preds_rx.value
|
|
|
|
| 240 |
tok_disp = display_token_from_id(tid)
|
| 241 |
label = fmt_row(i, prob, tid, tok_disp)
|
| 242 |
|
| 243 |
+
# Put ALL hover handlers directly on the Button.
|
| 244 |
+
solara.Button(
|
| 245 |
+
label,
|
| 246 |
+
on_click=lambda tid=tid: append_token(tid), # click to append
|
| 247 |
+
on_mouse_enter=lambda e=None, tid=tid: preview_token(tid), # hover preview
|
| 248 |
+
on_mouse_over=lambda e=None, tid=tid: preview_token(tid), # extra safety
|
| 249 |
+
on_mouse_move=lambda e=None, tid=tid: preview_token(tid), # tracks movement
|
| 250 |
+
on_focus=lambda e=None, tid=tid: preview_token(tid), # keyboard focus
|
| 251 |
+
classes=["rowbtn"],
|
| 252 |
+
style={"justifyContent": "flex-start", "width": "100%"},
|
| 253 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
# ------------------ Page ------------------
|
| 256 |
@solara.component
|
|
|
|
| 294 |
|
| 295 |
# Seed initial predictions and mount
|
| 296 |
on_predict()
|
| 297 |
+
Page()
|