mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-05 05:16:03 +00:00
perf: Filter plugins by component types in pipeline extensions (#1821)
* Initial plan * Add component-kind filtering to list_plugins and filter pipeline extensions to only show plugins with Command, EventListener, or Tool components Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> * fix: testing path --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> Co-authored-by: Junyan Qin <rockchinq@gmail.com>
This commit is contained in:
@@ -59,7 +59,10 @@ class PipelinesRouterGroup(group.RouterGroup):
|
||||
if pipeline is None:
|
||||
return self.http_status(404, -1, 'pipeline not found')
|
||||
|
||||
plugins = await self.ap.plugin_connector.list_plugins()
|
||||
# Only include plugins with pipeline-related components (Command, EventListener, Tool)
|
||||
# Plugins that only have KnowledgeRetriever components are not suitable for pipeline extensions
|
||||
pipeline_component_kinds = ['Command', 'EventListener', 'Tool']
|
||||
plugins = await self.ap.plugin_connector.list_plugins(component_kinds=pipeline_component_kinds)
|
||||
mcp_servers = await self.ap.mcp_service.get_mcp_servers(contain_runtime_info=True)
|
||||
|
||||
extensions_prefs = pipeline.get('extensions_preferences', {})
|
||||
|
||||
@@ -284,12 +284,35 @@ class PluginRuntimeConnector:
|
||||
task_context.trace('Cleaning up plugin configuration and storage...')
|
||||
await self.handler.cleanup_plugin_data(plugin_author, plugin_name)
|
||||
|
||||
async def list_plugins(self) -> list[dict[str, Any]]:
|
||||
async def list_plugins(self, component_kinds: list[str] | None = None) -> list[dict[str, Any]]:
|
||||
"""List plugins, optionally filtered by component kinds.
|
||||
|
||||
Args:
|
||||
component_kinds: Optional list of component kinds to filter by.
|
||||
If provided, only plugins that contain at least one
|
||||
component of the specified kinds will be returned.
|
||||
E.g., ['Command', 'EventListener', 'Tool'] for pipeline-related plugins.
|
||||
"""
|
||||
if not self.is_enable_plugin:
|
||||
return []
|
||||
|
||||
plugins = await self.handler.list_plugins()
|
||||
|
||||
# Filter plugins by component kinds if specified
|
||||
if component_kinds is not None:
|
||||
filtered_plugins = []
|
||||
for plugin in plugins:
|
||||
components = plugin.get('components', [])
|
||||
has_matching_component = False
|
||||
for component in components:
|
||||
component_kind = component.get('manifest', {}).get('manifest', {}).get('kind', '')
|
||||
if component_kind in component_kinds:
|
||||
has_matching_component = True
|
||||
break
|
||||
if has_matching_component:
|
||||
filtered_plugins.append(plugin)
|
||||
plugins = filtered_plugins
|
||||
|
||||
# Sort plugins: debug plugins first, then by installation time (newest first)
|
||||
# Get installation timestamps from database in a single query
|
||||
plugin_timestamps = {}
|
||||
|
||||
Reference in New Issue
Block a user