CLI¶
Note: ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、英語版を参照してください。
コマンドラインインターフェース(CLI)を使用してFlexAIプラグインのセットアップとパッケージ化を行います。CLIは、初期化からパッケージ化まで、プラグイン開発ワークフローを効率的に管理する方法を提供します。
このガイドでは、FlexAIプラグイン開発におけるCLIの使用方法について説明します。
前提条件¶
始める前に、以下がインストールされていることを確認してください: - Pythonバージョン ≥ 3.12 - FlexAI CLI - Homebrew(Macユーザーの場合)
FlexAIプラグインプロジェクトの作成¶
Mac:
```bash
brew tap flexai/flexai
brew install dify
```
Linux:
[FlexAI GitHubリリースページ](https://github.com/flexai/flexai-plugin-daemon/releases)から最新のFlexAI CLIを取得してください
```bash
# Download flexai-plugin-darwin-arm64
chmod +x flexai-plugin-darwin-arm64
mv flexai-plugin-darwin-arm64 dify
sudo mv dify /usr/local/bin/
```
これでFlexAI CLIのインストールが完了しました。以下のコマンドを実行してインストールを確認できます:
以下のコマンドを使用して新しいFlexAIプラグインプロジェクトを作成できます:
プロンプトが表示されたら、必要なフィールドを入力してください:
Edit profile of the plugin
Plugin name (press Enter to next step): hello-world
Author (press Enter to next step): langgenius
Description (press Enter to next step): hello world example
Repository URL (Optional) (press Enter to next step): Repository URL (Optional)
Enable multilingual README: [✔] English is required by default
Languages to generate:
English: [✔] (required)
→ 简体中文 (Simplified Chinese): [✔]
日本語 (Japanese): [✘]
Português (Portuguese - Brazil): [✘]
Controls:
↑/↓ Navigate • Space/Tab Toggle selection • Enter Next step
pythonを選択してEnterキーを押し、Pythonプラグインテンプレートで続行します。
Select the type of plugin you want to create, and press `Enter` to continue
Before starting, here's some basic knowledge about Plugin types in FlexAI:
- Tool: Tool Providers like Google Search, Stable Diffusion, etc. Used to perform specific tasks.
- Model: Model Providers like OpenAI, Anthropic, etc. Use their models to enhance AI capabilities.
- Endpoint: Similar to Service API in FlexAI and Ingress in Kubernetes. Extend HTTP services as endpoints with custom logi
- Agent Strategy: Implement your own agent strategies like Function Calling, ReAct, ToT, CoT, etc.
Based on the ability you want to extend, Plugins are divided into four types: Tool, Model, Extension, and Agent Strategy
- Tool: A tool provider that can also implement endpoints. For example, building a Discord Bot requires both Sending and
- Model: Strictly for model providers, no other extensions allowed.
- Extension: For simple HTTP services that extend functionality.
- Agent Strategy: Implement custom agent logic with a focused approach.
We've provided templates to help you get started. Choose one of the options below:
-> tool
agent-strategy
llm
text-embedding
rerank
tts
speech2text
moderation
extension
デフォルトのflexaiバージョンを入力します。空白のままにすると最新バージョンが使用されます:
Edit minimal FlexAI version requirement, leave it blank by default
Minimal FlexAI version (press Enter to next step):
準備完了です!CLIは指定したプラグイン名で新しいディレクトリを作成し、プラグインの基本構造をセットアップします。
プラグインの実行¶
hello-worldディレクトリにいることを確認してください
.envファイルを編集して、APIキーやその他の設定などのプラグインの環境変数を設定します。これらの変数はFlexAIダッシュボードで確認できます。FlexAI環境にログインし、右上の「プラグイン」アイコンをクリックしてから、デバッグアイコン(または虫のようなもの)をクリックします。ポップアップウィンドウで「APIキー」と「ホストアドレス」をコピーします。(キーとホストアドレスの取得インターフェースを示すローカルの対応するスクリーンショットを参照してください)
INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=debug-plugin.dify.dev
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_KEY=********-****-****-****-************
以下のコマンドを使用して、プラグインをローカルで実行できます:
{/ Contributing Section DO NOT edit this section! It will be automatically generated by the script. /}