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

Method add_to_cache

optillm/inference.py:769–781  ·  view source on GitHub ↗

Add response to cache with metadata

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

Source from the content-addressed store, hash-verified

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"""
771 signature = self._compute_prompt_signature(prompt)
772
773 self.cache[signature] = {
774 "response": response,
775 "temperature": temperature,
776 "top_p": top_p,
777 "timestamp": torch.cuda.current_timestamp() if torch.cuda.is_available() else 0
778 }
779
780 if len(self.cache) > self.max_size:
781 self.cache.popitem(last=False)
782
783 def update_stats(self, prompt: str, success: bool):
784 """Update prompt success statistics"""

Callers 1

process_batchMethod · 0.80

Calls 1

Tested by

no test coverage detected