Closed shawn-trilogy closed 1 month ago
We found an issue on the task callback, it's being fixed and will be available in the next version :D
Awesome, thank you so much!!!!
Thank you for using crew, I super appreciate <3
I have same problem. Any idea when new version will be avail?
I have also.
Been debugging for the last hour if something is wrong with my code since I recently updated the crewAI package. Seems like the last release where task callbacks were working is 0.22.4.
João Moura @joaomdmoura http://twitter.com/joaomdmoura
Em seg., 29 de abr. de 2024 às 13:31, Amr Hany Saleh < @.***> escreveu:
Been debugging for the last hour if something is wrong with my code since I recently updated the crewAI package. Seems like the last release where task callbacks were working is 0.22.4.
— Reply to this email directly, view it on GitHub https://github.com/joaomdmoura/crewAI/issues/496#issuecomment-2083175981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3NYIPFKCJ4M7NHHMP3TY7ZYWZAVCNFSM6AAAAABGUHJIEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGE3TKOJYGE . You are receiving this because you commented.Message ID: @.***>
Hey there, I can confirm that this works for crewAI 0.30.11 with this MWE:
from crewai import Agent, Task, Crew, Process
from crewai.tasks.task_output import TaskOutput
from model import llm
def callback_function(output: TaskOutput):
# Do something after the task is completed
# Example: Send an email to the manager
with open("test.txt", "wt") as f:
f.write(f"{output.raw_output}")
agent = Agent(
role="comedian",
backstory="You are the host of a famous late night show and known for your funny stories",
goal='funny story',
verbose=True,
llm=llm
)
task = Task(
description="tell a funny story about the following topic {topic}. Make it short.",
callback=callback_function,
expected_output="a funny story",
agent=agent
)
crew = Crew(
agents=[agent],
tasks=[task],
process=Process.sequential,
verbose=2,
)
if __name__ == "__main__":
crew.kickoff(inputs={"topic": "yellyfish"})
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
I am building a workflow in which I want a few Tasks to write their outputs to a file. To do this, I am trying to give those Tasks a callback to a function that writes their output to a file. However, the callbacks never seem to be called. I've tried using both functions and lambdas as callbacks, and making the callback raise an exception so it would be really obvious that it did something. However, nothing seems to work.
Any ideas what could be the problem, or how I might be able to debug the flow better? Do callbacks for Tasks just not work yet?
Here's a simple example script which shows what I'm trying to do:
And here is the output. As you can see, it never prints that it's writing the file, and no file is generated: