From 505b4f86d3fb766b63544083bbaaf7a1d666acdc Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 16 Jul 2024 16:56:15 -0700 Subject: [PATCH] fix installing on python3.8 --- litellm/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 48fdf80c59f..33a053a23bd 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1575,8 +1575,8 @@ def openai_token_counter( model="gpt-3.5-turbo-0613", text: Optional[str] = None, is_tool_call: Optional[bool] = False, - tools: Optional[List[ChatCompletionToolParam]] = None, - tool_choice: Optional[ChatCompletionNamedToolChoiceParam] = None, + tools: List[ChatCompletionToolParam] | None = None, + tool_choice: ChatCompletionNamedToolChoiceParam | None = None, count_response_tokens: Optional[ bool ] = False, # Flag passed from litellm.stream_chunk_builder, to indicate counting tokens for LLM Response. We need this because for LLM input we add +3 tokens per message - based on OpenAI's token counter @@ -1621,6 +1621,7 @@ def openai_token_counter( num_tokens += tokens_per_message if message.get("role", None) == "system": includes_system_message = True + includes_system_message = True for key, value in message.items(): if isinstance(value, str): num_tokens += len(encoding.encode(value, disallowed_special=())) @@ -1872,6 +1873,7 @@ def _format_type(props, indent): return "any" + def token_counter( model="", custom_tokenizer: Optional[dict] = None, @@ -1960,6 +1962,7 @@ def token_counter( count_response_tokens=count_response_tokens, tools=tools, tool_choice=tool_choice, + tool_choice=tool_choice, ) else: print_verbose( @@ -1973,6 +1976,7 @@ def token_counter( count_response_tokens=count_response_tokens, tools=tools, tool_choice=tool_choice, + tool_choice=tool_choice, ) else: num_tokens = len(encoding.encode(text, disallowed_special=())) # type: ignore