import os

from crewai import LLM
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai_tools import (
	EXASearchTool
)






@CrewBase
class MadbradSDataDrivenSalesEngineCrew:
    """MadbradSDataDrivenSalesEngine crew"""

    
    @agent
    def intelligence_agent_lead_researcher(self) -> Agent:
        
        
        return Agent(
            config=self.agents_config["intelligence_agent_lead_researcher"],
            
            
            tools=[				EXASearchTool()],
            reasoning=False,
            max_reasoning_attempts=None,
            inject_date=True,
            allow_delegation=False,
            max_iter=25,
            max_rpm=None,
            
            
            max_execution_time=None,
            llm=LLM(
                model="openai/gpt-4o-mini",
                
                
            ),
            
        )
        
    
    @agent
    def narrative_agent_madbrad_s_copywriter(self) -> Agent:
        
        
        return Agent(
            config=self.agents_config["narrative_agent_madbrad_s_copywriter"],
            
            
            tools=[				EXASearchTool()],
            reasoning=False,
            max_reasoning_attempts=None,
            inject_date=True,
            allow_delegation=False,
            max_iter=25,
            max_rpm=None,
            
            
            max_execution_time=None,
            llm=LLM(
                model="openai/gpt-4o-mini",
                
                
            ),
            
        )
        
    
    @agent
    def operations_agent_sales_director_s_logistics_manager(self) -> Agent:
        
        
        return Agent(
            config=self.agents_config["operations_agent_sales_director_s_logistics_manager"],
            
            
            tools=[],
            reasoning=False,
            max_reasoning_attempts=None,
            inject_date=True,
            allow_delegation=False,
            max_iter=25,
            max_rpm=None,
            
            apps=[
                    "hubspot/create_contact",
                    
                    "hubspot/create_deal",
                    
                    "hubspot/update_contact",
                    
                    "hubspot/list_contacts",
                    
                    "hubspot/search_contacts",
                    ],
            
            
            max_execution_time=None,
            llm=LLM(
                model="openai/gpt-4o-mini",
                
                
            ),
            
        )
        
    

    
    @task
    def lead_intelligence_research(self) -> Task:
        return Task(
            config=self.tasks_config["lead_intelligence_research"],
            markdown=False,
            
            
        )
    
    @task
    def personalized_outreach_creation(self) -> Task:
        return Task(
            config=self.tasks_config["personalized_outreach_creation"],
            markdown=False,
            
            
        )
    
    @task
    def sales_pipeline_operations(self) -> Task:
        return Task(
            config=self.tasks_config["sales_pipeline_operations"],
            markdown=False,
            
            
        )
    

    @crew
    def crew(self) -> Crew:
        """Creates the MadbradSDataDrivenSalesEngine crew"""

        return Crew(
            agents=self.agents,  # Automatically created by the @agent decorator
            tasks=self.tasks,  # Automatically created by the @task decorator
            process=Process.sequential,
            verbose=True,

            chat_llm=LLM(model="openai/gpt-4o-mini"),
        )


