Files
crewAI/src/crewai/agents/cache/cache_handler.py
Brandon Hancock (bhancock_ai) bf7372fefa Adding Autocomplete to OSS (#1198)
* Cleaned up model_config

* Fix pydantic issues

* 99% done with autocomplete

* fixed test issues

* Fix type checking issues
2024-08-16 15:04:21 -04:00

16 lines
414 B
Python

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