mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
* docs: update wiki for RAG engine plugin architecture Replace KnowledgeRetriever component docs with RAGEngine across all three languages (zh/en/ja). Key changes: - Add new rag-engine.mdx component docs covering RAGEngine base class, creation_schema/retrieval_schema, capability declarations, lifecycle hooks, host RAG APIs, and complete code examples - Update knowledge base usage docs to reflect unified KB model (remove internal/external distinction, add RAG engine selection flow) - Update component list (add.mdx) and plugin intro to reference RAGEngine - Add RAG API section to plugin common APIs (invoke_embedding, vector_upsert/search/delete, get_rag_file_stream) - Update docs.json navigation to point to rag-engine pages Companion to LangBot PR #1995 and SDK PR #34. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: sync with sdk * docs: update vector API docs with metadata filters, search_type, and documents support - Replace Warning tags about unimplemented filters with Info tags documenting canonical filter format (Chroma-style where syntax) and supported operators - Document search_type/query_text params for full-text and hybrid search - Document documents param for vector_upsert - Update RetrievalContext.filters description from reserved to active - Add filter usage examples (en/zh/ja) Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs: enhance RAG Engine documentation across multiple languages - Expanded the description of the RAG Engine component to include bridging capabilities with advanced knowledge base services like Dify, RAGFlow, and FastGPT. - Clarified the `DOC_INGESTION` capability description, specifying conditions under which the declaration can be omitted. - Updated documentation in English, Japanese, and Chinese to ensure consistency and clarity. * docs: add instructions for show_if conditional rendering * docs: add Parser component documentation (zh/en/ja) Add Parser as a new component type in plugin docs. Parser extracts structured text from binary files (PDF, Word, etc.) before RAG engine ingestion. Includes manifest format, parse method API, data models (ParseContext/ParseResult/TextSection), RAGEngine integration via parsed_content, and cross-plugin invoke_parser API. Also add DOC_PARSING capability to RAG engine docs and parsed_content field to IngestionContext. Companion to SDK PR langbot-app/langbot-plugin-sdk#37 and LangBot PR langbot-app/LangBot#2000. Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs: rename RAGEngine components to KnowledgeEngine * refactor: change rag engine to knowledge engine --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Junyan Qin <[email protected]>
261 lines
8.6 KiB
Plaintext
261 lines
8.6 KiB
Plaintext
---
|
|
title: "プラグイン設定情報の完成"
|
|
---
|
|
|
|
## マニフェストファイルの修正
|
|
|
|
プラグインディレクトリ内の`manifest.yaml`ファイルは、プラグインの基本情報を宣言します。これはLangBot UIまたはプラグインマーケットプレイスのインターフェースに表示されます。
|
|
|
|
```yaml
|
|
apiVersion: v1 # 変更しないでください
|
|
kind: Plugin # 変更しないでください
|
|
metadata:
|
|
author: RockChinQ # 作成者、正規表現^[a-zA-Z0-9_-]+$に一致する必要があります
|
|
name: HelloPlugin # プラグイン名、プラグインを区別するために使用、正規表現^[a-zA-Z0-9-]+$に一致する必要があります
|
|
repository: 'https://github.com/langbot-app/HelloPlugin' # プラグインリポジトリURL
|
|
version: 0.1.0 # プラグインバージョン
|
|
description:
|
|
en_US: 'Hello LangBot Plugin' # プラグイン説明、多言語対応
|
|
zh_Hans: 'Hello LangBot Plugin'
|
|
label:
|
|
en_US: HelloPlugin # プラグインラベル、インターフェースに表示、多言語対応
|
|
zh_Hans: HelloPlugin
|
|
icon: assets/icon.svg # プラグインアイコン、デフォルトはassets/icon.svg、さまざまな画像形式に置き換え可能
|
|
spec:
|
|
config: [] # プラグイン設定項目フォーマット
|
|
components: {} # プラグインコンポーネントリスト、手動で変更する必要はありません
|
|
execution:
|
|
python:
|
|
path: main.py # 変更しないでください
|
|
attr: HelloPlugin # 変更しないでください
|
|
```
|
|
|
|
プラグインの多言語サポートは[RFC 4646](https://datatracker.ietf.org/doc/html/rfc4646)標準に従います。現在サポートされている言語は次のとおりです:
|
|
|
|
- `en_US` 英語
|
|
- `zh_Hans` 簡体字中国語
|
|
- `zh_Hant` 繁体字中国語
|
|
- `ja_JP` 日本語
|
|
|
|
## プラグイン設定項目フォーマット
|
|
|
|
`manifest.yaml`ファイルの`spec.config`で宣言されたフィールドは、LangBotによってユーザーが入力するための設定項目フォームとしてレンダリングされます。プラグインは、SDKが提供するAPIを通じて、ユーザーが入力した設定項目を取得できます(後のセクションを参照)。
|
|
|
|
例えば:
|
|
|
|
```yaml
|
|
spec:
|
|
config:
|
|
- name: github_token # 必須; 設定項目名、プラグイン内での取得に使用
|
|
type: string # 必須; 設定項目タイプ、string、integer、float、boolean、select、prompt-editor、llm-model-selector、bot-selectorなどをサポート
|
|
label: # 必須; 設定項目表示名、多言語サポート。言語コードはRFC 4646標準に従います。
|
|
en_US: Github Token
|
|
zh_Hans: Github Token
|
|
description: # 設定項目説明、多言語サポート。オプション。
|
|
en_US: Image downloading requires a Github token
|
|
zh_Hans: 如果不填的話、图片可能會下載失败
|
|
default: '' # 設定項目のデフォルト値、オプション。
|
|
required: false # 設定項目が必須かどうか、オプション。
|
|
show_if: # 条件付きレンダリング(条件を満たす場合にのみ表示)、オプション。
|
|
field: mode
|
|
operator: eq
|
|
value: mode1
|
|
- name: mode
|
|
type: select
|
|
...
|
|
```
|
|
|
|
設定項目でサポートされるタイプとフィールドは次のとおりです:
|
|
|
|
### 条件付きレンダリング (`show_if`)
|
|
|
|
すべてのタイプの設定項目は、`show_if` フィールドを使用した条件付きレンダリングをサポートしています。同じ(または関連する)フォーム内の他のフィールドの値に基づいて、現在のフィールドをレンダリングして表示するかどうかを決定できます。
|
|
|
|
```yaml
|
|
- name: advanced_setting
|
|
type: string
|
|
show_if:
|
|
field: mode # 依存するフィールドの名前
|
|
operator: eq # 判定演算子。'eq' (等しい)、'neq' (等しくない)、'in' (リストに含まれる) をサポートします
|
|
value: advanced # 判断の基準値
|
|
```
|
|
|
|
> **注意:** クロスフォームのカスケード関係(例:RAG エンジンの `creation_schema` 設定が `retrieval_schema` の値を読み取る、またはその逆)は、LangBot の最新フロントエンドでサポートされています。
|
|
|
|
### type: string
|
|
|
|
文字列型。
|
|
|
|
```yaml
|
|
- name: api_key
|
|
type: string
|
|
...
|
|
```
|
|
|
|
### type: array[string]
|
|
|
|
文字列配列。
|
|
|
|
```yaml
|
|
- name: tags
|
|
type: array[string]
|
|
...
|
|
```
|
|
|
|
### type: integer
|
|
|
|
整数型。
|
|
|
|
```yaml
|
|
- name: progress
|
|
type: integer
|
|
...
|
|
```
|
|
|
|
### type: float
|
|
|
|
浮動小数点型。
|
|
|
|
```yaml
|
|
- name: temperature
|
|
type: float
|
|
...
|
|
```
|
|
|
|
### type: boolean
|
|
|
|
ブール型。
|
|
|
|
```yaml
|
|
- name: is_enabled
|
|
type: boolean
|
|
...
|
|
```
|
|
|
|
### type: select
|
|
|
|
ドロップダウンメニュー。`options`の設定が必要で、ドロップダウンメニューのオプションを表します。
|
|
|
|
```yaml
|
|
- name: mode
|
|
type: select
|
|
options: # ドロップダウンオプション、多言語サポート。
|
|
- name: mode1 # 値
|
|
label: # 表示名、多言語サポート。
|
|
en_US: Mode 1
|
|
zh_Hans: 模式 1
|
|
- name: mode2
|
|
label: # 表示名、多言語サポート。
|
|
en_US: Mode 2
|
|
zh_Hans: 模式 2
|
|
...
|
|
```
|
|
|
|
### type: prompt-editor
|
|
|
|
プロンプトエディター。パイプライン設定ページからプロンプトエディターを表示し、最終結果はOpenAIの`messages`形式で表されます。
|
|
|
|
```yaml
|
|
- name: prompt
|
|
type: prompt-editor
|
|
...
|
|
```
|
|
|
|
### type: text
|
|
|
|
大きなテキスト入力。フロントエンドでtextareaとしてレンダリングされ、ユーザーが入力し、文字列としてプラグインに渡されます。
|
|
|
|
```yaml
|
|
- name: prompt
|
|
type: text
|
|
...
|
|
```
|
|
|
|
### type: file
|
|
|
|
ファイルアップロード。最大10MBのファイルアップロードをサポートし、`{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}`形式でプラグインに渡されます。プラグインは`get_config_file` APIを使用してファイルの内容を取得できます。
|
|
|
|
```yaml
|
|
- name: config_file
|
|
type: file
|
|
accept: 'application/json' # オプション、受け入れるファイルMIMEタイプを指定
|
|
...
|
|
```
|
|
|
|
プラグインでファイルを取得する:
|
|
|
|
```python
|
|
# 設定からファイル情報を取得
|
|
file_config = self.get_config()['config_file']
|
|
file_key = file_config['file_key']
|
|
mimetype = file_config['mimetype']
|
|
|
|
# 出力例: {'file_input': {'file_key': 'plugin_config_d2234fd802054faf80babe0679a97fa9.json', 'mimetype': 'application/json'}}
|
|
print(file_config)
|
|
|
|
# ファイルの内容を取得
|
|
file_bytes = await self.get_config_file(file_key)
|
|
```
|
|
|
|
<Info>
|
|
一般的なMIMEタイプとファイル拡張子のリファレンス: [MDNドキュメント](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)
|
|
</Info>
|
|
|
|
### type: array[file]
|
|
|
|
複数ファイルアップロード。fileタイプと似ていますが、複数のファイルのアップロードをサポートし、`[{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}]`形式でプラグインに渡されます。
|
|
|
|
```yaml
|
|
- name: resource_files
|
|
type: array[file]
|
|
accept: 'image/*' # オプション、受け入れるファイルMIMEタイプを指定
|
|
...
|
|
```
|
|
|
|
プラグインでファイルを取得する:
|
|
|
|
```python
|
|
# 設定からファイルリストを取得
|
|
files_config = self.get_config()['resource_files']
|
|
|
|
for file_config in files_config:
|
|
file_key = file_config['file_key']
|
|
mimetype = file_config['mimetype']
|
|
|
|
# ファイルの内容を取得
|
|
file_bytes = await self.get_config_file(file_key)
|
|
```
|
|
|
|
### type: llm-model-selector
|
|
|
|
LLMモデルセレクター。設定されたLLMモデルを選択できるLLMモデルセレクターを表示し、最終結果はLLMモデルUUIDとして表されます。
|
|
|
|
```yaml
|
|
- name: model
|
|
type: llm-model-selector
|
|
...
|
|
```
|
|
|
|
### type: bot-selector
|
|
|
|
Botセレクター。設定されたBotを選択できるBotセレクターを表示し、最終結果はBot UUIDとして表されます。
|
|
|
|
```yaml
|
|
- name: bot
|
|
type: bot-selector
|
|
...
|
|
```
|
|
|
|
プラグインでBot UUIDを使用する:
|
|
|
|
```python
|
|
# 設定からBot UUIDを取得
|
|
bot_uuid = self.get_config()['bot']
|
|
print(bot_uuid) # 出力: '550e8400-e29b-41d4-a716-446655440000'
|
|
```
|
|
|
|
## 次のステップ
|
|
|
|
このチュートリアルでは、プラグイン機能を段階的に完成させる方法を案内します。
|
|
|
|
- コンポーネントの追加: プラグインコンポーネントはプラグインのコア機能ユニットです。必要に応じて[コンポーネントを追加](/en/plugin/dev/components/add)できます。 |