"""The two places a person reads the list of models: the chat's picker and /settings. Until 1.8.2 both printed every capability switch as a tag -- twenty `tool_*` entries per model -- and in /settings the tags sat beside the name and squeezed it to a word per line underneath them. The picker is now name, context window and an eye for vision; /settings keeps the tags, underneath. The layout is by construction (the rows share the list's column tracks), and that only holds while every row emits every slot, so a model with no context length and no vision is asserted to still have both cells. """ from __future__ import annotations import re import pytest from lembas.db.models import Connection, Model from lembas.services.crypto import encrypt from lembas.web.templating import context_size @pytest.mark.parametrize( ("tokens", "shown"), [ (None, ""), (0, ""), (512, "512"), (4096, "4K"), (32768, "33K"), (131072, "131K"), (262144, "262K"), (1_000_000, "1M"), (1_048_576, "1M"), (2_000_000, "2M"), (1_500_000, "1.5M"), ], ) def test_a_context_window_is_shortened_the_way_it_is_quoted(tokens, shown): assert context_size(tokens) == shown @pytest.fixture def models(db, registered): connection = Connection( name="Test", base_url="http://127.0.0.1:1", api_key_encrypted=encrypt("") ) db.add(connection) db.commit() db.add_all( [ Model( connection_id=connection.id, model_id="sees", display_name="Sees", position=0, context_length=131072, capabilities_json={"vision": True, "tools": True, "tool_fetch": True}, ), Model( connection_id=connection.id, model_id="blind", display_name="Blind", position=1, capabilities_json={"tools": True, "tool_fetch": True}, ), ] ) db.commit() def _options(html: str) -> dict[str, str]: """The model picker's options by model id -- not the @-mention menu's.""" found = {} for body in re.findall(r'