Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]use @callback failed #1948

Open
YDS854394028 opened this issue Jan 22, 2025 · 0 comments
Open

[BUG]use @callback failed #1948

YDS854394028 opened this issue Jan 22, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@YDS854394028
Copy link

Description

"When I use the @callback decorator to pass into Task or Crew, it results in an error."

Steps to Reproduce

@callback
def callback_function(self,output: str):
# Do something after the task is completed
# Example: Send an email to the manager
print(f"""
Task completed!
Task: {output.description}
Output: {output.raw}
""")

@task
def research_task(self) -> Task:
return Task(
config=self.tasks_config['research_task'],
callback=self.callback_function
)

@crew
def crew(self) -> Crew:
"""Creates the Crewaiexample crew"""
# To learn how to add knowledge sources to your crew, check out the documentation:
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge

return Crew(
   agents=self.agents, # Automatically created by the @agent decorator
   #可以不用注解直接传 tasks=[self.research_task(),self.reporting_task()], # Automatically created by the @task decorator
   tasks=self.tasks,
   process=Process.sequential,
   verbose=True,
   cache=True,
   task_callback=self.callback_function
   # process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
)

Expected behavior

in document no page used the @callback

Screenshots/Code snippets

Image

Operating System

Ubuntu 20.04

Python Version

3.10

crewAI Version

0.9

crewAI Tools Version

0.9

Virtual Environment

Venv

Evidence

no

Possible Solution

no

Additional context

no

@YDS854394028 YDS854394028 added the bug Something isn't working label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant