@@ -163,23 +163,40 @@ def load_memory_cache(self, filepath: str) -> None:
163
163
self .memory_cache = cloudpickle .load (f )
164
164
165
165
166
- def request_cache (cache_arg_name : Optional [str ] = None , ignored_args_for_cache_key : Optional [list [str ]] = None ):
167
- """Decorator for applying caching to a function based on the request argument.
166
+ def request_cache (
167
+ cache_arg_name : Optional [str ] = None ,
168
+ ignored_args_for_cache_key : Optional [list [str ]] = ["api_key" , "api_base" , "base_url" ],
169
+ * , # everything after this is keyword-only
170
+ maxsize : Optional [int ] = None , # legacy / no-op
171
+ ):
172
+ """
173
+ Decorator for applying caching to a function based on the request argument.
168
174
169
175
Args:
170
176
cache_arg_name: The name of the argument that contains the request. If not provided, the entire kwargs is used
171
177
as the request.
172
178
ignored_args_for_cache_key: A list of arguments to ignore when computing the cache key from the request.
173
179
"""
174
180
181
+ # ---- Deprecation notice ----------------------------------------------
182
+ if maxsize is not None :
183
+ logger .warning (
184
+ "`maxsize` is deprecated and no longer does anything; "
185
+ "the cache is now handled internally by `dspy.cache`. "
186
+ "This parameter will be removed in a future release." ,
187
+ )
188
+ # ----------------------------------------------------------------------
189
+
175
190
def decorator (fn ):
176
191
@wraps (fn )
177
192
def wrapper (* args , ** kwargs ):
178
193
import dspy
179
194
180
195
cache = dspy .cache
181
196
original_ignored_args_for_cache_key = cache .ignored_args_for_cache_key
182
- cache .ignored_args_for_cache_key = ignored_args_for_cache_key or []
197
+
198
+ # FIXME: Why is this mutating the global cache instead of passing an argument?
199
+ cache .ignored_args_for_cache_key = list (ignored_args_for_cache_key ) or []
183
200
184
201
# Use fully qualified function name for uniqueness
185
202
fn_identifier = f"{ fn .__module__ } .{ fn .__qualname__ } "
0 commit comments