diff --git a/dspy/clients/cache.py b/dspy/clients/cache.py index 4773306ccc..7ed1fafd94 100644 --- a/dspy/clients/cache.py +++ b/dspy/clients/cache.py @@ -122,7 +122,6 @@ def get(self, request: dict[str, Any], ignored_args_for_cache_key: list[str] | N if hasattr(response, "usage"): # Clear the usage data when cache is hit, because no LM call is made response.usage = {} - response.cache_hit = True return response def put( diff --git a/dspy/clients/lm.py b/dspy/clients/lm.py index f4885d470e..8cd21ede07 100644 --- a/dspy/clients/lm.py +++ b/dspy/clients/lm.py @@ -163,7 +163,7 @@ def forward( self._check_truncation(results) - if not getattr(results, "cache_hit", False) and dspy.settings.usage_tracker and hasattr(results, "usage"): + if dspy.settings.usage_tracker and hasattr(results, "usage"): settings.usage_tracker.add_usage(self.model, dict(results.usage)) return results @@ -201,7 +201,7 @@ async def aforward( self._check_truncation(results) - if not getattr(results, "cache_hit", False) and dspy.settings.usage_tracker and hasattr(results, "usage"): + if dspy.settings.usage_tracker and hasattr(results, "usage"): settings.usage_tracker.add_usage(self.model, dict(results.usage)) return results