mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Fix
This commit is contained in:
@@ -335,7 +335,7 @@ async def on_message(message):
|
||||
|
||||
# *=========================================== Define Functions
|
||||
|
||||
def num_tokens_from_string(string, model):
|
||||
def num_tokens_from_string(message, model):
|
||||
"""
|
||||
The function `num_tokens_from_string` returns the number of tokens in a given string.
|
||||
|
||||
@@ -347,10 +347,9 @@ def num_tokens_from_string(string, model):
|
||||
tokens_per_name = 1
|
||||
chat_gpt_encoding = tiktoken.encoding_for_model(model)
|
||||
|
||||
num_tokens = len(chat_gpt_encoding.encode(string))
|
||||
num_tokens = 0
|
||||
num_tokens += tokens_per_message
|
||||
for keys, values in string.items():
|
||||
for keys, values in message.items():
|
||||
num_tokens += len(chat_gpt_encoding.encode(values))
|
||||
if keys == "role":
|
||||
num_tokens += tokens_per_name
|
||||
|
||||
Reference in New Issue
Block a user