langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
46.76k stars 6.61k forks source link

refactor: update Callback to an abstract class #8868

Closed hwzhuhao closed 15 hours ago

hwzhuhao commented 16 hours ago

Checklist:

[!IMPORTANT]
Please review the checklist below before submitting your pull request.

Description

Currently, in the base_callback module, the Callback class includes four methods: on_before_invoke, on_new_chunk, on_after_invoke, and on_invoke_error. The implementations of these methods simply raise a NotImplementedError. However, the inheriting class, LoggingCallback, has overridden all of these methods. In order to facilitate future expansion by users, it is suggested to refactor this class into an abstract class, thereby making it mandatory for its subclasses to implement these methods.

image

image

Fixes

Type of Change

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration