feat:继续重构插件api
This commit is contained in:
@@ -54,7 +54,10 @@ class PluginAPI(MessageAPI, LLMAPI, DatabaseAPI, ConfigAPI, UtilsAPI, StreamAPI,
|
||||
}
|
||||
|
||||
self.log_prefix = log_prefix
|
||||
|
||||
|
||||
# 存储action上下文信息
|
||||
self._action_context = {}
|
||||
|
||||
# 调用所有父类的初始化
|
||||
super().__init__()
|
||||
|
||||
@@ -88,6 +91,17 @@ class PluginAPI(MessageAPI, LLMAPI, DatabaseAPI, ConfigAPI, UtilsAPI, StreamAPI,
|
||||
"""检查是否有指定的服务对象"""
|
||||
return service_name in self._services and self._services[service_name] is not None
|
||||
|
||||
def set_action_context(self, thinking_id: str = None, shutting_down: bool = False, **kwargs):
|
||||
"""设置action上下文信息"""
|
||||
if thinking_id:
|
||||
self._action_context["thinking_id"] = thinking_id
|
||||
self._action_context["shutting_down"] = shutting_down
|
||||
self._action_context.update(kwargs)
|
||||
|
||||
def get_action_context(self, key: str, default=None):
|
||||
"""获取action上下文信息"""
|
||||
return self._action_context.get(key, default)
|
||||
|
||||
|
||||
# 便捷的工厂函数
|
||||
def create_plugin_api(
|
||||
|
||||
Reference in New Issue
Block a user