""" Cache Module Responsibilities: - Store previous responses - Return cached answers - Reduce repeated LLM requests """ from functools import wraps # ============================================================ # Memory Cache Storage # ============================================================ response_cache = {} # ============================================================ # Cache Decorator # ============================================================ def cached_response(function): """ Decorator for caching function responses. """ @wraps(function) def wrapper(*args, **kwargs): # Create unique cache key cache_key = str( args ) + str( kwargs ) # Check existing response if cache_key in response_cache: return response_cache[ cache_key ] # Generate new response result = function( *args, **kwargs ) # Store response response_cache[ cache_key ] = result return result return wrapper