mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-11 00:06:04 +00:00
feat: discovering plugins by manifests
This commit is contained in:
@@ -8,6 +8,7 @@ import enum
|
||||
from . import events
|
||||
from ..provider.tools import entities as tools_entities
|
||||
from ..core import app
|
||||
from ..discover import engine as discover_engine
|
||||
from ..platform.types import message as platform_message
|
||||
from ..platform import adapter as platform_adapter
|
||||
|
||||
@@ -308,7 +309,10 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
plugin_name: str
|
||||
"""插件名称"""
|
||||
|
||||
plugin_description: str
|
||||
plugin_label: discover_engine.I18nString
|
||||
"""插件标签"""
|
||||
|
||||
plugin_description: discover_engine.I18nString
|
||||
"""插件描述"""
|
||||
|
||||
plugin_version: str
|
||||
@@ -317,7 +321,7 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
plugin_author: str
|
||||
"""插件作者"""
|
||||
|
||||
plugin_source: str
|
||||
plugin_repository: str
|
||||
"""插件源码地址"""
|
||||
|
||||
main_file: str
|
||||
@@ -343,7 +347,7 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
]] = {}
|
||||
"""事件处理器"""
|
||||
|
||||
content_functions: list[tools_entities.LLMFunction] = []
|
||||
tools: list[tools_entities.LLMFunction] = []
|
||||
"""内容函数"""
|
||||
|
||||
status: RuntimeContainerStatus = RuntimeContainerStatus.MOUNTED
|
||||
@@ -355,10 +359,10 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
def to_setting_dict(self):
|
||||
return {
|
||||
'name': self.plugin_name,
|
||||
'description': self.plugin_description,
|
||||
'description': self.plugin_description.to_dict(),
|
||||
'version': self.plugin_version,
|
||||
'author': self.plugin_author,
|
||||
'source': self.plugin_source,
|
||||
'source': self.plugin_repository,
|
||||
'main_file': self.main_file,
|
||||
'pkg_path': self.pkg_path,
|
||||
'priority': self.priority,
|
||||
@@ -369,17 +373,18 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
self,
|
||||
setting: dict
|
||||
):
|
||||
self.plugin_source = setting['source']
|
||||
self.plugin_repository = setting['source']
|
||||
self.priority = setting['priority']
|
||||
self.enabled = setting['enabled']
|
||||
|
||||
def model_dump(self, *args, **kwargs):
|
||||
return {
|
||||
'name': self.plugin_name,
|
||||
'description': self.plugin_description,
|
||||
'label': self.plugin_label.to_dict(),
|
||||
'description': self.plugin_description.to_dict(),
|
||||
'version': self.plugin_version,
|
||||
'author': self.plugin_author,
|
||||
'source': self.plugin_source,
|
||||
'repository': self.plugin_repository,
|
||||
'main_file': self.main_file,
|
||||
'pkg_path': self.pkg_path,
|
||||
'enabled': self.enabled,
|
||||
@@ -388,7 +393,7 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
event_name.__name__: handler.__name__
|
||||
for event_name, handler in self.event_handlers.items()
|
||||
},
|
||||
'content_functions': [
|
||||
'tools': [
|
||||
{
|
||||
'name': function.name,
|
||||
'human_desc': function.human_desc,
|
||||
@@ -396,7 +401,7 @@ class RuntimeContainer(pydantic.BaseModel):
|
||||
'parameters': function.parameters,
|
||||
'func': function.func.__name__,
|
||||
}
|
||||
for function in self.content_functions
|
||||
for function in self.tools
|
||||
],
|
||||
'status': self.status.value,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user