Spaces:
Running
Running
Commit ·
b299707
1
Parent(s): 310419f
sync editor text at measure bar.
Browse files
app.py
CHANGED
|
@@ -198,8 +198,13 @@ def run_generation (prompt, measures, temperature, max_patches, seed, store, top
|
|
| 198 |
top_k=int(top_k), top_p=float(top_p), measures=meas, seed=int(seed)):
|
| 199 |
if not done:
|
| 200 |
n_yields += 1
|
| 201 |
-
#
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
except Exception as e:
|
| 204 |
LOG.exception('generation failed: %s', e)
|
| 205 |
yield _log_panel(raw), pretty, gr.update(), store
|
|
|
|
| 198 |
top_k=int(top_k), top_p=float(top_p), measures=meas, seed=int(seed)):
|
| 199 |
if not done:
|
| 200 |
n_yields += 1
|
| 201 |
+
# The log streams every patch (raw text). The editor, however, must stay
|
| 202 |
+
# syntactically valid: only sync it at a measure boundary — i.e. when the
|
| 203 |
+
# accumulated text ends with the measure separator `|` (so it never shows a
|
| 204 |
+
# half-generated, incomplete measure). `done` forces a final sync.
|
| 205 |
+
at_boundary = raw.rstrip().endswith('|')
|
| 206 |
+
editor_update = pretty if (at_boundary or done) else gr.update()
|
| 207 |
+
yield _log_panel(raw), editor_update, gr.update(), store
|
| 208 |
except Exception as e:
|
| 209 |
LOG.exception('generation failed: %s', e)
|
| 210 |
yield _log_panel(raw), pretty, gr.update(), store
|