diff --git a/dsp/utils/settings.py b/dsp/utils/settings.py index 1fed723683..009c7b6c9c 100644 --- a/dsp/utils/settings.py +++ b/dsp/utils/settings.py @@ -1,6 +1,6 @@ import threading -from copy import deepcopy from contextlib import contextmanager +from copy import deepcopy from dsp.utils.utils import dotdict @@ -24,7 +24,6 @@ experimental=False, backoff_time=10, callbacks=[], - suppress_debug_info=True, ) diff --git a/dspy/clients/__init__.py b/dspy/clients/__init__.py index 9692a9a974..dc10f865fb 100644 --- a/dspy/clients/__init__.py +++ b/dspy/clients/__init__.py @@ -10,7 +10,15 @@ DISK_CACHE_DIR = os.environ.get("DSPY_CACHEDIR") or os.path.join(Path.home(), ".dspy_cache") litellm.cache = Cache(disk_cache_dir=DISK_CACHE_DIR, type="disk") litellm.telemetry = False +# Turn off by default to avoid LiteLLM logging during every LM call. +litellm.suppress_debug_info = True if "LITELLM_LOCAL_MODEL_COST_MAP" not in os.environ: - # accessed at run time by litellm; i.e., fine to keep after import + # Accessed at run time by litellm; i.e., fine to keep after import os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + +def enable_litellm_logging(): + litellm.suppress_debug_info = False + +def disable_litellm_logging(): + litellm.suppress_debug_info = True diff --git a/dspy/clients/lm.py b/dspy/clients/lm.py index ac891841c3..4964d73173 100644 --- a/dspy/clients/lm.py +++ b/dspy/clients/lm.py @@ -9,7 +9,6 @@ import litellm import ujson -import dspy from dspy.adapters.base import Adapter from dspy.clients.openai import OpenAIProvider from dspy.clients.provider import Provider, TrainingJob @@ -70,9 +69,6 @@ def __init__( self.num_retries = num_retries self.finetuning_model = finetuning_model - #turned off by default to avoid LiteLLM logging during every LM call - litellm.suppress_debug_info = dspy.settings.suppress_debug_info - # TODO(bug): Arbitrary model strings could include the substring "o1-". # We should find a more robust way to check for the "o1-" family models. if "o1-" in model: