fix prompt list counter

This commit is contained in:
Zilin Xiao 2023-03-16 13:49:46 +08:00 committed by GitHub
parent 9a65782f7b
commit d2e343153c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,7 +341,7 @@ def num_tokens_consumed_from_request(
return num_tokens
elif isinstance(prompt, list): # multiple prompts
prompt_tokens = sum([len(encoding.encode(p)) for p in prompt])
num_tokens = prompt_tokens + completion_tokens
num_tokens = prompt_tokens + completion_tokens * len(prompt)
return num_tokens
else:
raise TypeError('Expecting either string or list of strings for "prompt" field in completion request')