added tokens() function to Message and Chat
This commit is contained in:
@@ -129,6 +129,13 @@ class Chat:
|
||||
tags |= m.filter_tags(prefix, contain)
|
||||
return tags
|
||||
|
||||
def tokens(self) -> int:
|
||||
"""
|
||||
Returns the nr. of AI language tokens used by all messages in this chat.
|
||||
If unknown, 0 is returned.
|
||||
"""
|
||||
return sum(m.tokens() for m in self.messages)
|
||||
|
||||
def print(self, dump: bool = False, source_code_only: bool = False,
|
||||
with_tags: bool = False, with_file: bool = False,
|
||||
paged: bool = True) -> None:
|
||||
|
||||
Reference in New Issue
Block a user