文档索引
获取完整文档索引: https://docs.crewai.com.cn/llms.txt
在深入了解之前,请使用此文件来浏览所有可用页面。
在 CrewAI 中,您可以强制将工具的输出作为智能体任务的结果。当您希望确保工具输出被捕获并作为任务结果返回,且避免智能体在任务执行期间对其进行任何修改时,此功能非常有用。
要强制将工具输出作为智能体任务的结果,您需要在向智能体添加工具时将 result_as_answer 参数设置为 True。此参数可确保工具输出被捕获并作为任务结果返回,且不会受到智能体的任何修改。 以下是如何强制将工具输出作为智能体任务结果的示例:from crewai.agent import Agent
from my_tool import MyCustomTool
# Create a coding agent with the custom tool
coding_agent = Agent(
role="Data Scientist",
goal="Produce amazing reports on AI",
backstory="You work with data and AI",
tools=[MyCustomTool(result_as_answer=True)],
)
# Assuming the tool's execution and result population occurs within the system
task_result = coding_agent.execute_task(task)
工作流程实践
智能体交互
智能体可能会对工具的输出进行思考并从中学习,但输出本身不会被修改。