crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG]

Open gergirod opened this issue 3 months ago • 8 comments

Description

crew result token usage always 0

total_tokens=0 prompt_tokens=0 cached_prompt_tokens=0 completion_tokens=0 successful_requests=0

Steps to Reproduce

This is how i setup the crew

// this is how I create the agent

def _create_researcher(self):
        return Agent(
            role='Data Researcher',
            goal='Gather comprehensive information about the target profile',
            backstory="""You are an expert in data gathering, specializing in finding comprehensive information online.
                        You know how to craft precise search queries to find specific professional profiles and validate connections.""",
            verbose=True,
            tools=[getSerperTool()],
            allow_delegation=False,
            llm=self.agents_llm
        )

// this is how I create the crew

def _create_crew(self):
        agents = [self._create_researcher(), self._create_info_gatherer()]
        tasks = [self._create_research_task(), self._create_gather_info_task()]
        
        return Crew(
            agents=agents,
            tasks=tasks,
            verbose=True
        )

//this is how I create the LLM

def create_llm(api_key: str):
    return LLM(model=os.getenv("OPENAI_MODEL_NAME"), api_key=api_key, temperature=0.0)
     ```
     
     
	self.set_llm(openai_api_key)
    
    self.crew = self._create_crew()

    inputs = {
        'profile': fullname,
        'company': company,
        'language': language
    }

    result = self.crew.kickoff(inputs=inputs)
        
        

### Expected behavior

i expect that the token usage return the proper token consume by the crew

### Screenshots/Code snippets

This is how i setup the crew

// this is how I create the agent

def _create_researcher(self): return Agent( role='Data Researcher', goal='Gather comprehensive information about the target profile', backstory="""You are an expert in data gathering, specializing in finding comprehensive information online. You know how to craft precise search queries to find specific professional profiles and validate connections.""", verbose=True, tools=[getSerperTool()], allow_delegation=False, llm=self.agents_llm )


// this is how I create the crew

def _create_crew(self): agents = [self._create_researcher(), self._create_info_gatherer()] tasks = [self._create_research_task(), self._create_gather_info_task()]

    return Crew(
        agents=agents,
        tasks=tasks,
        verbose=True
    )

//this is how I create the LLM

def create_llm(api_key: str): return LLM(model=os.getenv("OPENAI_MODEL_NAME"), api_key=api_key, temperature=0.0)



         ```
         
         
		self.set_llm(openai_api_key)
        
        self.crew = self._create_crew()

        inputs = {
            'profile': fullname,
            'company': company,
            'language': language
        }

        result = self.crew.kickoff(inputs=inputs)

Operating System

macOS Monterey

Python Version

3.10

crewAI Version

0.80.0

crewAI Tools Version

0.14.0

Virtual Environment

Venv

Evidence

Uploading Screen Shot 2024-11-14 at 2.20.14 pm.png…

Possible Solution

None

Additional context

OPENAI_MODEL_NAME=gpt-4o-mini

gergirod avatar Nov 14 '24 17:11 gergirod