fix (token_tracker): prevented double token tracker

This commit is contained in:
GGrassia 2025-11-28 15:49:04 +01:00
parent 49ce064a11
commit d971e372c9

View file

@ -1694,10 +1694,13 @@ async def use_llm_func_with_cache(
if max_tokens is not None:
kwargs["max_tokens"] = max_tokens
# Only add token_tracker if not already in kwargs (to avoid duplicate argument error)
if token_tracker is not None and "token_tracker" not in kwargs:
kwargs["token_tracker"] = token_tracker
res: str = await use_llm_func(
safe_user_prompt,
system_prompt=safe_system_prompt,
token_tracker=token_tracker,
**kwargs,
)
@ -1731,11 +1734,14 @@ async def use_llm_func_with_cache(
if max_tokens is not None:
kwargs["max_tokens"] = max_tokens
# Only add token_tracker if not already in kwargs (to avoid duplicate argument error)
if token_tracker is not None and "token_tracker" not in kwargs:
kwargs["token_tracker"] = token_tracker
try:
res = await use_llm_func(
safe_user_prompt,
system_prompt=safe_system_prompt,
token_tracker=token_tracker,
**kwargs,
)
except Exception as e: