Skip to content

Commit 80e4fb2

Browse files
umermansoorvictordibia
authored andcommitted
Update token_count_utils.py - Replace print with logger.warning for consistency (#3168)
The code was using both `logger.warning` and `print` for showing warning. This commit fixes this inconsistency which can be an issue on production environments / logging systems
1 parent 4a4eae6 commit 80e4fb2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

autogen/token_count_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _num_token_from_messages(messages: Union[List, Dict], model="gpt-3.5-turbo-0
9595
try:
9696
encoding = tiktoken.encoding_for_model(model)
9797
except KeyError:
98-
print("Warning: model not found. Using cl100k_base encoding.")
98+
logger.warning(f"Model {model} not found. Using cl100k_base encoding.")
9999
encoding = tiktoken.get_encoding("cl100k_base")
100100
if model in {
101101
"gpt-3.5-turbo-0613",
@@ -166,7 +166,7 @@ def num_tokens_from_functions(functions, model="gpt-3.5-turbo-0613") -> int:
166166
try:
167167
encoding = tiktoken.encoding_for_model(model)
168168
except KeyError:
169-
print("Warning: model not found. Using cl100k_base encoding.")
169+
logger.warning(f"Model {model} not found. Using cl100k_base encoding.")
170170
encoding = tiktoken.get_encoding("cl100k_base")
171171

172172
num_tokens = 0
@@ -193,7 +193,7 @@ def num_tokens_from_functions(functions, model="gpt-3.5-turbo-0613") -> int:
193193
function_tokens += 3
194194
function_tokens += len(encoding.encode(o))
195195
else:
196-
print(f"Warning: not supported field {field}")
196+
logger.warning(f"Not supported field {field}")
197197
function_tokens += 11
198198
if len(parameters["properties"]) == 0:
199199
function_tokens -= 2

0 commit comments

Comments
 (0)