DSPy: The framework for programming—not prompting—language models
Python
fix: set LITELLM_LOCAL_MODEL_COST_MAP before litellm import to avoid HTTP fetch (#9388)
Isaac Miller30ebe34f9efa
diff --git a/dspy/__init__.py b/dspy/__init__.pyindex b65ed557b..cdeb4b777 100644--- a/dspy/__init__.py+++ b/dspy/__init__.py@@ -1,3 +1,6 @@+import os+os.environ.setdefault("LITELLM_LOCAL_MODEL_COST_MAP", "True")+from dspy.predict import *from dspy.primitives import *from dspy.retrievers import *diff --git a/dspy/clients/__init__.py b/dspy/clients/__init__.pyindex 7972bba8a..592a9091d 100644--- a/dspy/clients/__init__.py+++ b/dspy/clients/__init__.py@@ -79,11 +79,6 @@ def _get_dspy_cache():DSPY_CACHE = _get_dspy_cache()-if "LITELLM_LOCAL_MODEL_COST_MAP" not in os.environ:- # Accessed at run time by litellm; i.e., fine to keep after import- os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"--def configure_litellm_logging(level: str = "ERROR"):"""Configure LiteLLM logging to the specified level."""# Litellm uses a global logger called `verbose_logger` to control all loggings.