CrewAI

Fuze integrates with CrewAI via a mixin for BaseTool.

Installation

pip install fuze-ai crewai

Usage

from crewai import BaseTool
from fuze_ai.adapters.crewai import FuzeToolMixin

class SearchTool(FuzeToolMixin, BaseTool):
    name = "search"
    description = "Search the vector database"

    fuze_config = {
        "max_cost": 0.50,
        "max_retries": 3,
    }

    def _run(self, query: str) -> str:
        return vector_db.search(query)

Side-effects

class SendEmailTool(FuzeToolMixin, BaseTool):
    name = "send_email"
    description = "Send an email"

    fuze_config = {
        "side_effect": True,
    }

    def _run(self, to: str, body: str) -> str:
        return ses.send_email(to, body)

    def _compensate(self, result):
        ses.recall_email(result["message_id"])

Wrapping existing tools

from fuze_ai.adapters.crewai import fuze_crew_tools

tools = [SearchTool(), CalculatorTool(), EmailTool()]
guarded = fuze_crew_tools(tools, side_effects={"send_email": recall_email})

Full example

from crewai import Agent, Task, Crew

tools = fuze_crew_tools(
    [SearchTool(), EmailTool()],
    side_effects={"send_email": recall_email},
)

agent = Agent(
    role="Research Assistant",
    goal="Find and summarize information",
    tools=tools,
)

crew = Crew(agents=[agent], tasks=[Task(description="Research quarterly revenue", agent=agent)])
result = crew.kickoff()