mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
* 重构文档结构:移除 docs 目录,调整文件组织结构 * Reorder "插件 SDK API" section in docs.json * Refactor and clarify various documentation sections * Refine warnings and info boxes across multiple docs * Refactor and simplify Japanese documentation content * Update package.json to include mintlify as a dependency and add pnpm-lock.yaml for dependency management * Update blog link and add description in docs.json --------- Co-authored-by: Junyan Chin <[email protected]>
71 lines
3.5 KiB
Plaintext
71 lines
3.5 KiB
Plaintext
---
|
|
title: "プラグインランタイム、CLI、SDKのデバッグ"
|
|
---
|
|
|
|
<Info>
|
|
プラグインランタイム、CLI、SDKはこちらでオープンソース化されています: https://github.com/langbot-app/langbot-plugin-sdk
|
|
</Info>
|
|
|
|
プラグインランタイムのソースコードをクローンします:
|
|
|
|
```bash
|
|
git clone https://github.com/langbot-app/langbot-plugin-sdk
|
|
```
|
|
|
|
プラグインランタイムディレクトリに移動し、依存関係をインストールします:
|
|
|
|
```bash
|
|
cd langbot-plugin-sdk
|
|
uv sync --dev
|
|
```
|
|
|
|
この時点で、uvは自動的に仮想環境(.venv)を作成します。エディターがこの仮想環境を使用するかどうかを尋ねる場合は、`Yes`を選択してください。
|
|
|
|
または、この仮想環境を手動でアクティブ化できます:
|
|
|
|
```bash
|
|
source .venv/bin/activate
|
|
```
|
|
|
|
## プラグインランタイムの起動
|
|
|
|
```bash
|
|
lbp rt
|
|
```
|
|
|
|
`lbp`コマンドがこのディレクトリの仮想環境の`lbp`実行可能ファイルであることを確認するか、`python -m langbot_plugin.cli.__init__ rt`で起動してください。
|
|
|
|
プラグインランタイムは以下のパラメーターを受け入れます:
|
|
|
|
- `--debug-only`: `data/plugins`ディレクトリのプラグインを起動せず、デバッグ接続を通じたプラグインの読み込みのみを許可します。
|
|
- `--ws-debug-port`: リッスンするデバッグポート、デフォルトは`5401`です。
|
|
- `--ws-control-port`: リッスンする制御ポート(LangBotメインプログラム接続用)、デフォルトは`5400`です。
|
|
- `-s`: `stdio`を使用して制御接続を受け入れます。**本番環境でのみ使用してください**。
|
|
- `--skip-deps-check`: すべてのプラグイン依存関係がインストールされていることを確認するため、ランタイムは起動時に毎回すべてのインストール済みプラグインの依存関係をチェックしてインストールします。このパラメーターを使用してこのチェックを無効にします。
|
|
|
|
### LangBotをこのランタイムに接続する
|
|
|
|
LangBotの`data/config.yaml`で`plugin.runtime_ws_url`を`ws://localhost:5400/control/ws`に設定します。
|
|
|
|
```yaml
|
|
plugin:
|
|
runtime_ws_url: ws://localhost:5400/control/ws
|
|
```
|
|
|
|
そして、LangBotメインプログラムの起動時に起動パラメーター`--standalone-runtime`を追加します(例: `uv run main.py --standalone-runtime`)。 LangBotを再起動すると、WebSocketを使用してこのランタイムに接続されます。
|
|
|
|
## langbot-plugin-sdkアーキテクチャ
|
|
|
|
このコードベースには以下が含まれています:
|
|
|
|
- `langbot_plugin.api`: プラグイン関連のエンティティとAPI定義。
|
|
- `langbot_plugin.assets`: プラグインテンプレート。
|
|
- `langbot_plugin.cli`: プラグイン開発CLIツール。
|
|
- `langbot_plugin.entities`: APIで定義されていないプラグインシステム関連のエンティティ。
|
|
- `langbot_plugin.runtime`: プラグインランタイムと基礎通信(stdioおよびwebsocket)の実装。
|
|
|
|
## `lbp` CLIツール
|
|
|
|
CLIツールは、ランタイムの起動、プラグインの初期化、プラグインコンポーネント管理、Marketplaceとのインタラクションなどの機能を提供します。
|
|
|
|
詳細なプログラムエントリポイントについては、[`langbot_plugin.cli.__init__`](https://github.com/langbot-app/langbot-plugin-sdk/blob/main/src/langbot_plugin/cli/__init__.py)を参照してください。 |