Signal · Methods
signal.count
signal.count(input) estimates the token count of a string or of a list of messages: one token per four characters, plus four tokens per message. The estimate is a heuristic with no tokenizer behind it, and no request is sent.
'Two for The Tempest on Saturday, please. Grace'
[
{
role: 'user',
content: 'Two for The Tempest on Saturday, please. Grace',
},
{
role: 'assistant',
content: '{"show":"The Tempest","seats":2}',
},
]{ string: 12, messages: 28 }Runs in this page on the installed package. The input and the expected output are defined by the example.