A small ring that fills as a conversation uses up the model's memory. Point at it to see what takes the room and what each reply costs. It warns before the model starts to forget.

Ask anything84k of 200k42%Instructions2.4kFiles31kTools11kMessages39kFree116kEach reply reads it all$0.25
Used, 84k42

Model window

Price

Warns at0.80

Breakdown

Ring

NeedsReactTheme

Source
curl --create-dirs -o src/components/context.tsx https://fragms.simonveprek.cz/source/context -o src/components/theme.tsx https://fragms.simonveprek.cz/source/theme

Saves src/components/context.tsx and theme.tsx beside it. No setup, works in any React project.

import { Context } from "@/components/context";<Context  // What fills the window. Count tokens with your model's tokenizer  parts={[    { label: "Instructions", tokens: system },    { label: "Files", tokens: files },    { label: "Messages", tokens: messages },  ]}  price={3}  label="percent"  onCompact={summarise}/>
used

Tokens in the conversation so far. Use parts instead for a breakdown.

numberDefault 0
parts

What the tokens are made of, each with a label, a count and an optional colour.

ContextPart[]Default none
limit

The model's context window, in tokens.

32_000200_0001_000_000
price

Price per million input tokens. Every reply reads the whole conversation, so this is what the next one costs.

numberDefault hidden
warnAt

How full it gets before turning amber. It turns red at 95%.

0.50.80.95
label

What reads beside it. The share, tokens used, or tokens left.

nonepercentusedleft
shape

A ring, or a slim bar.

ringbar
segments

Draws each part in its own colour while there is room.

truefalse
colors

The fill while there is room, once it warns, and once it is nearly full.

{ fine, warn, full }Default text, amber, red
onCompact

Offered once it warns. Summarise or trim the conversation here.

() => voidDefault nothing
open

Holds the breakdown open or shut. Left out, hover and tap decide.

truefalseDefault auto
side

Where the breakdown opens.

topbottom
size

The ring's diameter in pixels.

numberDefault 22

What's new

  1. 2.0
    • Fills in the Theme's accent
    • Its breakdown stays dark on dark pages
  2. 1.0
    • First release