Add response to cache with metadata
(self, prompt: str, response: str, temperature: float, top_p: float)
| 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""" |
no test coverage detected