-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Implement baisc system events for application lifecycle #1428
Conversation
插件启动的序列图sequenceDiagram
participant PluginLoader
participant Plugin
participant EventBus
PluginLoader->>Plugin: on_start()
activate Plugin
Plugin->>EventBus: post(PluginStarted(plugin))
deactivate Plugin
插件停止的序列图sequenceDiagram
participant PluginLoader
participant Plugin
participant EventBus
PluginLoader->>Plugin: on_stop()
activate Plugin
Plugin->>Plugin: event_bus.unregister_all()
Plugin->>EventBus: post(PluginStopped(plugin))
deactivate Plugin
工作流执行的序列图sequenceDiagram
participant WorkflowExecutor
participant EventBus
WorkflowExecutor->>EventBus: post(WorkflowExecutionBegin(workflow, self))
activate WorkflowExecutor
WorkflowExecutor->>WorkflowExecutor: _execute_nodes()
WorkflowExecutor->>EventBus: post(WorkflowExecutionEnd(workflow, self, self.results))
deactivate WorkflowExecutor
LLM 适配器加载的序列图sequenceDiagram
participant LLMManager
participant LLMBackendAdapter
participant EventBus
LLMManager->>LLMBackendAdapter: load_backend()
activate LLMBackendAdapter
LLMManager->>EventBus: post(LLMAdapterLoaded(adapter))
deactivate LLMBackendAdapter
LLM 适配器卸载的序列图sequenceDiagram
participant LLMManager
participant LLMBackendAdapter
participant EventBus
LLMManager->>LLMBackendAdapter: unload_backend()
activate LLMBackendAdapter
LLMManager->>EventBus: post(LLMAdapterUnloaded(adapter))
deactivate LLMBackendAdapter
IM 适配器启动的序列图sequenceDiagram
participant IMManager
participant IMAdapter
participant EventBus
IMManager->>IMAdapter: start()
activate IMAdapter
IMManager->>EventBus: post(IMAdapterStarted(adapter))
deactivate IMAdapter
IM 适配器停止的序列图sequenceDiagram
participant IMManager
participant IMAdapter
participant EventBus
IMManager->>IMAdapter: stop()
activate IMAdapter
IMManager->>EventBus: post(IMAdapterStopped(adapter))
deactivate IMAdapter
应用程序启动的序列图sequenceDiagram
participant Application
participant EventBus
Application->>EventBus: post(ApplicationStarted())
应用程序停止的序列图sequenceDiagram
participant Application
participant EventBus
Application->>EventBus: post(ApplicationStopping())
PluginEventBus 的更新类图classDiagram
class PluginEventBus {
-event_bus: EventBus
-registered_listeners: List[Callable]
+__init__(event_bus: EventBus)
+register(event_type: Type, listener: Callable)
+unregister(event_type: Type, listener: Callable)
+post(event)
+unregister_all()
}
PluginEventBus -- EventBus : uses
文件级别更改
提示和命令与 Sourcery 交互
自定义您的体验访问您的 仪表板 以:
获得帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request introduces a basic system event mechanism to the application. It defines new event classes for application, plugin, IM, LLM, and workflow events. The Sequence diagram for Plugin LoadingsequenceDiagram
participant PluginLoader
participant Plugin
participant EventBus
PluginLoader->>Plugin: instantiate_plugin()
activate Plugin
PluginLoader->>Plugin: on_load()
Plugin->>EventBus: post(PluginLoaded(plugin))
deactivate Plugin
Sequence diagram for Plugin StartingsequenceDiagram
participant PluginLoader
participant Plugin
participant EventBus
PluginLoader->>Plugin: on_start()
activate Plugin
Plugin->>EventBus: post(PluginStarted(plugin))
deactivate Plugin
Sequence diagram for Plugin StoppingsequenceDiagram
participant PluginLoader
participant Plugin
participant EventBus
PluginLoader->>Plugin: on_stop()
activate Plugin
Plugin->>Plugin: event_bus.unregister_all()
Plugin->>EventBus: post(PluginStopped(plugin))
deactivate Plugin
Sequence diagram for Workflow ExecutionsequenceDiagram
participant WorkflowExecutor
participant EventBus
WorkflowExecutor->>EventBus: post(WorkflowExecutionBegin(workflow, self))
activate WorkflowExecutor
WorkflowExecutor->>WorkflowExecutor: _execute_nodes()
WorkflowExecutor->>EventBus: post(WorkflowExecutionEnd(workflow, self, self.results))
deactivate WorkflowExecutor
Sequence diagram for LLM Adapter LoadingsequenceDiagram
participant LLMManager
participant LLMBackendAdapter
participant EventBus
LLMManager->>LLMBackendAdapter: load_backend()
activate LLMBackendAdapter
LLMManager->>EventBus: post(LLMAdapterLoaded(adapter))
deactivate LLMBackendAdapter
Sequence diagram for LLM Adapter UnloadingsequenceDiagram
participant LLMManager
participant LLMBackendAdapter
participant EventBus
LLMManager->>LLMBackendAdapter: unload_backend()
activate LLMBackendAdapter
LLMManager->>EventBus: post(LLMAdapterUnloaded(adapter))
deactivate LLMBackendAdapter
Sequence diagram for IM Adapter StartingsequenceDiagram
participant IMManager
participant IMAdapter
participant EventBus
IMManager->>IMAdapter: start()
activate IMAdapter
IMManager->>EventBus: post(IMAdapterStarted(adapter))
deactivate IMAdapter
Sequence diagram for IM Adapter StoppingsequenceDiagram
participant IMManager
participant IMAdapter
participant EventBus
IMManager->>IMAdapter: stop()
activate IMAdapter
IMManager->>EventBus: post(IMAdapterStopped(adapter))
deactivate IMAdapter
Sequence diagram for Application StartingsequenceDiagram
participant Application
participant EventBus
Application->>EventBus: post(ApplicationStarted())
Sequence diagram for Application StoppingsequenceDiagram
participant Application
participant EventBus
Application->>EventBus: post(ApplicationStopping())
Updated class diagram for PluginEventBusclassDiagram
class PluginEventBus {
-event_bus: EventBus
-registered_listeners: List[Callable]
+__init__(event_bus: EventBus)
+register(event_type: Type, listener: Callable)
+unregister(event_type: Type, listener: Callable)
+post(event)
+unregister_all()
}
PluginEventBus -- EventBus : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @lss233 - 我已经审查了你的更改 - 这里有一些反馈:
总体评论:
- 考虑为事件类添加一个基类或协议,以提供一个公共接口。
- 这些测试现在正在注册 EventBus,但没有使用它 - 考虑添加一个断言来验证是否发布了一个事件。
以下是我在审查期间查看的内容
- 🟡 一般问题:发现 4 个问题
- 🟢 安全性:一切看起来都很好
- 🟡 测试:发现 1 个问题
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @lss233 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a base class or protocol for the event classes to provide a common interface.
- The tests are now registering the EventBus, but not using it - consider adding an assertion that an event was posted.
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #1428 +/- ##
==========================================
+ Coverage 68.82% 69.25% +0.43%
==========================================
Files 106 113 +7
Lines 4718 4820 +102
==========================================
+ Hits 3247 3338 +91
- Misses 1471 1482 +11 ☔ View full report in Codecov by Sentry. |
- Add new event classes for application, plugin, IM, LLM, and workflow events - Enhance EventBus with error handling and logging - Modify managers and loaders to emit events during key lifecycle stages - Refactor PluginEventBus to use global EventBus - Update workflow executor to emit execution events
2351f97
to
3219e02
Compare
- Move LLM adapter event posting outside of the loop in LLMManager - Fix Ollama adapter model list parsing to use correct JSON key - Update backend deletion route to use correct backend enable flag
本次提交提供了一些基础事件供插件使用。
插件可以通过下面的方式来注册事件监听器:
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
实现了一个基本的系统事件机制,用于跟踪应用程序生命周期事件。 这包括添加新的事件类,增强 EventBus 的错误处理能力,修改管理器和加载器以发出事件,重构 PluginEventBus 以使用全局 EventBus,以及更新工作流执行器以发出执行事件。
新功能:
测试:
Original summary in English
Summary by Sourcery
Implements a basic system event mechanism for tracking application lifecycle events. This includes adding new event classes, enhancing the EventBus with error handling, modifying managers and loaders to emit events, refactoring PluginEventBus to use the global EventBus, and updating the workflow executor to emit execution events.
New Features:
Tests: