tokenCountFor
Retrieves the number of tokens contained in the content of the given message. This method utilizes caching to improve performance, storing previously computed token counts and reusing them for identical messages.
Return
The number of tokens in the content of the message
Parameters
message
The message whose content's token count is to be retrieved
Calculates the total number of tokens spent on the given prompt by summing the token usage of all messages associated with the prompt.
Return
The total number of tokens spent across all messages in the provided prompt.
Parameters
prompt
The prompt containing the list of messages whose token usage will be calculated.