MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / get_cached_response

Method get_cached_response

optillm/inference.py:757–767  ·  view source on GitHub ↗

Get cached response with fuzzy matching

(self, prompt: str, temperature: float, top_p: float)

Source from the content-addressed store, hash-verified

755 return " ".join(sorted(list(words)))
756
757 def get_cached_response(self, prompt: str, temperature: float, top_p: float) -> Optional[str]:
758 """Get cached response with fuzzy matching"""
759 signature = self._compute_prompt_signature(prompt)
760
761 if signature in self.cache:
762 cached_item = self.cache[signature]
763 if abs(cached_item["temperature"] - temperature) < 0.1 and abs(cached_item["top_p"] - top_p) < 0.1:
764 self.prompt_stats[signature]["count"] += 1
765 return cached_item["response"]
766
767 return None
768
769 def add_to_cache(self, prompt: str, response: str, temperature: float, top_p: float):
770 """Add response to cache with metadata"""

Callers 1

process_batchMethod · 0.80

Calls 1

Tested by

no test coverage detected