Skip to main content
Enable caching to store and reuse task responses for similar inputs, reducing API costs and improving performance.

Quick Start

Cache Methods

Vector Search (Default)

Uses semantic similarity to find cached responses for similar inputs.

LLM Call

Uses an LLM to determine if cached responses are applicable.

Configuration Options

Full Example

Task Cache Methods

get_cache_stats()

Get cache statistics including hit rate and configuration.
Returns:
  • total_entries: Number of cached entries
  • cache_hits: Number of cache hits
  • cache_misses: Number of cache misses
  • hit_rate: Cache hit rate (0.0-1.0)
  • cache_method: Current cache method
  • cache_threshold: Current threshold
  • cache_hit: Whether last request was a cache hit
  • session_id: Current session ID

clear_cache()

Clear all cache entries.

Best Practices

  • Threshold Tuning: Start with 0.7, increase for stricter matching
  • Duration: Set based on how often your data changes
  • Method Choice: Use vector_search for speed, llm_call for accuracy
  • Embedding Provider: Auto-detected if not specified