Skip to content

Commit c3ffc83

Browse files
safer token counting in messages (#19599)
1 parent 23137a5 commit c3ffc83

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llama-index-core/llama_index/core/utilities/token_counting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def estimate_tokens_in_messages(self, messages: List[ChatMessage]) -> int:
6666
tokens += 3 # Additional tokens for function call
6767

6868
if "tool_calls" in additional_kwargs:
69-
for tool_call in additional_kwargs["tool_calls"]:
69+
for tool_call in additional_kwargs.get("tool_calls", []):
7070
if (
7171
hasattr(tool_call, "function")
7272
and tool_call.function is not None

0 commit comments

Comments
 (0)