- Replace token 'a or b' fallback with explicit None checks so valid zero token counts are not lost (__init__.py, waterfall.html) - Remove nl filter from raw JSON textarea to preserve stored bytes exactly (payload.html) - Use PRAGMA table_info introspection instead of broad except OperationalError for ALTER TABLE migration (db.py)
100 lines
4.1 KiB
HTML
100 lines
4.1 KiB
HTML
{% set turn = waterfall_turn %}
|
|
{% set max_duration = turn.elapsed_ms or 1 %}
|
|
{% set order_display = turn._order if "_order" in turn and turn._order else turn.api_call_count or "(?)" %}
|
|
|
|
<div class="waterfall" x-data="{ activeItem: 'turn-{{ turn.id }}' }"
|
|
hx-get="/turn/{{ turn.id }}"
|
|
hx-target="#detail-body"
|
|
hx-trigger="load"
|
|
hx-swap="innerHTML">
|
|
|
|
{# ── The turn itself (LLM call) ── #}
|
|
<div class="wf-item wf-llm-call active"
|
|
:class="{ active: activeItem === 'turn-{{ turn.id }}' }"
|
|
@click="activeItem = 'turn-{{ turn.id }}'"
|
|
hx-get="/turn/{{ turn.id }}"
|
|
hx-target="#detail-body"
|
|
hx-trigger="click"
|
|
hx-swap="innerHTML">
|
|
|
|
<div class="wf-indent" style="width: 0;"></div>
|
|
<div class="wf-icon">⚡</div>
|
|
<div class="wf-body">
|
|
<div class="wf-row">
|
|
<span class="wf-name">LLM call {{ order_display }}</span>
|
|
<span class="wf-model badge badge-dim">{{ (turn.model or "—") | truncate(20) }}</span>
|
|
</div>
|
|
<div class="wf-bar-track">
|
|
<div class="wf-bar wf-bar-main" style="width: 100%"></div>
|
|
</div>
|
|
<div class="wf-stats">
|
|
<span class="wf-latency">
|
|
{% if turn.elapsed_ms is not none and turn.elapsed_ms >= 1000 %}
|
|
{{ "%.1f" | format(turn.elapsed_ms / 1000) }}s
|
|
{% else %}
|
|
{{ turn.elapsed_ms or "—" }}ms
|
|
{% endif %}
|
|
</span>
|
|
<span class="wf-tokens">{{ turn.input_tokens if turn.input_tokens is not none else "?" }} → {{ turn.output_tokens if turn.output_tokens is not none else "?" }}</span>
|
|
<span class="wf-total">Σ {{ turn.total_tokens if turn.total_tokens is not none else "?" }}</span>
|
|
{% set fr = turn.finish_reason or "" %}
|
|
{% if fr %}
|
|
<span class="badge {% if fr == 'stop' %}badge-green{% elif fr == 'length' %}badge-yellow{% else %}badge-red{% endif %}">{{ fr }}</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="wf-preview">{{ (turn.response_preview or "") | truncate(100) }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# ── Tool calls (children) ── #}
|
|
{% for tc in turn.tool_calls %}
|
|
{% set tc_duration = tc.duration_ms or 0 %}
|
|
{% set bar_pct = (tc_duration / max_duration * 100) if max_duration > 0 else 0 %}
|
|
<div class="wf-item wf-tool-call"
|
|
:class="{ active: activeItem === 'tc-{{ tc.id }}' }"
|
|
@click="activeItem = 'tc-{{ tc.id }}'"
|
|
hx-get="/turn/{{ turn.id }}?focus_tc={{ tc.id }}"
|
|
hx-target="#detail-body"
|
|
hx-trigger="click"
|
|
hx-swap="innerHTML">
|
|
|
|
<div class="wf-indent" style="width: 28px;">
|
|
<div class="wf-tree-line"></div>
|
|
</div>
|
|
<div class="wf-icon">
|
|
{% if tc.error %}
|
|
<span style="color: var(--red);">⚠</span>
|
|
{% else %}
|
|
<span style="color: var(--yellow);">🔧</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="wf-body">
|
|
<div class="wf-row">
|
|
<span class="wf-name">Tool: <strong>{{ tc.name }}</strong></span>
|
|
{% if tc.error %}
|
|
<span class="badge badge-red">error</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="wf-bar-track">
|
|
<div class="wf-bar wf-bar-tool"
|
|
style="width: {{ bar_pct | round(1) }}%"></div>
|
|
</div>
|
|
<div class="wf-stats">
|
|
<span class="wf-latency">
|
|
{% if tc_duration >= 1000 %}
|
|
{{ "%.1f" | format(tc_duration / 1000) }}s
|
|
{% else %}
|
|
{{ tc_duration }}ms
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
<div class="wf-preview">{{ (tc.args or "") | truncate(80) }}</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{# ── Empty state ── #}
|
|
{% if not turn.tool_calls %}
|
|
<div class="wf-empty">No tool calls in this turn</div>
|
|
{% endif %}
|
|
</div>
|