MCPcopy Index your code
hub / github.com/codehamr/codehamr / Tokens

Method Tokens

internal/ctx/ctx.go:37–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35// Tokens approximates token count as char/4, good enough for budgeting.
36func Tokens(s string) int { return (len(s) + 3) / 4 }
37
38func (m Message) Tokens() int {
39 n := Tokens(m.Content)
40 for _, tc := range m.ToolCalls {
41 n += Tokens(tc.Name)
42 for k, v := range tc.Arguments {
43 n += Tokens(k) + Tokens(fmt.Sprint(v))
44 }
45 }
46 return n + 8
47}
48
49const (

Callers 5

NewFunction · 0.80
dbgWriteRequestFunction · 0.80
PackFunction · 0.80

Calls 1

TokensFunction · 0.85