crewAI
crewAI copied to clipboard
[BUG] AttributeError: 'WrappedClass' object has no attribute 'crewer
Description
[This might be not a bug, I come here to seek help.]
I got error: 'AttributeError: 'WrappedClass' object has no attribute 'crewer'. ' when running following code.
It was thrown when executing self.crewer.kickoff(inputs)
As I did not want to create new Crew object each time when I call call method, I introduce the self.crewer here to keep the only crew instance. However, this code fails to run. So how to fix this issue?
`
from crewai import Agent, Crew, Process, Task,LLM from crewai.project import CrewBase, agent, crew, task from crewai_tools import SerperDevTool
llm=LLM( model="deepseek/deepseek-chat", temperature=0.7, max_tokens=150, base_url="https://api.deepseek.com", api_key='xxx' )
class ChanaBaseProcessor: @agent def script_agent(self) -> Agent: return Agent( config=self.agents_config['script_agent'], verbose=True, llm = llm )
@CrewBase class LLMScritProcessor(ChanaBaseProcessor): @task def script_task(self) -> Task: return Task( config=self.tasks_config['script_task'], )
@crew
def crew(self) -> Crew:
if self.crewer is not None:
return self.crewer
self.crewer = Crew(
tasks=[self.script_task()], # Automatically created by the @task decorator
agents=[self.script_agent()], # Automatically created by the @agent decorator
process=Process.sequential,
verbose=True,
)
return self.crewer
def __call__(self, inputs: dict):
self.crewer.kickoff(inputs) # Using self.crewer instead of self.crew().kickoff() is to avoid creating crew object each time
return self.tasks[0].output
if name == "main": script_processor = LLMScritProcessor() example_inputs = { 'topic': 'how human being are created' # Replace with actual input keys and values } output = script_processor(example_inputs)
`
Steps to Reproduce
refer to the #description section.
Expected behavior
It should correctly executed.
Screenshots/Code snippets
refer to the Description section
Operating System
Ubuntu 22.04
Python Version
3.10
crewAI Version
0.80.0
crewAI Tools Version
0.0.0(not clear)
Virtual Environment
Conda
Evidence
Possible Solution
not sure.
Additional context
n/a