mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
Better agent execution error handling (#54)
A few quality of life improvements around cache handling and repeated tool usage
This commit is contained in:
20
crewai/agents/cache/cache_handler.py
vendored
Normal file
20
crewai/agents/cache/cache_handler.py
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import PrivateAttr
|
||||
|
||||
|
||||
class CacheHandler:
|
||||
"""Callback handler for tool usage."""
|
||||
|
||||
_cache: PrivateAttr = {}
|
||||
|
||||
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}")
|
||||
Reference in New Issue
Block a user