feat: fix new summarizer code and add more tests (#6461)

This commit is contained in:
Sarah Wooders
2025-11-30 00:49:38 -08:00
committed by Caren Thomas
parent 86023db9b1
commit 91e3dd8b3e
25 changed files with 728 additions and 358 deletions

View File

@@ -812,13 +812,13 @@ class OpenAIBackcompatUnpickler(pickle.Unpickler):
return super().find_class(module, name)
def count_tokens(s: str, model: str = "gpt-4") -> int:
try:
encoding = tiktoken.encoding_for_model(model)
except KeyError:
print("Falling back to cl100k base for token counting.")
encoding = tiktoken.get_encoding("cl100k_base")
return len(encoding.encode(s))
# def count_tokens(s: str, model: str = "gpt-4") -> int:
# try:
# encoding = tiktoken.encoding_for_model(model)
# except KeyError:
# print("Falling back to cl100k base for token counting.")
# encoding = tiktoken.get_encoding("cl100k_base")
# return len(encoding.encode(s))
def printd(*args, **kwargs):