From 4f64f20df638288c61c851214d032d15fac8cd9f Mon Sep 17 00:00:00 2001 From: XianBW <36835909+XianBW@users.noreply.github.com> Date: Fri, 24 Oct 2025 12:30:30 +0800 Subject: [PATCH] fix litellm log content (#1278) --- rdagent/oai/backend/litellm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rdagent/oai/backend/litellm.py b/rdagent/oai/backend/litellm.py index 1ac0e6fe..d3ead499 100644 --- a/rdagent/oai/backend/litellm.py +++ b/rdagent/oai/backend/litellm.py @@ -158,7 +158,8 @@ class LiteLLMAPIBackend(APIBackend): **complete_kwargs, **kwargs, ) - logger.info(f"{LogColors.GREEN}Using chat model{LogColors.END} {model}", tag="llm_messages") + if LITELLM_SETTINGS.log_llm_chat_content: + logger.info(f"{LogColors.GREEN}Using chat model{LogColors.END} {model}", tag="llm_messages") if LITELLM_SETTINGS.chat_stream: if LITELLM_SETTINGS.log_llm_chat_content: @@ -198,9 +199,10 @@ class LiteLLMAPIBackend(APIBackend): cost = np.nan else: ACC_COST += cost - logger.info( - f"Current Cost: ${float(cost):.10f}; Accumulated Cost: ${float(ACC_COST):.10f}; {finish_reason=}", - ) + if LITELLM_SETTINGS.log_llm_chat_content: + logger.info( + f"Current Cost: ${float(cost):.10f}; Accumulated Cost: ${float(ACC_COST):.10f}; {finish_reason=}", + ) prompt_tokens = token_counter(model=model, messages=messages) completion_tokens = token_counter(model=model, text=content)