Skip to content

Commit e7583bb

Browse files
authored
fix: token calculation for streaming requests with tools (#34) (#39)
1 parent 64a5b76 commit e7583bb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aidial_adapter_openai/utils/tokens.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def calculate_tokens_per_message(
3333

3434
prompt_tokens = tokens_per_message
3535
for key, value in message.items():
36-
prompt_tokens += len(encoding.encode(value))
36+
if type(value) == str:
37+
prompt_tokens += len(encoding.encode(value))
3738
if key == "name":
3839
prompt_tokens += tokens_per_name
3940

0 commit comments

Comments
 (0)