MCPcopy
hub / github.com/llmware-ai/llmware / count_tokens

Method count_tokens

llmware/models.py:2948–2955  ·  view source on GitHub ↗
(self, ctx, tokenizer=None)

Source from the content-addressed store, hash-verified

2946 return pruned_ctx
2947
2948 def count_tokens(self, ctx, tokenizer=None):
2949
2950 if not tokenizer:
2951 tokenizer = self.tokenizer
2952
2953 toks = tokenizer.encode(ctx)
2954 tok_len = len(toks.ids)
2955 return tok_len
2956
2957 def prompt_engineer(self, query, context, inference_dict):
2958

Callers 1

prune_contextMethod · 0.95

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected