MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / calc_token

Method calc_token

utils/src/llms.py:247–254  ·  view source on GitHub ↗

Calculate the number of tokens for the turn.

(self)

Source from the content-addressed store, hash-verified

245 return {k: v for k, v in asdict(self).items() if k != "embedding"}
246
247 def calc_token(self):
248 """
249 Calculate the number of tokens for the turn.
250 """
251 if self.images is not None:
252 self.input_tokens += calc_image_tokens(self.images)
253 self.input_tokens += len(ENCODING.encode(self.prompt))
254 self.output_tokens = len(ENCODING.encode(self.response))
255
256 def __eq__(self, other):
257 return self is other

Callers 1

__post_process__Method · 0.45

Calls 1

calc_image_tokensFunction · 0.70

Tested by

no test coverage detected