Skip to main content

Provider-V2 平台插件 SDK — 第三方平台适配器开发与加载

Project description

provider-sdk

Provider-V2 平台插件 SDK。对标 maibot-plugin-sdk 的插件契约,为第三方平台适配器提供独立开发与加载能力。

安装

pip install -e X:\Project\provider-sdk

快速开始

在 Provider Host 的 plugins/ 目录下创建插件文件夹:

plugins/
  my_platform/
    _manifest.json
    plugin.py
    config.toml          # 可选,由 Host 管理

plugin.py 最小示例见 examples/echo_platform/plugin.py

from provider_sdk import ProviderPlugin, PlatformAdapter, Candidate, make_id

class MyPlugin(ProviderPlugin, PlatformAdapter):
    @property
    def name(self) -> str:
        return "my_platform"

    async def on_load(self) -> None:
        self.ctx.logger.info("loaded")

    async def init(self, session): ...
    async def candidates(self) -> list[Candidate]: ...
    async def ensure_candidates(self, count: int) -> int: ...
    async def complete(self, candidate, messages, model, stream, **kw): ...
    async def close(self) -> None: ...

def create_plugin() -> MyPlugin:
    return MyPlugin()

与 MaiBot SDK 的对应关系

MaiBot provider-sdk
MaiBotPlugin ProviderPlugin
create_plugin() create_plugin()
_manifest.json _manifest.json
on_load / on_unload / on_config_update 相同
self.ctx.send / gateway self.ctx.config / http / logger
@Tool / @Command 平台插件以 PlatformAdapter 能力为主

Host 集成

from pathlib import Path
from provider_sdk.integrate import load_platform_plugins, register_loaded_plugins

loaded = await load_platform_plugins(Path("plugins"), session)
register_loaded_plugins(registry, loaded)

完整说明见 docs/guide.md

开发

pip install -e ".[dev]"
pytest -q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

provider_sdk-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

provider_sdk-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file provider_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: provider_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for provider_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc6f947e5aafebf789213c099fafc65cea751100331731492b7afedd924d5c0d
MD5 0c9fb129ffe3821ca2c808e99cdd86d8
BLAKE2b-256 c196e5ba3175711cc7aefd4c2e1bb9d80e47616ed00c04d2d0fda792e5892bec

See more details on using hashes here.

File details

Details for the file provider_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: provider_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for provider_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62fdcff3877f2e28cf303bc8792eed3b1fe90ec484f559d2b0163445cbeb6ebf
MD5 7c8496907096bf994a8e559b2702dfb9
BLAKE2b-256 45f41c68790edbbc91bb1e7c1af6b701a6c1cfa9949cc9db17d619f85979bc2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page