Files
crewAI/src/crewai/agents/cache/cache_handler.py
Guilherme Vieira e0d97b9916 Fix static typing errors (#187)
Co-authored-by: João Moura <joaomdmoura@gmail.com>
2024-01-29 19:52:14 -03:00

19 lines
416 B
Python

from typing import Optional
class CacheHandler:
"""Callback handler for tool usage."""
_cache: dict = {}
def __init__(self):
self._cache = {}
def add(self, tool, input, output):
input = input.strip()
self._cache[f"{tool}-{input}"] = output
def read(self, tool, input) -> Optional[str]:
input = input.strip()
return self._cache.get(f"{tool}-{input}")