Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Wrap disk_cache.size_limit adjustment in an if stmt

Omar Khattabf0efe4549b16
diff --git a/dspy/clients/__init__.py b/dspy/clients/__init__.py
index de2e76f3c..546a96c75 100644
--- a/dspy/clients/__init__.py
+++ b/dspy/clients/__init__.py
@@ -13,7 +13,9 @@ DISK_CACHE_LIMIT = int(os.environ.get("DSPY_CACHE_LIMIT", 3e10)) # 30 GB defaul
# TODO: There's probably value in getting litellm to support FanoutCache and to separate the limit for
# the LM cache from the embeddings cache. Then we can lower the default 30GB limit.
litellm.cache = Cache(disk_cache_dir=DISK_CACHE_DIR, type="disk")
-litellm.cache.cache.disk_cache.reset('size_limit', DISK_CACHE_LIMIT)
+
+if litellm.cache.cache.disk_cache.size_limit != DISK_CACHE_LIMIT:
+ litellm.cache.cache.disk_cache.reset('size_limit', DISK_CACHE_LIMIT)
litellm.telemetry = False