Get cached response with fuzzy matching
(self, prompt: str, temperature: float, top_p: float)
| 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""" |
no test coverage detected