mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
* move base_tool to main package and consolidate tool desscription generation * update import path * update tests * update doc * add base_tool test * migrate agent delegation tools to use BaseTool * update tests * update import path for tool * fix lint * update param signature * add from_langchain to BaseTool for backwards support of langchain tools * fix the case where StructuredTool doesn't have func --------- Co-authored-by: c0dez <li@vitablehealth.com> Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
27 lines
851 B
Python
27 lines
851 B
Python
from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class AskQuestionToolSchema(BaseModel):
|
|
question: str = Field(..., description="The question to ask")
|
|
context: str = Field(..., description="The context for the question")
|
|
coworker: str = Field(..., description="The role/name of the coworker to ask")
|
|
|
|
|
|
class AskQuestionTool(BaseAgentTool):
|
|
"""Tool for asking questions to coworkers"""
|
|
|
|
name: str = "Ask question to coworker"
|
|
args_schema: type[BaseModel] = AskQuestionToolSchema
|
|
|
|
def _run(
|
|
self,
|
|
question: str,
|
|
context: str,
|
|
coworker: Optional[str] = None,
|
|
**kwargs,
|
|
) -> str:
|
|
coworker = self._get_coworker(coworker, **kwargs)
|
|
return self._execute(coworker, question, context)
|