perf: display installed plugin icon

This commit is contained in:
Junyan Qin
2025-08-28 23:50:26 +08:00
parent 91959527a4
commit 40f1af4434
5 changed files with 50 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ import typing
import os
import sys
from async_lru import alru_cache
from ..core import app
from . import handler
from ..utils import platform
@@ -153,6 +155,10 @@ class PluginRuntimeConnector:
async def set_plugin_config(self, plugin_author: str, plugin_name: str, config: dict[str, Any]) -> dict[str, Any]:
return await self.handler.set_plugin_config(plugin_author, plugin_name, config)
@alru_cache(ttl=5 * 60) # 5 minutes
async def get_plugin_icon(self, plugin_author: str, plugin_name: str) -> dict[str, Any]:
return await self.handler.get_plugin_icon(plugin_author, plugin_name)
async def emit_event(
self,
event: events.BaseEventModel,

View File

@@ -534,6 +534,17 @@ class RuntimeConnectionHandler(handler.Handler):
return result['tools']
async def get_plugin_icon(self, plugin_author: str, plugin_name: str) -> dict[str, Any]:
"""Get plugin icon"""
result = await self.call_action(
LangBotToRuntimeAction.GET_PLUGIN_ICON,
{
'plugin_author': plugin_author,
'plugin_name': plugin_name,
},
)
return result
async def call_tool(self, tool_name: str, parameters: dict[str, Any]) -> dict[str, Any]:
"""Call tool"""
result = await self.call_action(