Spaces:
Running on Zero
Running on Zero
Tighten ZeroGPU duration to measured 30s; clearer empty-content message
Browse files
app.py
CHANGED
|
@@ -219,8 +219,18 @@ def make_figure(
|
|
| 219 |
|
| 220 |
def format_answer(result: dict[str, Any], horizon: int) -> str:
|
| 221 |
"""Render the model response plus a short run summary."""
|
| 222 |
-
lines: list[str] = [(result.get("content") or "(no text returned)").strip()]
|
| 223 |
forecast = result.get("timeseries") if horizon > 0 else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
if forecast is not None and forecast.get("values"):
|
| 225 |
values = ", ".join(f"{value:.3f}" for value in forecast["values"])
|
| 226 |
lines += ["", f"Forecast (original scale, {horizon} step(s)):", values]
|
|
@@ -240,7 +250,7 @@ def format_answer(result: dict[str, Any], horizon: int) -> str:
|
|
| 240 |
# ---------------------------------------------------------------------------
|
| 241 |
|
| 242 |
|
| 243 |
-
@spaces.GPU(duration=
|
| 244 |
def run_timebraid(
|
| 245 |
series_text: str,
|
| 246 |
prompt: str,
|
|
@@ -260,7 +270,7 @@ def run_timebraid(
|
|
| 260 |
system_prompt = _coerce_text(system_prompt)
|
| 261 |
horizon = _coerce_int(horizon, 0, 0, MAX_HORIZON)
|
| 262 |
target_number = _coerce_int(target_number, 1, 1, MAX_SERIES)
|
| 263 |
-
max_new_tokens = _coerce_int(max_new_tokens, 256, 32,
|
| 264 |
|
| 265 |
instruction = prompt.strip()
|
| 266 |
if not instruction:
|
|
@@ -472,7 +482,7 @@ with gr.Blocks(title="TimeBraid", theme=gr.themes.Citrus(), css=CSS) as demo:
|
|
| 472 |
)
|
| 473 |
max_tokens_slider = gr.Slider(
|
| 474 |
minimum=64,
|
| 475 |
-
maximum=
|
| 476 |
value=256,
|
| 477 |
step=32,
|
| 478 |
precision=0,
|
|
|
|
| 219 |
|
| 220 |
def format_answer(result: dict[str, Any], horizon: int) -> str:
|
| 221 |
"""Render the model response plus a short run summary."""
|
|
|
|
| 222 |
forecast = result.get("timeseries") if horizon > 0 else None
|
| 223 |
+
content = (result.get("content") or "").strip()
|
| 224 |
+
if not content:
|
| 225 |
+
if forecast is not None and forecast.get("values"):
|
| 226 |
+
content = (
|
| 227 |
+
"TimeBraid returned the forecast values below without an "
|
| 228 |
+
"accompanying written answer, which is normal for a pure "
|
| 229 |
+
"forecasting request."
|
| 230 |
+
)
|
| 231 |
+
else:
|
| 232 |
+
content = "(the model returned no text)"
|
| 233 |
+
lines: list[str] = [content]
|
| 234 |
if forecast is not None and forecast.get("values"):
|
| 235 |
values = ", ".join(f"{value:.3f}" for value in forecast["values"])
|
| 236 |
lines += ["", f"Forecast (original scale, {horizon} step(s)):", values]
|
|
|
|
| 250 |
# ---------------------------------------------------------------------------
|
| 251 |
|
| 252 |
|
| 253 |
+
@spaces.GPU(duration=30)
|
| 254 |
def run_timebraid(
|
| 255 |
series_text: str,
|
| 256 |
prompt: str,
|
|
|
|
| 270 |
system_prompt = _coerce_text(system_prompt)
|
| 271 |
horizon = _coerce_int(horizon, 0, 0, MAX_HORIZON)
|
| 272 |
target_number = _coerce_int(target_number, 1, 1, MAX_SERIES)
|
| 273 |
+
max_new_tokens = _coerce_int(max_new_tokens, 256, 32, 512)
|
| 274 |
|
| 275 |
instruction = prompt.strip()
|
| 276 |
if not instruction:
|
|
|
|
| 482 |
)
|
| 483 |
max_tokens_slider = gr.Slider(
|
| 484 |
minimum=64,
|
| 485 |
+
maximum=512,
|
| 486 |
value=256,
|
| 487 |
step=32,
|
| 488 |
precision=0,
|