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

[FEATURE] Provide more granular callback mechanism #1875

Open
TomeHirata opened this issue Jan 10, 2025 · 0 comments
Open

[FEATURE] Provide more granular callback mechanism #1875

TomeHirata opened this issue Jan 10, 2025 · 0 comments
Labels
feature-request New feature or request

Comments

@TomeHirata
Copy link

Feature Area

Other (please specify in additional context)

Is your feature request related to a an existing bug? Please link it here.

N/A

Describe the solution you'd like

The current implementation for the callback mechanism of CrewAI is enabled by passing a callback function as the Task attribute or Agent attribute. However, since the callback function is called only after the execution, it is challenging to have full observability including latency of the execution. Therefore, it would be great if a new callback attribute is added to Task, Agent and so on that is called before the execution.

def pre_method_callback(input):
  ...

def post_method_callback(output):
  ...

from crewai import Agent
agent = Agent(
    role="Senior Data Scientist",
    goal="Analyze and interpret complex datasets to provide actionable insights",
    backstory="With over 10 years of experience in data science and machine learning, "
              "you excel at finding patterns in complex datasets.",
    llm="gpt-4",
    pre_callback=pre_method_callback,
    post_callback=post_method_callback,
)

Describe alternatives you've considered

Alternatively, the callback function could be configured as a global configuration as DSPy does. In this approach, one callback class will be defined and configured globally. The callback class implements the callback methods for each major class (e.g. Crew, Task, Agent) separately.
https://dspy.ai/tutorials/observability/

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

@TomeHirata TomeHirata added the feature-request New feature or request label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant