{% extends "server/base.html" %} {% block title %}{{ t.text("usage.title") }}{% endblock %} {% block top %}{% endblock %} {% block head %}{% endblock %} {% block body %} {# how things stand for the account: a sentence on the agents at work, the new conversations waiting and, on a wide screen, the computers away, what is none left out, beside the choice of range; the agents running, a lantern each, and those at work; then each range's turns against as long before and how they went, and its tokens with their cost where a runtime gave one and what they are made of - the range chosen shown, and on a phone today's #} {% set lanterns = {"working": "work", "idle": "on", "failed": "fail", "offline": "off"} %} {% set working = glance.agents | selectattr(1, "equalto", "working") | map(attribute="0.name") | list %} {% set said = [] %} {% if working %}{% set _ = said.append(t.text("usage.said.working", {"n": working | length})) %}{% endif %} {% if glance.pending %}{% set _ = said.append(t.text("usage.said.pending", {"n": glance.pending})) %}{% endif %} {% set wide = said + [t.text("usage.said.offline", {"n": glance.offline})] if glance.offline else said %}
{% if wide %}

{{ wide | join(t.text("usage.said.and")) | safe }}{{ t.text("usage.said.end") }}

{% endif %} {% if said %}

{{ said | join(t.text("usage.said.and")) | safe }}{{ t.text("usage.said.end") }}

{% endif %}
{% for span in spans %}{% endfor %}
{% include "usage/icons/bot.svg" %}{{ t.text("usage.running") }}{{ t.text("usage.running.short") }}
{{ glance.agents | selectattr(1, "in", ("working", "idle")) | list | length }}/ {{ glance.agents | length }}
{% for agent, now in glance.agents %}{% endfor %}
{% include "usage/icons/zap.svg" %}{{ t.text("usage.working") }}
{{ working | length }}{{ t.text("usage.working.unit", {"n": working | length}) }}
{{ working | join(" · ") }}
{% for span in spans %} {% set turns = span.buckets | sum(attribute="turns") %} {% set fresh = span.buckets | sum(attribute="input") %} {% set cached = span.buckets | sum(attribute="cached") %} {% set output = span.buckets | sum(attribute="output") %} {% set spent = span.buckets | rejectattr("cost", "none") | map(attribute="cost") | list %} {% set used = (fresh + cached + output) | tokens %} {% set unit = used[-1] if used[-1] in ("k", "M") else "" %}
{% include "usage/icons/activity.svg" %}{{ t.text("usage.turns." ~ span.days) }}{{ t.text("usage.turns.short") }}
{{ turns }}
{%- if span.before %} {%- set change = ((turns - span.before) * 100 / span.before) | round | int %} {{ "↑ " if change > 0 else "↓ " if change < 0 else "" }}{{ change | abs }}%{{ t.text("usage.than." ~ span.days) }} {%- endif %} {# the turns of each hour or day, against the busiest #} {%- set counts = span.buckets | map(attribute="turns") | list %} {%- set counts = counts * 2 if counts | length == 1 else counts %} {%- set top = [counts | max, 1] | max %} {%- set points = [] %} {%- for count in counts %}{% set _ = points.append("%.1f %.1f" | format(loop.index0 * 110 / (counts | length - 1), 20 - count / top * 16)) %}{% endfor %} {%- set line = "M" ~ points | join(" L") %}
{% include "usage/icons/coins.svg" %}{{ t.text("usage.tokens." ~ span.days) }}
{{ used[:-1] if unit else used }}{% if unit %}{{ unit }} {% endif %}tokens{% if spent %} · ${{ "%.2f" | format(spent | sum) }}{% endif %}{{ unit }}
{% if spent %}
${{ "%.2f" | format(spent | sum) }}
{% endif %} {% set split = [fresh, cached, output] | shares %}
{% for part in ("fresh", "cached", "output") %}{% if split[loop.index0] %}{% endif %}{% endfor %}
{% for part in ("fresh", "cached", "output") %}{{ t.text("usage." ~ part) }} {{ split[loop.index0] }}%{% endfor %}
{% endfor %}
{% endblock %}