mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 15:18:29 +00:00
* Cleaned up model_config * Fix pydantic issues * 99% done with autocomplete * fixed test issues * Fix type checking issues
16 lines
414 B
Python
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}")
|