mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-06 22:58:30 +00:00
* feat: add initial changes from langchain * feat: remove kwargs of being processed * feat: remove langchain, update uv.lock and fix type_hint * feat: change docs * feat: remove forced requirements for parameter * feat add tests for new structure tool * feat: fix tests and adapt code for args
28 lines
812 B
Python
28 lines
812 B
Python
from pydantic import BaseModel, Field
|
|
|
|
from crewai.agents.cache import CacheHandler
|
|
from crewai.tools.structured_tool import CrewStructuredTool
|
|
|
|
|
|
class CacheTools(BaseModel):
|
|
"""Default tools to hit the cache."""
|
|
|
|
name: str = "Hit Cache"
|
|
cache_handler: CacheHandler = Field(
|
|
description="Cache Handler for the crew",
|
|
default_factory=CacheHandler,
|
|
)
|
|
|
|
def tool(self):
|
|
return CrewStructuredTool.from_function(
|
|
func=self.hit_cache,
|
|
name=self.name,
|
|
description="Reads directly from the cache",
|
|
)
|
|
|
|
def hit_cache(self, key):
|
|
split = key.split("tool:")
|
|
tool = split[1].split("|input:")[0].strip()
|
|
tool_input = split[1].split("|input:")[1].strip()
|
|
return self.cache_handler.read(tool, tool_input)
|