Skip to content

Commit 451a76b

Browse files
new: only print the unexpected api keys found once
1 parent 45c00e9 commit 451a76b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

DocToolsLLM/utils/misc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def language_detector(text: str) -> None:
7878
max_lines = 100_000
7979
min_lang_prob = 0.50
8080

81+
printed_unexpected_api_keys = False # to print it only once
82+
8183
# loader specific arguments
8284
loader_specific_keys = {
8385
"anki_deck": str,
@@ -212,10 +214,12 @@ def wrapped_model_name_matcher(model: str) -> str:
212214
for k, v in dict(os.environ).items():
213215
if k.endswith("_API_KEY"):
214216
backend = k.split("_API_KEY")[0].lower()
215-
if backend not in all_backends and is_verbose:
217+
if backend not in all_backends and is_verbose and not printed_unexpected_api_keys:
216218
yel(f"Found API_KEY for backend {backend} that is not a known backend for litellm.")
217219
else:
218220
backends.append(backend)
221+
if is_verbose:
222+
printed_unexpected_api_keys = True
219223
assert backends, "No API keys found in environnment"
220224

221225
# filter by providers

0 commit comments

Comments
 (0)